From 7543d92473e79d3957740cc07523d05adfe186c1 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 28 Dec 2019 18:05:45 -0500 Subject: [PATCH] Added startup commands to server --- core/src/mindustry/net/Administration.java | 1 + server/src/mindustry/server/ServerControl.java | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/src/mindustry/net/Administration.java b/core/src/mindustry/net/Administration.java index 268e8d089f..57a728a020 100644 --- a/core/src/mindustry/net/Administration.java +++ b/core/src/mindustry/net/Administration.java @@ -320,6 +320,7 @@ public class Administration{ name("The server name as displayed on clients.", "Server", "servername"), port("The port to host on.", Vars.port), autoUpdate("Whether to auto-update and exit when a new bleeding-edge update arrives.", false), + 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), diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index f1dbb59803..619004f79f 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -90,11 +90,17 @@ public class ServerControl implements ApplicationListener{ registerCommands(); Core.app.post(() -> { - String[] commands = {}; + Array commands = new Array<>(); if(args.length > 0){ - commands = Strings.join(" ", args).split(","); - info("&lmFound {0} command-line arguments to parse.", commands.length); + commands.addAll(Strings.join(" ", args).split(",")); + info("&lmFound {0} command-line arguments to parse.", commands.size); + } + + if(!Config.startCommands.string().isEmpty()){ + String[] startup = Strings.join(" ", Config.startCommands.string()).split(","); + info("&lmFound {0} startup commands.", startup.length); + commands.addAll(startup); } for(String s : commands){ @@ -102,7 +108,6 @@ public class ServerControl implements ApplicationListener{ if(response.type != ResponseType.valid){ err("Invalid command argument sent: '{0}': {1}", s, response.type.name()); err("Argument usage: &lc , "); - System.exit(1); } } }); @@ -443,7 +448,7 @@ public class ServerControl implements ApplicationListener{ } }); - handler.register("config", "[name] [value]", "Configure server settings.", arg -> { + handler.register("config", "[name] [value...]", "Configure server settings.", arg -> { if(arg.length == 0){ info("&lyAll config values:"); for(Config c : Config.all){