From 495250850e6474424e90ad16d468c11f458d3140 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 17 Apr 2022 10:21:44 -0400 Subject: [PATCH] Custom Config support / Corrupt crux --- core/assets-raw/sprites/teams/team-crux.png | Bin 479 -> 511 bytes core/src/mindustry/content/SectorPresets.java | 2 +- core/src/mindustry/net/Administration.java | 86 ++++++++++-------- core/src/mindustry/net/NetworkIO.java | 2 +- .../mindustry/type/unit/MissileUnitType.java | 1 + .../src/mindustry/server/ServerControl.java | 13 +-- 6 files changed, 57 insertions(+), 47 deletions(-) diff --git a/core/assets-raw/sprites/teams/team-crux.png b/core/assets-raw/sprites/teams/team-crux.png index 4fb6783a5b49b3fdced9de4860670f644459bb28..bd945aba7b475fcca42700608ad2e1a90bfd4825 100644 GIT binary patch delta 472 zcmcc5{GWM(Vf{`|7srr{#<#a_7d0F3uv{qp|9}4F=@n|1H4{8{Pr6eT->k1LA_2uvC!ngfjy5^78{1sX?R)5TWSnWjLv1)zD{4n)g`lH|n)BMsOvaepWTBGfy zgz}wy%@|8<_m7(vu8V75Jn_Kp#f*$K>?RIv@0-{j9qm=@HB07R zFpcY+Zr8s)=CtUKsa5lT{i`^(`=Mk;Lg9+?gPSijJd|30%=ltMVNv(G`|o~d8A%nK zd3DoVpUdPy%(+b;v`hpdj$f^)SC!(pcVNYbERzom=U+6eI=j3|?tF!s9XGEI-&dX* zH7NtT{>@VVBK^&z1afU76+|-}b}%2_Wgouv>MzrcpZKTcnYn#<6{vbY_3Hy;y`^jI z{>@B0BY(T*o$29OCfk1;$Zy-(d-dPsbCTcg#lG&ZNEg|?b&~W9!(%6E3O=^{<2o5w zuJCYi+=yM=CQtDH9MF}l{GZf<7xx>Y$fEdAl;3k-#p-G_`WGE~Zbf3*4H k(#pNTcl#$#wx5?D=n#;}G<8!50|Nttr>mdKI;Vst0Esu}dH?_b delta 440 zcmey*e4lxOVf{=`7srr{#<#N%PC9JB;XL*4|N3`vr`cz&;_NLw8w>k5@xBRl*{Xo}q)9e|{aq|}JDqj6? z>A~`TZPh(G2CsX<4th6j>g{BjCl~Pa*o_ZY60*2YwJc{X`k5zYQ?J^w`)0y{eD)Ww zHk3WwE>^y6>H)c$%0%;$62q~z@Cc~><*Tsy0Kh4+5Z zoYs9;57gYb6Sg4A?J&3H`>g$UulhHqJ1}=2zp42_CqtpIul%s_!p0?yFPqYxnOUDd zYYTT^c0K*7Dcq4+Ixd!XeG6N?*=!NfJyKE;1$jCa&-&YXW=)&d#(j^KS7pyGse7Ef zDj;cTDS_U3MhdbQ8VZ;W8yRkzyg00nJ#OaX8;72-t=wg>MB~CoGuiL5w|+I;Wl(fG zc+U57o#BJnhu_Mki)w^0zK|%`68n#H!nT!s)(IV^`Qc|jK5Lrq6k diff --git a/core/src/mindustry/content/SectorPresets.java b/core/src/mindustry/content/SectorPresets.java index fff9d98032..d7bd3f7dae 100644 --- a/core/src/mindustry/content/SectorPresets.java +++ b/core/src/mindustry/content/SectorPresets.java @@ -133,7 +133,7 @@ public class SectorPresets{ new ShapeTextMarker("To [accent]power[] the plasma bore, research and place a [accent]beam node[].\nConnect the turbine condenser to the plasma bore.", 254f * 8f, 267f * 8f) ), new CoreItemObjective(Items.beryllium, 5).withMarkers( - new TextMarker("Once the plasma bore is powered, the next step is to route the resources to the core.\nUnlock and place [accent]ducts[] to move the mined resources to the core", 236f * 8f, 278f * 8f) + new TextMarker("Once the plasma bore is powered, the next step is to route the resources to the core.\nResearch and place [accent]ducts[] to move the mined resources to the core.", 236f * 8f, 278f * 8f) ), new CoreItemObjective(Items.beryllium, 200).withMarkers( new TextMarker("Expand your mining operation!\nPlace more plasma bores and use beam nodes and ducts to support them.", 253f * 8f, 282f * 8f), diff --git a/core/src/mindustry/net/Administration.java b/core/src/mindustry/net/Administration.java index 09953843ec..7982dce937 100644 --- a/core/src/mindustry/net/Administration.java +++ b/core/src/mindustry/net/Administration.java @@ -453,59 +453,67 @@ public class Administration{ subnetBans = Core.settings.getJson("banned-subnets", Seq.class, Seq::new); } - /** Server configuration definition. Each config value can be a string, boolean or number. */ - public enum Config{ - name("The server name as displayed on clients.", "Server", "servername"), - desc("The server description, displayed under the name. Max 100 characters.", "off"), - port("The port to host on.", Vars.port), - autoUpdate("Whether to auto-update and exit when a new bleeding-edge update arrives.", false), - showConnectMessages("Whether to display connect/disconnect messages.", true), - enableVotekick("Whether votekick is enabled.", true), - startCommands("Commands run at startup. This should be a comma-separated list.", ""), - crashReport("Whether to send crash reports.", false, "crashreport"), - logging("Whether to log everything to files.", true), - strict("Whether strict mode is on - corrects positions and prevents duplicate UUIDs.", true), - antiSpam("Whether spammers are automatically kicked and rate-limited.", headless), - interactRateWindow("Block interaction rate limit window, in seconds.", 6), - interactRateLimit("Block interaction rate limit.", 25), - interactRateKick("How many times a player must interact inside the window to get kicked.", 60), - messageRateLimit("Message rate limit in seconds. 0 to disable.", 0), - messageSpamKick("How many times a player must send a message before the cooldown to get kicked. 0 to disable.", 3), - socketInput("Allows a local application to control this server through a local TCP socket.", false, "socket", () -> Events.fire(Trigger.socketConfigChanged)), - socketInputPort("The port for socket input.", 6859, () -> Events.fire(Trigger.socketConfigChanged)), - socketInputAddress("The bind address for socket input.", "localhost", () -> Events.fire(Trigger.socketConfigChanged)), - allowCustomClients("Whether custom clients are allowed to connect.", !headless, "allow-custom"), - whitelist("Whether the whitelist is used.", false), - motd("The message displayed to people on connection.", "off"), - 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.level = debug() ? LogLevel.debug : LogLevel.info), - snapshotInterval("Client entity snapshot interval in ms.", 200); + /** + * Server configuration definition. Each config value can be a string, boolean or number. + * Creating a new Config instance implicitly adds it to the list of server configs. This can be used for custom plugin configuration. + * */ + public static class Config{ + public static final Seq all = new Seq<>(); - public static final Config[] all = values(); + public static final Config + + serverName = new Config("name", "The server name as displayed on clients.", "Server", "servername"), + desc = new Config("desc", "The server description, displayed under the name. Max 100 characters.", "off"), + port = new Config("port", "The port to host on.", Vars.port), + autoUpdate = new Config("autoUpdate", "Whether to auto-update and exit when a new bleeding-edge update arrives.", false), + showConnectMessages = new Config("showConnectMessages", "Whether to display connect/disconnect messages.", true), + enableVotekick = new Config("enableVotekick", "Whether votekick is enabled.", true), + startCommands = new Config("startCommands", "Commands run at startup. This should be a comma-separated list.", ""), + logging = new Config("logging", "Whether to log everything to files.", true), + strict = new Config("strict", "Whether strict mode is on - corrects positions and prevents duplicate UUIDs.", true), + antiSpam = new Config("antiSpam", "Whether spammers are automatically kicked and rate-limited.", headless), + interactRateWindow = new Config("interactRateWindow", "Block interaction rate limit window, in seconds.", 6), + interactRateLimit = new Config("interactRateLimit", "Block interaction rate limit.", 25), + interactRateKick = new Config("interactRateKick", "How many times a player must interact inside the window to get kicked.", 60), + messageRateLimit = new Config("messageRateLimit", "Message rate limit in seconds. 0 to disable.", 0), + messageSpamKick = new Config("messageSpamKick", "How many times a player must send a message before the cooldown to get kicked. 0 to disable.", 3), + socketInput = new Config("socketInput", "Allows a local application to control this server through a local TCP socket.", false, "socket", () -> Events.fire(Trigger.socketConfigChanged)), + socketInputPort = new Config("socketInputPort", "The port for socket input.", 6859, () -> Events.fire(Trigger.socketConfigChanged)), + socketInputAddress = new Config("socketInputAddress", "The bind address for socket input.", "localhost", () -> Events.fire(Trigger.socketConfigChanged)), + allowCustomClients = new Config("allowCustomClients", "Whether custom clients are allowed to connect.", !headless, "allow-custom"), + whitelist = new Config("whitelist", "Whether the whitelist is used.", false), + motd = new Config("motd", "The message displayed to people on connection.", "off"), + autosave = new Config("autosave", "Whether the periodically save the map when playing.", false), + autosaveAmount = new Config("autosaveAmount", "The maximum amount of autosaves. Older ones get replaced.", 10), + autosaveSpacing = new Config("autosaveSpacing", "Spacing between autosaves in seconds.", 60 * 5), + debug = new Config("debug", "Enable debug logging", false, () -> Log.level = debug() ? LogLevel.debug : LogLevel.info), + snapshotInterval = new Config("snapshotInterval", "Client entity snapshot interval in ms.", 200); public final Object defaultValue; - public final String key, description; + public final String name, key, description; + final Runnable changed; - Config(String description, Object def){ - this(description, def, null, null); + public Config(String name, String description, Object def){ + this(name, description, def, null, null); } - Config(String description, Object def, String key){ - this(description, def, key, null); + public Config(String name, String description, Object def, String key){ + this(name, description, def, key, null); } - Config(String description, Object def, Runnable changed){ - this(description, def, null, changed); + public Config(String name, String description, Object def, Runnable changed){ + this(name, description, def, null, changed); } - Config(String description, Object def, String key, Runnable changed){ + public Config(String name, String description, Object def, String key, Runnable changed){ + this.name = name; this.description = description; - this.key = key == null ? name() : key; + this.key = key == null ? name : key; this.defaultValue = def; this.changed = changed == null ? () -> {} : changed; + + all.add(this); } public boolean isNum(){ diff --git a/core/src/mindustry/net/NetworkIO.java b/core/src/mindustry/net/NetworkIO.java index 0b2b386b59..49979a439e 100644 --- a/core/src/mindustry/net/NetworkIO.java +++ b/core/src/mindustry/net/NetworkIO.java @@ -111,7 +111,7 @@ public class NetworkIO{ } public static ByteBuffer writeServerData(){ - String name = (headless ? Config.name.string() : player.name); + String name = (headless ? Config.serverName.string() : player.name); String description = headless && !Config.desc.string().equals("off") ? Config.desc.string() : ""; String map = state.map.name(); diff --git a/core/src/mindustry/type/unit/MissileUnitType.java b/core/src/mindustry/type/unit/MissileUnitType.java index 9427075890..2a490b7bdc 100644 --- a/core/src/mindustry/type/unit/MissileUnitType.java +++ b/core/src/mindustry/type/unit/MissileUnitType.java @@ -33,6 +33,7 @@ public class MissileUnitType extends UnitType{ range = 6f; targetPriority = -1f; outlineColor = Pal.darkOutline; + fogRadius = 2f; //TODO weapon configs, etc? } } diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index 7590f7a5e8..fe90922fd5 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -572,17 +572,18 @@ public class ServerControl implements ApplicationListener{ if(arg.length == 0){ info("All config values:"); for(Config c : Config.all){ - info("&lk| @: @", c.name(), "&lc&fi" + c.get()); + info("&lk| @: @", c.name, "&lc&fi" + c.get()); info("&lk| | &lw" + c.description); info("&lk|"); } return; } - try{ - Config c = Config.valueOf(arg[0]); + Config c = Config.all.find(conf -> conf.name.equalsIgnoreCase(arg[0])); + + if(c != null){ if(arg.length == 1){ - info("'@' is currently @.", c.name(), c.get()); + info("'@' is currently @.", c.name, c.get()); }else{ if(arg[1].equals("default")){ c.set(c.defaultValue); @@ -599,10 +600,10 @@ public class ServerControl implements ApplicationListener{ c.set(arg[1].replace("\\n", "\n")); } - info("@ set to @.", c.name(), c.get()); + info("@ set to @.", c.name, c.get()); Core.settings.forceSave(); } - }catch(IllegalArgumentException e){ + }else{ err("Unknown config: '@'. Run the command with no arguments to get a list of valid configs.", arg[0]); } });