diff --git a/core/src/io/anuke/mindustry/ctype/UnlockableContent.java b/core/src/io/anuke/mindustry/ctype/UnlockableContent.java index 7082b4a431..ab1e4d9e4b 100644 --- a/core/src/io/anuke/mindustry/ctype/UnlockableContent.java +++ b/core/src/io/anuke/mindustry/ctype/UnlockableContent.java @@ -42,11 +42,6 @@ public abstract class UnlockableContent extends MappableContent{ return cicons[icon.ordinal()]; } - /** Returns the localized name of this content. */ - public abstract String localizedName(); - - //public abstract TextureRegion getContentIcon(); - /** This should show all necessary info about this content in the specified table. */ public abstract void displayInfo(Table table); diff --git a/core/src/io/anuke/mindustry/mod/Mods.java b/core/src/io/anuke/mindustry/mod/Mods.java index 974be2f634..bdcd7ca800 100644 --- a/core/src/io/anuke/mindustry/mod/Mods.java +++ b/core/src/io/anuke/mindustry/mod/Mods.java @@ -392,7 +392,7 @@ public class Mods implements Loadable{ if(mod.root.child("scripts").exists()){ content.setCurrentMod(mod); mod.scripts = mod.root.child("scripts").findAll(f -> f.extension().equals("js")); - Log.info("[{0}] Found {1} scripts.", mod.meta.name, mod.scripts.size); + Log.debug("[{0}] Found {1} scripts.", mod.meta.name, mod.scripts.size); for(FileHandle file : mod.scripts){ try{ @@ -415,7 +415,7 @@ public class Mods implements Loadable{ content.setCurrentMod(null); } - Log.info("Time to initialize modded scripts: {0}", Time.elapsed()); + Log.debug("Time to initialize modded scripts: {0}", Time.elapsed()); } /** Creates all the content found in mod files. */ diff --git a/core/src/io/anuke/mindustry/mod/Scripts.java b/core/src/io/anuke/mindustry/mod/Scripts.java index 84fdc4e5d3..664c1e54ff 100644 --- a/core/src/io/anuke/mindustry/mod/Scripts.java +++ b/core/src/io/anuke/mindustry/mod/Scripts.java @@ -26,7 +26,7 @@ public class Scripts implements Disposable{ wrapper = Core.files.internal("scripts/wrapper.js").readString(); run(Core.files.internal("scripts/global.js").readString(), "global.js"); - Log.info("Time to load script engine: {0}", Time.elapsed()); + Log.debug("Time to load script engine: {0}", Time.elapsed()); } public String runConsole(String text){ @@ -52,7 +52,7 @@ public class Scripts implements Disposable{ public void log(String source, String message){ Log.info("[{0}]: {1}", source, message); logBuffer.add("[accent][" + source + "]:[] " + message); - if(!headless & ui.scriptfrag != null){ + if(!headless && ui.scriptfrag != null){ onLoad(); } } diff --git a/core/src/io/anuke/mindustry/type/Item.java b/core/src/io/anuke/mindustry/type/Item.java index 86951ab093..597eb468b5 100644 --- a/core/src/io/anuke/mindustry/type/Item.java +++ b/core/src/io/anuke/mindustry/type/Item.java @@ -1,10 +1,9 @@ package io.anuke.mindustry.type; -import io.anuke.arc.*; import io.anuke.arc.collection.*; import io.anuke.arc.graphics.*; import io.anuke.arc.scene.ui.layout.*; -import io.anuke.mindustry.ctype.UnlockableContent; +import io.anuke.mindustry.ctype.*; import io.anuke.mindustry.ui.*; import io.anuke.mindustry.world.blocks.*; @@ -50,14 +49,9 @@ public class Item extends UnlockableContent{ ContentDisplay.displayItem(table, this); } - @Override - public String localizedName(){ - return Core.bundle.get("item." + this.name + ".name"); - } - @Override public String toString(){ - return localizedName(); + return localizedName; } @Override diff --git a/core/src/io/anuke/mindustry/type/Liquid.java b/core/src/io/anuke/mindustry/type/Liquid.java index 63839c479c..8ed87e7941 100644 --- a/core/src/io/anuke/mindustry/type/Liquid.java +++ b/core/src/io/anuke/mindustry/type/Liquid.java @@ -1,11 +1,10 @@ package io.anuke.mindustry.type; -import io.anuke.arc.*; import io.anuke.arc.graphics.*; import io.anuke.arc.scene.ui.layout.*; import io.anuke.arc.util.ArcAnnotate.*; import io.anuke.mindustry.content.*; -import io.anuke.mindustry.ctype.UnlockableContent; +import io.anuke.mindustry.ctype.*; import io.anuke.mindustry.ui.*; public class Liquid extends UnlockableContent{ @@ -51,14 +50,9 @@ public class Liquid extends UnlockableContent{ ContentDisplay.displayLiquid(table, this); } - @Override - public String localizedName(){ - return Core.bundle.get("liquid." + this.name + ".name"); - } - @Override public String toString(){ - return localizedName(); + return localizedName; } @Override diff --git a/core/src/io/anuke/mindustry/type/Mech.java b/core/src/io/anuke/mindustry/type/Mech.java index a9419a116b..7a5de5ae2d 100644 --- a/core/src/io/anuke/mindustry/type/Mech.java +++ b/core/src/io/anuke/mindustry/type/Mech.java @@ -45,10 +45,6 @@ public class Mech extends UnlockableContent{ this(name, false); } - public String localizedName(){ - return Core.bundle.get("mech." + name + ".name"); - } - public void updateAlt(Player player){ } @@ -112,6 +108,6 @@ public class Mech extends UnlockableContent{ @Override public String toString(){ - return localizedName(); + return localizedName; } } diff --git a/core/src/io/anuke/mindustry/type/UnitType.java b/core/src/io/anuke/mindustry/type/UnitType.java index ddcaa4f36f..c559177139 100644 --- a/core/src/io/anuke/mindustry/type/UnitType.java +++ b/core/src/io/anuke/mindustry/type/UnitType.java @@ -64,11 +64,6 @@ public class UnitType extends UnlockableContent{ ContentDisplay.displayUnit(table, this); } - @Override - public String localizedName(){ - return Core.bundle.get("unit." + name + ".name"); - } - @Override public void load(){ weapon.load(); diff --git a/core/src/io/anuke/mindustry/type/Zone.java b/core/src/io/anuke/mindustry/type/Zone.java index e0084f0b73..c60249b223 100644 --- a/core/src/io/anuke/mindustry/type/Zone.java +++ b/core/src/io/anuke/mindustry/type/Zone.java @@ -205,11 +205,6 @@ public class Zone extends UnlockableContent{ public void displayInfo(Table table){ } - @Override - public String localizedName(){ - return Core.bundle.get("zone." + name + ".name"); - } - @Override public ContentType getContentType(){ return ContentType.zone; diff --git a/core/src/io/anuke/mindustry/ui/ContentDisplay.java b/core/src/io/anuke/mindustry/ui/ContentDisplay.java index e086e4e616..36f100d6a3 100644 --- a/core/src/io/anuke/mindustry/ui/ContentDisplay.java +++ b/core/src/io/anuke/mindustry/ui/ContentDisplay.java @@ -66,7 +66,7 @@ public class ContentDisplay{ table.table(title -> { title.addImage(item.icon(Cicon.xlarge)).size(8 * 6); - title.add("[accent]" + item.localizedName()).padLeft(5); + title.add("[accent]" + item.localizedName).padLeft(5); }); table.row(); @@ -100,7 +100,7 @@ public class ContentDisplay{ table.table(title -> { title.addImage(liquid.icon(Cicon.xlarge)).size(8 * 6); - title.add("[accent]" + liquid.localizedName()).padLeft(5); + title.add("[accent]" + liquid.localizedName).padLeft(5); }); table.row(); @@ -134,7 +134,7 @@ public class ContentDisplay{ public static void displayMech(Table table, Mech mech){ table.table(title -> { title.addImage(mech.icon(Cicon.xlarge)).size(8 * 6); - title.add("[accent]" + mech.localizedName()).padLeft(5); + title.add("[accent]" + mech.localizedName).padLeft(5); }); table.left().defaults().left(); @@ -182,7 +182,7 @@ public class ContentDisplay{ public static void displayUnit(Table table, UnitType unit){ table.table(title -> { title.addImage(unit.icon(Cicon.xlarge)).size(8 * 6); - title.add("[accent]" + unit.localizedName()).padLeft(5); + title.add("[accent]" + unit.localizedName).padLeft(5); }); table.row(); diff --git a/core/src/io/anuke/mindustry/ui/ItemDisplay.java b/core/src/io/anuke/mindustry/ui/ItemDisplay.java index 1efcd10919..a55a5034c5 100644 --- a/core/src/io/anuke/mindustry/ui/ItemDisplay.java +++ b/core/src/io/anuke/mindustry/ui/ItemDisplay.java @@ -15,7 +15,7 @@ public class ItemDisplay extends Table{ public ItemDisplay(Item item, int amount, boolean showName){ add(new ItemImage(new ItemStack(item, amount))).size(8 * 4).padRight(amount > 99 ? 12 : 0); - if(showName) add(item.localizedName()).padLeft(4 + amount > 99 ? 4 : 0); + if(showName) add(item.localizedName).padLeft(4 + amount > 99 ? 4 : 0); this.item = item; this.amount = amount; diff --git a/core/src/io/anuke/mindustry/ui/ItemsDisplay.java b/core/src/io/anuke/mindustry/ui/ItemsDisplay.java index f10b17e3eb..e198673c08 100644 --- a/core/src/io/anuke/mindustry/ui/ItemsDisplay.java +++ b/core/src/io/anuke/mindustry/ui/ItemsDisplay.java @@ -29,7 +29,7 @@ public class ItemsDisplay extends Table{ if(item.type == ItemType.material && data.isUnlocked(item)){ t.label(() -> format(item)).left(); t.addImage(item.icon(Cicon.small)).size(8 * 3).padLeft(4).padRight(4); - t.add(item.localizedName()).color(Color.lightGray).left(); + t.add(item.localizedName).color(Color.lightGray).left(); t.row(); } } diff --git a/core/src/io/anuke/mindustry/ui/LiquidDisplay.java b/core/src/io/anuke/mindustry/ui/LiquidDisplay.java index be4d22b124..741491d9b9 100644 --- a/core/src/io/anuke/mindustry/ui/LiquidDisplay.java +++ b/core/src/io/anuke/mindustry/ui/LiquidDisplay.java @@ -33,6 +33,6 @@ public class LiquidDisplay extends Table{ add(StatUnit.perSecond.localized()).padLeft(2).padRight(5).color(Color.lightGray); } - add(liquid.localizedName()); + add(liquid.localizedName); } } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/DatabaseDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/DatabaseDialog.java index faa3f6f39a..65adb85efa 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/DatabaseDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/DatabaseDialog.java @@ -66,7 +66,7 @@ public class DatabaseDialog extends FloatingDialog{ if(unlocked(unlock)){ image.clicked(() -> Vars.ui.content.show(unlock)); - image.addListener(new Tooltip(t -> t.background(Tex.button).add(unlock.localizedName()))); + image.addListener(new Tooltip(t -> t.background(Tex.button).add(unlock.localizedName))); } if((++count) % maxWidth == 0){ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java index 056d0cfc24..a84ff1a73c 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java @@ -155,7 +155,7 @@ public class DeployDialog extends FloatingDialog{ }).color(Color.darkGray).grow())); } - TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName()), Styles.squaret, () -> { + TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName), Styles.squaret, () -> { control.saves.getZoneSlot().cautiousLoad(() -> { hide(); ui.loadAnd(() -> { @@ -232,7 +232,7 @@ public class DeployDialog extends FloatingDialog{ }); if(zone.unlocked() && !hidden(zone)){ - button.labelWrap(zone.localizedName()).style(Styles.outlineLabel).width(140).growX().get().setAlignment(Align.center); + button.labelWrap(zone.localizedName).style(Styles.outlineLabel).width(140).growX().get().setAlignment(Align.center); }else{ Cons flasher = zone.canUnlock() && !hidden(zone) ? e -> e.update(() -> e.getColor().set(Color.white).lerp(Pal.accent, Mathf.absin(3f, 1f))) : e -> {}; flasher.get(button.addImage(Icon.locked).get()); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/TechTreeDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/TechTreeDialog.java index a9b8282a36..7a60ad2724 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/TechTreeDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/TechTreeDialog.java @@ -337,7 +337,7 @@ public class TechTreeDialog extends FloatingDialog{ t.table(list -> { list.left(); list.addImage(req.item.icon(Cicon.small)).size(8 * 3).padRight(3); - list.add(req.item.localizedName()).color(Color.lightGray); + list.add(req.item.localizedName).color(Color.lightGray); list.label(() -> " " + Math.min(data.getItem(req.item), req.amount) + " / " + req.amount) .update(l -> l.setColor(data.has(req.item, req.amount) ? Color.lightGray : Color.scarlet)); }).fillX().left(); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java index 32d2e264f1..1bf34b0855 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java @@ -96,7 +96,7 @@ public class ZoneInfoDialog extends FloatingDialog{ }).growX(); }else{ - cont.add(zone.localizedName()).color(Pal.accent).growX().center(); + cont.add(zone.localizedName).color(Pal.accent).growX().center(); cont.row(); cont.addImage().color(Pal.accent).height(3).pad(6).growX(); cont.row(); diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index f9dcd9c779..6e001d38b5 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -395,11 +395,6 @@ public class Block extends BlockStorage{ return sum / size / size; } - @Override - public String localizedName(){ - return localizedName; - } - @Override public void displayInfo(Table table){ ContentDisplay.displayBlock(table, this); @@ -552,7 +547,7 @@ public class Block extends BlockStorage{ }else{ current = entity -> entity.liquids.current(); } - bars.add("liquid", entity -> new Bar(() -> entity.liquids.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName(), + bars.add("liquid", entity -> new Bar(() -> entity.liquids.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName, () -> current.get(entity).barColor(), () -> entity.liquids.get(current.get(entity)) / liquidCapacity)); } diff --git a/core/src/io/anuke/mindustry/world/blocks/OreBlock.java b/core/src/io/anuke/mindustry/world/blocks/OreBlock.java index ba74f2db0f..7270ec7aa0 100644 --- a/core/src/io/anuke/mindustry/world/blocks/OreBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/OreBlock.java @@ -16,7 +16,7 @@ public class OreBlock extends OverlayFloor{ public OreBlock(Item ore){ super("ore-" + ore.name); - this.localizedName = ore.localizedName(); + this.localizedName = ore.localizedName; this.itemDrop = ore; this.variants = 3; this.color.set(ore.color); @@ -29,7 +29,7 @@ public class OreBlock extends OverlayFloor{ } public void setup(Item ore){ - this.localizedName = ore.localizedName(); + this.localizedName = ore.localizedName; this.itemDrop = ore; this.color.set(ore.color); } @@ -80,6 +80,6 @@ public class OreBlock extends OverlayFloor{ @Override public String getDisplayName(Tile tile){ - return itemDrop.localizedName(); + return itemDrop.localizedName; } } diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java index c4ee18715a..14788104d9 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java @@ -191,7 +191,7 @@ public class Drill extends Block{ Item item = list.get(i); table.addImage(Core.atlas.find(item.name + "1")).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3); - table.add(item.localizedName()); + table.add(item.localizedName); if(i != list.size - 1){ table.add("/").padLeft(5).padRight(5); } diff --git a/core/src/io/anuke/mindustry/world/meta/values/AmmoListValue.java b/core/src/io/anuke/mindustry/world/meta/values/AmmoListValue.java index c531fabe45..c19503c5d1 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/AmmoListValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/AmmoListValue.java @@ -29,7 +29,7 @@ public class AmmoListValue implements StatValue{ for(T t : map.keys()){ BulletType type = map.get(t); table.addImage(icon(t)).size(3 * 8).padRight(4).right().top(); - table.add(t.localizedName()).padRight(10).left().top(); + table.add(t.localizedName).padRight(10).left().top(); table.table(Tex.underline, bt -> { bt.left().defaults().padRight(3).left(); diff --git a/core/src/io/anuke/mindustry/world/meta/values/BoosterListValue.java b/core/src/io/anuke/mindustry/world/meta/values/BoosterListValue.java index 4d1a867904..30c1ff0765 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/BoosterListValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/BoosterListValue.java @@ -33,7 +33,7 @@ public class BoosterListValue implements StatValue{ if(!filter.get(liquid)) continue; c.addImage(liquid.icon(Cicon.medium)).size(3 * 8).padRight(4).right().top(); - c.add(liquid.localizedName()).padRight(10).left().top(); + c.add(liquid.localizedName).padRight(10).left().top(); c.table(Tex.underline, bt -> { bt.left().defaults().padRight(3).left(); diff --git a/server/src/io/anuke/mindustry/server/ServerControl.java b/server/src/io/anuke/mindustry/server/ServerControl.java index f8f03f526e..ba5722e843 100644 --- a/server/src/io/anuke/mindustry/server/ServerControl.java +++ b/server/src/io/anuke/mindustry/server/ServerControl.java @@ -357,6 +357,10 @@ public class ServerControl implements ApplicationListener{ } }); + handler.register("js", "", "Run arbitrary Javascript.", arg -> { + info("&lc" + mods.getScripts().runConsole(arg[0])); + }); + handler.register("say", "", "Send a message to all players.", arg -> { if(!state.is(State.playing)){ err("Not hosting. Host a game first.");