Added startup commands to server
This commit is contained in:
@@ -320,6 +320,7 @@ public class Administration{
|
|||||||
name("The server name as displayed on clients.", "Server", "servername"),
|
name("The server name as displayed on clients.", "Server", "servername"),
|
||||||
port("The port to host on.", Vars.port),
|
port("The port to host on.", Vars.port),
|
||||||
autoUpdate("Whether to auto-update and exit when a new bleeding-edge update arrives.", false),
|
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"),
|
crashReport("Whether to send crash reports.", false, "crashreport"),
|
||||||
logging("Whether to log everything to files.", true),
|
logging("Whether to log everything to files.", true),
|
||||||
strict("Whether strict mode is on - corrects positions and prevents duplicate UUIDs.", true),
|
strict("Whether strict mode is on - corrects positions and prevents duplicate UUIDs.", true),
|
||||||
|
|||||||
@@ -90,11 +90,17 @@ public class ServerControl implements ApplicationListener{
|
|||||||
registerCommands();
|
registerCommands();
|
||||||
|
|
||||||
Core.app.post(() -> {
|
Core.app.post(() -> {
|
||||||
String[] commands = {};
|
Array<String> commands = new Array<>();
|
||||||
|
|
||||||
if(args.length > 0){
|
if(args.length > 0){
|
||||||
commands = Strings.join(" ", args).split(",");
|
commands.addAll(Strings.join(" ", args).split(","));
|
||||||
info("&lmFound {0} command-line arguments to parse.", commands.length);
|
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){
|
for(String s : commands){
|
||||||
@@ -102,7 +108,6 @@ public class ServerControl implements ApplicationListener{
|
|||||||
if(response.type != ResponseType.valid){
|
if(response.type != ResponseType.valid){
|
||||||
err("Invalid command argument sent: '{0}': {1}", s, response.type.name());
|
err("Invalid command argument sent: '{0}': {1}", s, response.type.name());
|
||||||
err("Argument usage: &lc<command-1> <command1-args...>,<command-2> <command-2-args2...>");
|
err("Argument usage: &lc<command-1> <command1-args...>,<command-2> <command-2-args2...>");
|
||||||
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){
|
if(arg.length == 0){
|
||||||
info("&lyAll config values:");
|
info("&lyAll config values:");
|
||||||
for(Config c : Config.all){
|
for(Config c : Config.all){
|
||||||
|
|||||||
Reference in New Issue
Block a user