Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anuken
2023-09-09 18:39:43 -04:00
2 changed files with 30 additions and 27 deletions

View File

@@ -343,7 +343,7 @@ public class ServerControl implements ApplicationListener{
handler.register("stop", "Stop hosting the server.", arg -> { handler.register("stop", "Stop hosting the server.", arg -> {
net.closeServer(); net.closeServer();
if(lastTask != null) lastTask.cancel(); cancelPlayTask();
state.set(State.menu); state.set(State.menu);
info("Stopped server."); info("Stopped server.");
}); });
@@ -354,7 +354,7 @@ public class ServerControl implements ApplicationListener{
return; return;
} }
if(lastTask != null) lastTask.cancel(); cancelPlayTask();
Gamemode preset = Gamemode.survival; Gamemode preset = Gamemode.survival;
@@ -1063,6 +1063,13 @@ public class ServerControl implements ApplicationListener{
maps.setNextMapOverride(map); maps.setNextMapOverride(map);
} }
/**
* Cancels the world load timer task, if it is scheduled. Can be useful for stopping a server or hosting a new game.
*/
public void cancelPlayTask(){
if(lastTask != null) lastTask.cancel();
}
/** /**
* Resets the world state, starts a new game. * Resets the world state, starts a new game.
* @param run What task to run to load a new world. * @param run What task to run to load a new world.
@@ -1078,38 +1085,30 @@ public class ServerControl implements ApplicationListener{
*/ */
public void play(boolean wait, Runnable run){ public void play(boolean wait, Runnable run){
inGameOverWait = true; inGameOverWait = true;
if(lastTask != null) lastTask.cancel(); cancelPlayTask();
Runnable r = () -> { Runnable reload = () -> {
WorldReloader reloader = new WorldReloader(); try{
WorldReloader reloader = new WorldReloader();
reloader.begin();
reloader.begin(); run.run();
run.run(); state.rules = state.map.applyRules(lastMode);
logic.play();
state.rules = state.map.applyRules(lastMode); reloader.end();
logic.play(); inGameOverWait = false;
}catch(MapException e){
reloader.end(); err("@: @", e.map.plainName(), e.getMessage());
inGameOverWait = false; net.closeServer();
}
}; };
if(wait){ if(wait){
lastTask = new Task(){ lastTask = Timer.schedule(reload, Config.roundExtraTime.num());
@Override
public void run(){
try{
r.run();
}catch(MapException e){
err("@: @", e.map.plainName(), e.getMessage());
net.closeServer();
}
}
};
Timer.schedule(lastTask, Config.roundExtraTime.num());
}else{ }else{
r.run(); reload.run();
} }
} }

View File

@@ -3,6 +3,10 @@
"name": "Tamazia", "name": "Tamazia",
"address": ["213.165.76.25:6567", "213.165.76.25:30104"] "address": ["213.165.76.25:6567", "213.165.76.25:30104"]
}, },
{
"name": "Crux's Federation",
"address": ["de-free-01.hosts.optikservers.com:32538", "de-free-01.hosts.optikservers.com:31421", "fsn1.bbn.one:37019"]
},
{ {
"name": "RCM", "name": "RCM",
"address": ["rcrms.ru:6567"] "address": ["rcrms.ru:6567"]
@@ -222,7 +226,7 @@
}, },
{ {
"name": "Alex Multiverse", "name": "Alex Multiverse",
"address": ["alexmindustryv7.servegame.com:25588", "alexmindustryv7.servegame.com:41962", "alexmindustrypvp.ddns.net:6767", "alexmindustrypvp.ddns.net:6768"] "address": ["alexmindustryv7.servegame.com:25588", "173.255.208.38:41962", "alexmindustrypvp.ddns.net:6767", "172.104.188.197:6768"]
}, },
{ {
"name": "Open PVP", "name": "Open PVP",