Improve server host command (#967)
* Improve server host command * remove spaces
This commit is contained in:
@@ -211,7 +211,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
info("Stopped server.");
|
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)){
|
if(state.is(State.playing)){
|
||||||
err("Already hosting. Type 'stop' to stop hosting first.");
|
err("Already hosting. Type 'stop' to stop hosting first.");
|
||||||
return;
|
return;
|
||||||
@@ -219,11 +219,17 @@ public class ServerControl implements ApplicationListener{
|
|||||||
|
|
||||||
if(lastTask != null) lastTask.cancel();
|
if(lastTask != null) lastTask.cancel();
|
||||||
|
|
||||||
Map result = maps.all().find(map -> map.name().equalsIgnoreCase(arg[0].replace('_', ' ')) || map.name().equalsIgnoreCase(arg[0]));
|
Map result;
|
||||||
|
if(arg.length > 0){
|
||||||
|
result = maps.all().find(map -> map.name().equalsIgnoreCase(arg[0].replace('_', ' ')) || map.name().equalsIgnoreCase(arg[0]));
|
||||||
|
|
||||||
if(result == null){
|
if(result == null){
|
||||||
err("No map with name &y'{0}'&lr found.", arg[0]);
|
err("No map with name &y'{0}'&lr found.", arg[0]);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Array<Map> maps = Vars.maps.customMaps().size == 0 ? Vars.maps.defaultMaps() : Vars.maps.customMaps();
|
||||||
|
result = maps.random();
|
||||||
}
|
}
|
||||||
|
|
||||||
Gamemode preset = Gamemode.survival;
|
Gamemode preset = Gamemode.survival;
|
||||||
|
|||||||
Reference in New Issue
Block a user