diff --git a/core/src/mindustry/Vars.java b/core/src/mindustry/Vars.java index 2653b55975..2cf07cbea6 100644 --- a/core/src/mindustry/Vars.java +++ b/core/src/mindustry/Vars.java @@ -89,7 +89,7 @@ public class Vars implements Loadable{ /** duration of time between turns in ticks */ public static final float turnDuration = 2 * Time.toMinutes; /** chance of an invasion per turn, 1 = 100% */ - public static final float baseInvasionChance = 1f / 25f; + public static final float baseInvasionChance = 1f / 30f; /** how many turns have to pass before invasions start */ public static final int invasionGracePeriod = 20; /** min armor fraction damage; e.g. 0.05 = at least 5% damage */ @@ -285,10 +285,10 @@ public class Vars implements Loadable{ if(loadedLogger) return; String[] tags = {"[green][D][]", "[royal][I][]", "[yellow][W][]", "[scarlet][E][]", ""}; - String[] stags = {"&lc&fb[D]", "&lg&fb[I]", "&ly&fb[W]", "&lr&fb[E]", ""}; + String[] stags = {"&lc&fb[D]", "&lb&fb[I]", "&ly&fb[W]", "&lr&fb[E]", ""}; Seq logBuffer = new Seq<>(); - Log.setLogger((level, text) -> { + Log.logger = (level, text) -> { String result = text; String rawText = Log.format(stags[level.ordinal()] + "&fr " + text); System.out.println(rawText); @@ -304,9 +304,9 @@ public class Vars implements Loadable{ } } - ui.scriptfrag.addMessage(Log.removeCodes(result)); + ui.scriptfrag.addMessage(Log.removeColors(result)); } - }); + }; Events.on(ClientLoadEvent.class, e -> logBuffer.each(ui.scriptfrag::addMessage)); @@ -319,18 +319,19 @@ public class Vars implements Loadable{ settings.setAppName(appName); Writer writer = settings.getDataDirectory().child("last_log.txt").writer(false); - LogHandler log = Log.getLogger(); - Log.setLogger((level, text) -> { + LogHandler log = Log.logger; + //ignore it + Log.logger = (level, text) -> { log.log(level, text); try{ - writer.write("[" + Character.toUpperCase(level.name().charAt(0)) +"] " + Log.removeCodes(text) + "\n"); + writer.write("[" + Character.toUpperCase(level.name().charAt(0)) +"] " + Log.removeColors(text) + "\n"); writer.flush(); }catch(IOException e){ e.printStackTrace(); //ignore it } - }); + }; loadedFileLogger = true; } diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index ae8c7d9a7c..3c6214fd85 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -194,14 +194,14 @@ public class NetClient implements ApplicationListener{ } //server console logging - Log.info("&y@: &lb@", player.name, message); + Log.info("&fi@: @", "&lc" + player.name, "&lw" + message); //invoke event for all clients but also locally //this is required so other clients get the correct name even if they don't know who's sending it yet Call.sendMessage(message, colorizeName(player.id(), player.name), player); }else{ //log command to console but with brackets - Log.info("<&y@: &lm@&lg>", player.name, message); + Log.info("<&fi@: @&fr>", "&lk" + player.name, "&lw" + message); //a command was sent, now get the output if(response.type != ResponseType.valid){ diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index d9f944c1aa..74e3ebb9c5 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -508,7 +508,8 @@ public class NetServer implements ApplicationListener{ Call.playerDisconnect(player.id()); } - if(Config.showConnectMessages.bool()) Log.info("&lm[@] &lc@ has disconnected. &lg&fi(@)", player.uuid(), player.name, reason); + String message = Strings.format("&lb@&fi&lk has disconnected. &fi&lk[&lb@&fi&lk] (@)", player.name, player.uuid(), reason); + if(Config.showConnectMessages.bool()) Log.info(message); } player.remove(); @@ -736,7 +737,8 @@ public class NetServer implements ApplicationListener{ if(Config.showConnectMessages.bool()){ Call.sendMessage("[accent]" + player.name + "[accent] has connected."); - Log.info("&lm[@] &y@ has connected.", player.uuid(), player.name); + String message = Strings.format("&lb@&fi&lk has connected. &fi&lk[&lb@&fi&lk]", player.name, player.uuid()); + Log.info(message); } if(!Config.motd.string().equalsIgnoreCase("off")){ @@ -785,7 +787,7 @@ public class NetServer implements ApplicationListener{ public void openServer(){ try{ net.host(Config.port.num()); - info("&lcOpened a server on port @.", Config.port.num()); + info("Opened a server on port @.", Config.port.num()); }catch(BindException e){ Log.err("Unable to host: Port already in use! Make sure no other servers are running on the same port in your network."); state.set(State.menu); diff --git a/core/src/mindustry/ctype/UnlockableContent.java b/core/src/mindustry/ctype/UnlockableContent.java index d3f21845ad..9020cd0ff1 100644 --- a/core/src/mindustry/ctype/UnlockableContent.java +++ b/core/src/mindustry/ctype/UnlockableContent.java @@ -112,6 +112,14 @@ public abstract class UnlockableContent extends MappableContent{ } } + /** Unlocks this content, but does not fire any events. */ + public void quiteUnlock(){ + if(!unlocked()){ + unlocked = true; + Core.settings.put(name + "-unlocked", true); + } + } + public boolean unlocked(){ if(net.client()) return state.rules.researched.contains(name); return unlocked || alwaysUnlocked; diff --git a/core/src/mindustry/game/Universe.java b/core/src/mindustry/game/Universe.java index 2140f08271..9b1064a791 100644 --- a/core/src/mindustry/game/Universe.java +++ b/core/src/mindustry/game/Universe.java @@ -6,6 +6,7 @@ import arc.struct.*; import arc.util.*; import mindustry.content.*; import mindustry.game.EventType.*; +import mindustry.io.legacy.*; import mindustry.maps.*; import mindustry.type.*; import mindustry.world.blocks.storage.*; @@ -260,6 +261,11 @@ public class Universe{ private void load(){ seconds = Core.settings.getInt("utimei"); turn = Core.settings.getInt("turn"); + + if(Core.settings.has("unlocks")){ + LegacyIO.readResearch(); + Core.settings.remove("unlocks"); + } } } diff --git a/core/src/mindustry/io/legacy/LegacyIO.java b/core/src/mindustry/io/legacy/LegacyIO.java index 545487d8ca..0bb84f3fc7 100644 --- a/core/src/mindustry/io/legacy/LegacyIO.java +++ b/core/src/mindustry/io/legacy/LegacyIO.java @@ -2,6 +2,8 @@ package mindustry.io.legacy; import arc.*; import arc.struct.*; +import mindustry.*; +import mindustry.ctype.*; import mindustry.ui.dialogs.JoinDialog.*; import java.io.*; @@ -48,4 +50,35 @@ public class LegacyIO{ return arr; } + public static void readResearch(){ + try{ + byte[] bytes = Core.settings.getBytes("unlocks"); + DataInputStream stream = new DataInputStream(new ByteArrayInputStream(bytes)); + + int length = stream.readInt(); + if(length > 0){ + stream.readUTF(); //name of key type + stream.readUTF(); //name of value type + + //each element is an array list + for(int i = 0; i < length; i++){ + ContentType type = ContentType.all[stream.readInt()]; + int arrLength = stream.readInt(); + if(arrLength > 0){ + stream.readUTF(); //type of contents (String) + for(int j = 0; j < arrLength; j++){ + String name = stream.readUTF(); + Content out = Vars.content.getByName(type, name); + if(out instanceof UnlockableContent u){ + u.unlock(); + } + } + } + } + } + }catch(Exception e){ + e.printStackTrace(); + } + } + } diff --git a/core/src/mindustry/mod/Scripts.java b/core/src/mindustry/mod/Scripts.java index 1aa260e8fa..f372586863 100644 --- a/core/src/mindustry/mod/Scripts.java +++ b/core/src/mindustry/mod/Scripts.java @@ -59,12 +59,12 @@ public class Scripts implements Disposable{ if(o instanceof Undefined) o = "undefined"; return String.valueOf(o); }catch(Throwable t){ - return getError(t); + return getError(t, false); } } - private String getError(Throwable t){ - t.printStackTrace(); + private String getError(Throwable t, boolean log){ + if(log) Log.err(t); return t.getClass().getSimpleName() + (t.getMessage() == null ? "" : ": " + t.getMessage()); } @@ -138,7 +138,7 @@ public class Scripts implements Disposable{ if(currentMod != null){ file = currentMod.name + "/" + file; } - log(LogLevel.err, file, "" + getError(t)); + log(LogLevel.err, file, "" + getError(t, true)); return false; } } diff --git a/core/src/mindustry/net/Administration.java b/core/src/mindustry/net/Administration.java index f185744c28..ccf5f76755 100644 --- a/core/src/mindustry/net/Administration.java +++ b/core/src/mindustry/net/Administration.java @@ -577,7 +577,10 @@ public class Administration{ autosave("Whether the periodically save the map when playing.", false), autosaveAmount("The maximum amount of autosaves. Older ones get replaced.", 10), autosaveSpacing("Spacing between autosaves in seconds.", 60 * 5), - debug("Enable debug logging", false, () -> Log.setLogLevel(debug() ? LogLevel.debug : LogLevel.info)); + debug("Enable debug logging", false, () -> { + LogLevel level = debug() ? LogLevel.debug : LogLevel.info; + Log.level = level; + }); public static final Config[] all = values(); diff --git a/core/src/mindustry/net/NetworkIO.java b/core/src/mindustry/net/NetworkIO.java index acaf9f9640..f4494e1c4f 100644 --- a/core/src/mindustry/net/NetworkIO.java +++ b/core/src/mindustry/net/NetworkIO.java @@ -58,8 +58,6 @@ public class NetworkIO{ state.rules = JsonIO.read(Rules.class, stream.readUTF()); state.map = new Map(SaveIO.getSaveWriter().readStringMap(stream)); - Log.info("READ RULES: @", state.rules.researched); - state.wave = stream.readInt(); state.wavetime = stream.readFloat(); diff --git a/gradle.properties b/gradle.properties index 0ebd9ffd28..5cda8698c7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=46ebdb4aeb1e03ca6b3b4c27a93533dc92278a33 +archash=723aa43b053b753631ed54906e7669132cddfdc6 diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index 48f529b187..7e1be67c52 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -30,6 +30,7 @@ import java.time.*; import java.time.format.*; import java.util.*; +import static arc.util.ColorCodes.*; import static arc.util.Log.*; import static mindustry.Vars.*; @@ -37,7 +38,7 @@ public class ServerControl implements ApplicationListener{ private static final int roundExtraTime = 12; private static final int maxLogLength = 1024 * 512; - protected static String[] tags = {"&lc&fb[D]", "&lg&fb[I]", "&ly&fb[W]", "&lr&fb[E]", ""}; + protected static String[] tags = {"&lc&fb[D]&fr", "&lb&fb[I]&fr", "&ly&fb[W]&fr", "&lr&fb[E]", ""}; protected static DateTimeFormatter dateTime = DateTimeFormatter.ofPattern("MM-dd-yyyy HH:mm:ss"), autosaveDate = DateTimeFormatter.ofPattern("MM-dd-yyyy_HH-mm-ss"); @@ -74,22 +75,27 @@ public class ServerControl implements ApplicationListener{ lastMode = Gamemode.survival; } - Log.setLogger((level, text) -> { - String result = "[" + dateTime.format(LocalDateTime.now()) + "] " + format(tags[level.ordinal()] + " " + text + "&fr"); + logger = (level1, text) -> { + String result = bold + lightBlack + "[" + dateTime.format(LocalDateTime.now()) + "] " + reset + format(tags[level1.ordinal()] + " " + text + "&fr"); System.out.println(result); if(Config.logging.bool()){ - logToFile("[" + dateTime.format(LocalDateTime.now()) + "] " + formatColors(tags[level.ordinal()] + " " + text + "&fr", false)); + logToFile("[" + dateTime.format(LocalDateTime.now()) + "] " + formatColors(tags[level1.ordinal()] + " " + text + "&fr", false)); } if(socketOutput != null){ try{ socketOutput.println(formatColors(text + "&fr", false)); - }catch(Throwable e){ - err("Error occurred logging to socket: @", e.getClass().getSimpleName()); + }catch(Throwable e1){ + err("Error occurred logging to socket: @", e1.getClass().getSimpleName()); } } - }); + }; + + formatter = (text, useColors, arg) -> { + text = Strings.format(text.replace("@", "&fb&lb@&fr"), arg); + return useColors ? addColors(text) : removeColors(text); + }; Time.setDeltaProvider(() -> Core.graphics.getDeltaTime() * 60f); @@ -115,12 +121,12 @@ public class ServerControl implements ApplicationListener{ if(args.length > 0){ commands.addAll(Strings.join(" ", args).split(",")); - info("&lmFound @ command-line arguments to parse.", commands.size); + info("Found @ command-line arguments to parse.", commands.size); } if(!Config.startCommands.string().isEmpty()){ String[] startup = Strings.join(" ", Config.startCommands.string()).split(","); - info("&lmFound @ startup commands.", startup.length); + info("Found @ startup commands.", startup.length); commands.addAll(startup); } @@ -128,7 +134,7 @@ public class ServerControl implements ApplicationListener{ CommandResponse response = handler.handleMessage(s); if(response.type != ResponseType.valid){ err("Invalid command argument sent: '@': @", s, response.type.name()); - err("Argument usage: &lc , "); + err("Argument usage: &lb , "); } } }); @@ -141,7 +147,7 @@ public class ServerControl implements ApplicationListener{ if(Version.build == -1){ warn("&lyYour server is running a custom build, which means that client checking is disabled."); - warn("&lyIt is highly advised to specify which version you're using by building with gradle args &lc-Pbuildversion=&lm&ly."); + warn("&lyIt is highly advised to specify which version you're using by building with gradle args &lb&fb-Pbuildversion=&lr"); } //set up default shuffle mode @@ -154,9 +160,9 @@ public class ServerControl implements ApplicationListener{ Events.on(GameOverEvent.class, event -> { if(inExtraRound) return; if(state.rules.waves){ - info("&lcGame over! Reached wave &ly@&lc with &ly@&lc players online on map &ly@&lc.", state.wave, Groups.player.size(), Strings.capitalize(state.map.name())); + info("Game over! Reached wave @ with @ players online on map @.", state.wave, Groups.player.size(), Strings.capitalize(state.map.name())); }else{ - info("&lcGame over! Team &ly@&lc is victorious with &ly@&lc players online on map &ly@&lc.", event.winner.name, Groups.player.size(), Strings.capitalize(state.map.name())); + info("Game over! Team @ is victorious with @ players online on map @.", event.winner.name, Groups.player.size(), Strings.capitalize(state.map.name())); } //set next map to be played @@ -209,11 +215,11 @@ public class ServerControl implements ApplicationListener{ String fileName = "auto_" + mapName + "_" + date + "." + saveExtension; Fi file = saveDirectory.child(fileName); - info("&lbAutosaving..."); + info("Autosaving..."); try{ SaveIO.save(file); - info("&lbAutosave completed."); + info("Autosave completed."); }catch(Throwable e){ err("Autosave failed.", e); } @@ -241,25 +247,25 @@ public class ServerControl implements ApplicationListener{ Timer.schedule(() -> Core.settings.forceSave(), saveInterval, saveInterval); if(!mods.list().isEmpty()){ - info("&lc@ mods loaded.", mods.list().size); + info("@ mods loaded.", mods.list().size); } toggleSocket(Config.socketInput.bool()); - info("&lcServer loaded. Type &ly'help'&lc for help."); + info("Server loaded. Type @ for help.", "'help'"); } private void registerCommands(){ handler.register("help", "Displays this command list.", arg -> { info("Commands:"); for(Command command : handler.getCommandList()){ - info(" &y" + command.text + (command.paramText.isEmpty() ? "" : " ") + command.paramText + " - &lm" + command.description); + info(" &b&lb " + command.text + (command.paramText.isEmpty() ? "" : " &lc&fi") + command.paramText + "&fr - &lw" + command.description); } }); handler.register("version", "Displays server version info.", arg -> { - info("&lmVersion: &lyMindustry @-@ @ / build @", Version.number, Version.modifier, Version.type, Version.build + (Version.revision == 0 ? "" : "." + Version.revision)); - info("&lmJava Version: &ly@", System.getProperty("java.version")); + info("Version: Mindustry @-@ @ / build @", Version.number, Version.modifier, Version.type, Version.build + (Version.revision == 0 ? "" : "." + Version.revision)); + info("Java Version: @", System.getProperty("java.version")); }); handler.register("exit", "Exit the server application.", arg -> { @@ -299,7 +305,7 @@ public class ServerControl implements ApplicationListener{ result = maps.all().find(map -> map.name().equalsIgnoreCase(arg[0].replace('_', ' ')) || map.name().equalsIgnoreCase(arg[0])); if(result == null){ - err("No map with name &y'@'&lr found.", arg[0]); + err("No map with name '@' found.", arg[0]); return; } }else{ @@ -329,21 +335,21 @@ public class ServerControl implements ApplicationListener{ if(!maps.all().isEmpty()){ info("Maps:"); for(Map map : maps.all()){ - info(" &ly@: &lb&fi@ / @x@", map.name(), map.custom ? "Custom" : "Default", map.width, map.height); + info(" @: &fi@ / @x@", map.name(), map.custom ? "Custom" : "Default", map.width, map.height); } }else{ info("No maps found."); } - info("&lyMap directory: &lb&fi@", customMapDirectory.file().getAbsoluteFile().toString()); + info("Map directory: &fi@", customMapDirectory.file().getAbsoluteFile().toString()); }); handler.register("reloadmaps", "Reload all maps from disk.", arg -> { int beforeMaps = maps.all().size; maps.reload(); if(maps.all().size > beforeMaps){ - info("&lc@&ly new map(s) found and reloaded.", maps.all().size - beforeMaps); + info("@ new map(s) found and reloaded.", maps.all().size - beforeMaps); }else{ - info("&lyMaps reloaded."); + info("Maps reloaded."); } }); @@ -352,23 +358,23 @@ public class ServerControl implements ApplicationListener{ info("Status: &rserver closed"); }else{ info("Status:"); - info(" &lyPlaying on map &fi@&fb &lb/&ly Wave @", Strings.capitalize(state.map.name()), state.wave); + info(" Playing on map &fi@ / Wave @", Strings.capitalize(state.map.name()), state.wave); if(state.rules.waves){ - info("&ly @ enemies.", state.enemies); + info(" @ enemies.", state.enemies); }else{ - info("&ly @ seconds until next wave.", (int)(state.wavetime / 60)); + info(" @ seconds until next wave.", (int)(state.wavetime / 60)); } - info(" &ly@ FPS, @ MB used.", Core.graphics.getFramesPerSecond(), Core.app.getJavaHeap() / 1024 / 1024); + info(" @ FPS, @ MB used.", Core.graphics.getFramesPerSecond(), Core.app.getJavaHeap() / 1024 / 1024); if(Groups.player.size() > 0){ - info(" &lyPlayers: @", Groups.player.size()); + info(" Players: @", Groups.player.size()); for(Player p : Groups.player){ - info(" &y@ / @", p.name(), p.uuid()); + info(" @ / @", p.name, p.uuid()); } }else{ - info(" &lyNo players connected."); + info(" No players connected."); } } }); @@ -377,30 +383,30 @@ public class ServerControl implements ApplicationListener{ if(!mods.list().isEmpty()){ info("Mods:"); for(LoadedMod mod : mods.list()){ - info(" &ly@ &lcv@", mod.meta.displayName(), mod.meta.version); + info(" @ &fi@", mod.meta.displayName(), mod.meta.version); } }else{ info("No mods found."); } - info("&lyMod directory: &lb&fi@", modDirectory.file().getAbsoluteFile().toString()); + info("Mod directory: &fi@", modDirectory.file().getAbsoluteFile().toString()); }); handler.register("mod", "", "Display information about a loaded plugin.", arg -> { LoadedMod mod = mods.list().find(p -> p.meta.name.equalsIgnoreCase(arg[0])); if(mod != null){ - info("Name: &ly@", mod.meta.displayName()); - info("Internal Name: &ly@", mod.name); - info("Version: &ly@", mod.meta.version); - info("Author: &ly@", mod.meta.author); - info("Path: &ly@", mod.file.path()); - info("Description: &ly@", mod.meta.description); + info("Name: @", mod.meta.displayName()); + info("Internal Name: @", mod.name); + info("Version: @", mod.meta.version); + info("Author: @", mod.meta.author); + info("Path: @", mod.file.path()); + info("Description: @", mod.meta.description); }else{ - info("No mod with name &ly'@'&lg found."); + info("No mod with name '@' found."); } }); handler.register("js", "", "Run arbitrary Javascript.", arg -> { - info("&lc" + mods.getScripts().runConsole(arg[0])); + info("&fi&lw&fb" + mods.getScripts().runConsole(arg[0])); }); handler.register("say", "", "Send a message to all players.", arg -> { @@ -411,7 +417,7 @@ public class ServerControl implements ApplicationListener{ Call.sendMessage("[scarlet][[Server]:[] " + arg[0]); - info("&lyServer: &lb@", arg[0]); + info("&fi&lcServer: &fr@", "&lw" + arg[0]); }); @@ -426,7 +432,7 @@ public class ServerControl implements ApplicationListener{ JsonValue base = JsonIO.json().fromJson(null, rules); if(arg.length == 0){ - Log.info("&lyRules:\n@", JsonIO.print(rules)); + Log.info("Rules:\n@", JsonIO.print(rules)); }else if(arg.length == 1){ Log.err("Invalid usage. Specify which rule to remove or add."); }else{ @@ -438,7 +444,7 @@ public class ServerControl implements ApplicationListener{ boolean remove = arg[0].equals("remove"); if(remove){ if(base.has(arg[1])){ - Log.info("Rule &lc'@'&lg removed.", arg[1]); + Log.info("Rule '@' removed.", arg[1]); base.remove(arg[1]); }else{ Log.err("Rule not defined, so not removed."); @@ -462,7 +468,7 @@ public class ServerControl implements ApplicationListener{ base.remove(value.name); } base.addChild(arg[1], value); - Log.info("Changed rule: &ly@", value.toString().replace("\n", " ")); + Log.info("Changed rule: @", value.toString().replace("\n", " ")); }catch(Throwable e){ Log.err("Error parsing rule JSON: @", e.getMessage()); } @@ -501,7 +507,7 @@ public class ServerControl implements ApplicationListener{ handler.register("playerlimit", "[off/somenumber]", "Set the server player limit.", arg -> { if(arg.length == 0){ - info("Player limit is currently &lc@.", netServer.admins.getPlayerLimit() == 0 ? "off" : netServer.admins.getPlayerLimit()); + info("Player limit is currently @.", netServer.admins.getPlayerLimit() == 0 ? "off" : netServer.admins.getPlayerLimit()); return; } if(arg[0].equals("off")){ @@ -521,11 +527,11 @@ public class ServerControl implements ApplicationListener{ handler.register("config", "[name] [value...]", "Configure server settings.", arg -> { if(arg.length == 0){ - info("&lyAll config values:"); + info("All config values:"); for(Config c : Config.all){ - Log.info("&ly| &lc@:&lm @", c.name(), c.get()); - Log.info("&ly| | @", c.description); - Log.info("&ly|"); + Log.info("&lk| @: @", c.name(), "&lc&fi" + c.get()); + Log.info("&lk| | &lw" + c.description); + Log.info("&lk|"); } return; } @@ -533,7 +539,7 @@ public class ServerControl implements ApplicationListener{ try{ Config c = Config.valueOf(arg[0]); if(arg.length == 1){ - Log.info("&lc'@'&lg is currently &lc@.", c.name(), c.get()); + Log.info("'@' is currently @.", c.name(), c.get()); }else{ if(c.isBool()){ c.set(arg[1].equals("on") || arg[1].equals("true")); @@ -548,7 +554,7 @@ public class ServerControl implements ApplicationListener{ c.set(arg[1]); } - Log.info("&lc@&lg set to &lc@.", c.name(), c.get()); + Log.info("@ set to @.", c.name(), c.get()); Core.settings.forceSave(); } }catch(IllegalArgumentException e){ @@ -558,9 +564,9 @@ public class ServerControl implements ApplicationListener{ handler.register("subnet-ban", "[add/remove] [address]", "Ban a subnet. This simply rejects all connections with IPs starting with some string.", arg -> { if(arg.length == 0){ - Log.info("Subnets banned: &lc@", netServer.admins.getSubnetBans().isEmpty() ? "" : ""); + Log.info("Subnets banned: @", netServer.admins.getSubnetBans().isEmpty() ? "" : ""); for(String subnet : netServer.admins.getSubnetBans()){ - Log.info("&ly " + subnet + ""); + Log.info("&lw " + subnet + ""); } }else if(arg.length == 1){ err("You must provide a subnet to add or remove."); @@ -572,7 +578,7 @@ public class ServerControl implements ApplicationListener{ } netServer.admins.addSubnetBan(arg[1]); - Log.info("Banned &ly@&lc**", arg[1]); + Log.info("Banned @**", arg[1]); }else if(arg[0].equals("remove")){ if(!netServer.admins.getSubnetBans().contains(arg[1])){ err("That subnet isn't banned."); @@ -580,7 +586,7 @@ public class ServerControl implements ApplicationListener{ } netServer.admins.removeSubnetBan(arg[1]); - Log.info("Unbanned &ly@&lc**", arg[1]); + Log.info("Unbanned @**", arg[1]); }else{ err("Incorrect usage. You must provide add/remove as the second argument."); } @@ -589,12 +595,12 @@ public class ServerControl implements ApplicationListener{ handler.register("whitelisted", "List the entire whitelist.", arg -> { if(netServer.admins.getWhitelisted().isEmpty()){ - info("&lyNo whitelisted players found."); + info("No whitelisted players found."); return; } - info("&lyWhitelist:"); - netServer.admins.getWhitelisted().each(p -> Log.info("- &ly@", p.lastName)); + info("Whitelist:"); + netServer.admins.getWhitelisted().each(p -> info("- @", p.lastName)); }); handler.register("whitelist-add", "", "Add a player to the whitelist by ID.", arg -> { @@ -605,7 +611,7 @@ public class ServerControl implements ApplicationListener{ } netServer.admins.whitelist(arg[0]); - info("Player &ly'@'&lg has been whitelisted.", info.lastName); + info("Player '@' has been whitelisted.", info.lastName); }); handler.register("whitelist-remove", "", "Remove a player to the whitelist by ID.", arg -> { @@ -616,18 +622,18 @@ public class ServerControl implements ApplicationListener{ } netServer.admins.unwhitelist(arg[0]); - info("Player &ly'@'&lg has been un-whitelisted.", info.lastName); + info("Player '@' has been un-whitelisted.", info.lastName); }); handler.register("shuffle", "[none/all/custom/builtin]", "Set map shuffling mode.", arg -> { if(arg.length == 0){ - info("Shuffle mode current set to &ly'@'&lg.", maps.getShuffleMode()); + info("Shuffle mode current set to '@'.", maps.getShuffleMode()); }else{ try{ ShuffleMode mode = ShuffleMode.valueOf(arg[0]); Core.settings.put("shufflemode", mode.name()); maps.setShuffleMode(mode); - info("Shuffle mode set to &ly'@'&lg.", arg[0]); + info("Shuffle mode set to '@'.", arg[0]); }catch(Exception e){ err("Invalid shuffle mode."); } @@ -638,7 +644,7 @@ public class ServerControl implements ApplicationListener{ Map res = maps.all().find(map -> map.name().equalsIgnoreCase(arg[0].replace('_', ' ')) || map.name().equalsIgnoreCase(arg[0])); if(res != null){ nextMapOverride = res; - Log.info("Next map set to &ly'@'.", res.name()); + Log.info("Next map set to '@'.", res.name()); }else{ Log.err("No map '@' found.", arg[0]); } @@ -694,9 +700,9 @@ public class ServerControl implements ApplicationListener{ if(bans.size == 0){ info("No ID-banned players have been found."); }else{ - info("&lyBanned players [ID]:"); + info("Banned players [ID]:"); for(PlayerInfo info : bans){ - info(" &ly @ / Last known name: '@'", info.id, info.lastName); + info(" @ / Last known name: '@'", info.id, info.lastName); } } @@ -705,13 +711,13 @@ public class ServerControl implements ApplicationListener{ if(ipbans.size == 0){ info("No IP-banned players have been found."); }else{ - info("&lmBanned players [IP]:"); + info("Banned players [IP]:"); for(String string : ipbans){ PlayerInfo info = netServer.admins.findByIP(string); if(info != null){ - info(" &lm '@' / Last known name: '@' / ID: '@'", string, info.lastName, info.id); + info(" '@' / Last known name: '@' / ID: '@'", string, info.lastName, info.id); }else{ - info(" &lm '@' (No known name or info)", string); + info(" '@' (No known name or info)", string); } } } @@ -765,7 +771,7 @@ public class ServerControl implements ApplicationListener{ netServer.admins.unAdminPlayer(target.id); } if(playert != null) playert.admin = add; - info("Changed admin status of player: &ly@", target.lastName); + info("Changed admin status of player: @", target.lastName); }else{ err("Nobody with that name or ID could be found. If adding an admin by name, make sure they're online; otherwise, use their UUID."); } @@ -777,7 +783,7 @@ public class ServerControl implements ApplicationListener{ if(admins.size == 0){ info("No admins have been found."); }else{ - info("&lyAdmins:"); + info("Admins:"); for(PlayerInfo info : admins){ info(" &lm @ / ID: '@' / IP: '@'", info.lastName, info.id, info.lastIP); } @@ -788,10 +794,10 @@ public class ServerControl implements ApplicationListener{ if(Groups.player.size() == 0){ info("No players are currently in the server."); }else{ - info("&lyPlayers: @", Groups.player.size()); + info("Players: @", Groups.player.size()); for(Player user : Groups.player){ PlayerInfo userInfo = user.getInfo(); - info(" &lm @ / ID: '@' / IP: '@' / Admin: '@'", userInfo.lastName, userInfo.id, userInfo.lastIP, userInfo.admin); + info(" &lm @ / ID: @ / IP: @ / Admin: @", userInfo.lastName, userInfo.id, userInfo.lastIP, userInfo.admin); } } }); @@ -849,7 +855,7 @@ public class ServerControl implements ApplicationListener{ info("Save files: "); for(Fi file : saveDirectory.list()){ if(file.extension().equals(saveExtension)){ - info("| &ly@", file.nameWithoutExtension()); + info("| @", file.nameWithoutExtension()); } } }); @@ -860,7 +866,7 @@ public class ServerControl implements ApplicationListener{ return; } - info("&lyCore destroyed."); + info("Core destroyed."); inExtraRound = false; Events.fire(new GameOverEvent(Team.crux)); }); @@ -870,16 +876,16 @@ public class ServerControl implements ApplicationListener{ ObjectSet infos = netServer.admins.findByName(arg[0]); if(infos.size > 0){ - info("&lgPlayers found: @", infos.size); + info("Players found: @", infos.size); int i = 0; for(PlayerInfo info : infos){ - info("&lc[@] Trace info for player '@' / UUID @", i++, info.lastName, info.id); - info(" &lyall names used: @", info.names); - info(" &lyIP: @", info.lastIP); - info(" &lyall IPs used: @", info.ips); - info(" &lytimes joined: @", info.timesJoined); - info(" &lytimes kicked: @", info.timesKicked); + info("[@] Trace info for player '@' / UUID @", i++, info.lastName, info.id); + info(" all names used: @", info.names); + info(" IP: @", info.lastIP); + info(" all IPs used: @", info.ips); + info(" times joined: @", info.timesJoined); + info(" times kicked: @", info.timesKicked); } }else{ info("Nobody with that name could be found."); @@ -891,11 +897,11 @@ public class ServerControl implements ApplicationListener{ ObjectSet infos = netServer.admins.searchNames(arg[0]); if(infos.size > 0){ - info("&lgPlayers found: @", infos.size); + info("Players found: @", infos.size); int i = 0; for(PlayerInfo info : infos){ - info("- &lc[@] &ly'@'&lc / &lm@", i++, info.lastName, info.id); + info("- [@] '@' / @", i++, info.lastName, info.id); } }else{ info("Nobody with that name could be found."); @@ -906,10 +912,10 @@ public class ServerControl implements ApplicationListener{ int pre = (int)(Core.app.getJavaHeap() / 1024 / 1024); System.gc(); int post = (int)(Core.app.getJavaHeap() / 1024 / 1024); - info("&ly@&lg MB collected. Memory usage now at &ly@&lg MB.", pre - post, post); + info("@ MB collected. Memory usage now at @ MB.", pre - post, post); }); - handler.register("yes", "Run the above \"did you mean\" suggestion.", arg -> { + handler.register("yes", "Run the last suggested incorrect command.", arg -> { if(yes == null){ err("There is nothing to say yes to."); }else{ @@ -1036,7 +1042,7 @@ public class ServerControl implements ApplicationListener{ serverSocket.bind(new InetSocketAddress(Config.socketInputAddress.string(), Config.socketInputPort.num())); while(true){ Socket client = serverSocket.accept(); - info("&lmReceived command socket connection: &lb@", serverSocket.getLocalSocketAddress()); + info("&lkReceived command socket connection: &fi@", serverSocket.getLocalSocketAddress()); BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream())); socketOutput = new PrintWriter(client.getOutputStream(), true); String line; @@ -1044,7 +1050,7 @@ public class ServerControl implements ApplicationListener{ String result = line; Core.app.post(() -> handleCommandString(result)); } - info("&lmLost command socket connection: &lb@", serverSocket.getLocalSocketAddress()); + info("&lkLost command socket connection: &fi@", serverSocket.getLocalSocketAddress()); socketOutput = null; } }catch(BindException b){ diff --git a/server/src/mindustry/server/ServerLauncher.java b/server/src/mindustry/server/ServerLauncher.java index 4c8a2bb8e6..ad274954ea 100644 --- a/server/src/mindustry/server/ServerLauncher.java +++ b/server/src/mindustry/server/ServerLauncher.java @@ -29,10 +29,10 @@ public class ServerLauncher implements ApplicationListener{ Vars.platform = new Platform(){}; Vars.net = new Net(platform.getNet()); - Log.setLogger((level, text) -> { - String result = "[" + dateTime.format(LocalDateTime.now()) + "] " + format(tags[level.ordinal()] + " " + text + "&fr"); - System.out.println(result); - }); + logger = (level1, text) -> { + String result = "[" + dateTime.format(LocalDateTime.now()) + "] " + format(tags[level1.ordinal()] + " " + text + "&fr"); + System.out.println(result); + }; new HeadlessApplication(new ServerLauncher(), null, throwable -> CrashSender.send(throwable, f -> {})); }catch(Throwable t){ CrashSender.send(t, f -> {}); diff --git a/tests/src/test/java/ApplicationTests.java b/tests/src/test/java/ApplicationTests.java index 01cf659df2..67d30e5ff9 100644 --- a/tests/src/test/java/ApplicationTests.java +++ b/tests/src/test/java/ApplicationTests.java @@ -36,7 +36,7 @@ public class ApplicationTests{ try{ boolean[] begins = {false}; Throwable[] exceptionThrown = {null}; - Log.setUseColors(false); + Log.useColors = false; ApplicationCore core = new ApplicationCore(){ @Override diff --git a/tests/src/test/java/power/PowerTestFixture.java b/tests/src/test/java/power/PowerTestFixture.java index 7bd7e821b2..ceed02b530 100644 --- a/tests/src/test/java/power/PowerTestFixture.java +++ b/tests/src/test/java/power/PowerTestFixture.java @@ -37,7 +37,7 @@ public class PowerTestFixture{ Vars.state = new GameState(); Vars.tree = new FileTree(); content.createBaseContent(); - Log.setUseColors(false); + Log.useColors = false; Time.setDeltaProvider(() -> 0.5f); } diff --git a/tools/src/mindustry/tools/ImagePacker.java b/tools/src/mindustry/tools/ImagePacker.java index 2533f99af9..1142de8a26 100644 --- a/tools/src/mindustry/tools/ImagePacker.java +++ b/tools/src/mindustry/tools/ImagePacker.java @@ -28,10 +28,10 @@ public class ImagePacker{ Vars.headless = true; ArcNativesLoader.load(); - Log.setLogger(new NoopLogHandler()); + Log.logger = new NoopLogHandler(); Vars.content = new ContentLoader(); Vars.content.createBaseContent(); - Log.setLogger(new DefaultLogHandler()); + Log.logger = new DefaultLogHandler(); Fi.get("../../../assets-raw/sprites_out").walk(path -> { if(!path.extEquals("png")) return;