Improve server host command (#967)

* Improve server host command

* remove spaces
This commit is contained in:
Maximilian 2019-11-02 01:26:29 +01:00 committed by Anuken
parent 59401ab5f5
commit 6148a931d3

View File

@ -211,19 +211,25 @@ public class ServerControl implements ApplicationListener{
info("Stopped server.");
});
handler.register("host", "<mapname> [mode]", "Open the server with a specific map.", arg -> {
handler.register("host", "[mapname] [mode]", "Open the server. Will default to survival and a random map if not specified.", arg -> {
if(state.is(State.playing)){
err("Already hosting. Type 'stop' to stop hosting first.");
return;
}
if(lastTask != null) lastTask.cancel();
Map result;
if(arg.length > 0){
result = maps.all().find(map -> map.name().equalsIgnoreCase(arg[0].replace('_', ' ')) || map.name().equalsIgnoreCase(arg[0]));
Map 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'{0}'&lr found.", arg[0]);
return;
if(result == null){
err("No map with name &y'{0}'&lr found.", arg[0]);
return;
}
}else{
Array<Map> maps = Vars.maps.customMaps().size == 0 ? Vars.maps.defaultMaps() : Vars.maps.customMaps();
result = maps.random();
}
Gamemode preset = Gamemode.survival;