Fixed #10652
This commit is contained in:
@@ -2,7 +2,7 @@ package mindustry.server;
|
|||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
import arc.func.Cons;
|
import arc.func.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.Timer;
|
import arc.util.Timer;
|
||||||
@@ -10,6 +10,7 @@ import arc.util.CommandHandler.*;
|
|||||||
import arc.util.Timer.*;
|
import arc.util.Timer.*;
|
||||||
import arc.util.serialization.*;
|
import arc.util.serialization.*;
|
||||||
import arc.util.serialization.JsonValue.*;
|
import arc.util.serialization.JsonValue.*;
|
||||||
|
import mindustry.*;
|
||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
@@ -254,6 +255,25 @@ public class ServerControl implements ApplicationListener{
|
|||||||
toggleSocket(Config.socketInput.bool());
|
toggleSocket(Config.socketInput.bool());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Events.on(ResetEvent.class, e -> {
|
||||||
|
autoPaused = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
Events.run(Trigger.update, () -> {
|
||||||
|
if(Config.autoPause.bool()){
|
||||||
|
if(Groups.player.isEmpty()){
|
||||||
|
autoPaused = true;
|
||||||
|
state.set(State.paused);
|
||||||
|
}else if(autoPaused){
|
||||||
|
autoPaused = false;
|
||||||
|
state.set(State.playing);
|
||||||
|
}
|
||||||
|
}else if(autoPaused && Vars.state.isPaused()){ //unpause when the config is disabled
|
||||||
|
state.set(State.playing);
|
||||||
|
autoPaused = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Events.on(PlayEvent.class, e -> {
|
Events.on(PlayEvent.class, e -> {
|
||||||
try{
|
try{
|
||||||
JsonValue value = JsonIO.json.fromJson(null, Core.settings.getString("globalrules"));
|
JsonValue value = JsonIO.json.fromJson(null, Core.settings.getString("globalrules"));
|
||||||
@@ -294,31 +314,6 @@ public class ServerControl implements ApplicationListener{
|
|||||||
|
|
||||||
info("Server loaded. Type @ for help.", "'help'");
|
info("Server loaded. Type @ for help.", "'help'");
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(SaveLoadEvent.class, e -> {
|
|
||||||
Core.app.post(() -> {
|
|
||||||
if(Config.autoPause.bool() && Groups.player.size() == 0){
|
|
||||||
state.set(State.paused);
|
|
||||||
autoPaused = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
Events.on(PlayerJoin.class, e -> {
|
|
||||||
if(state.isPaused() && autoPaused && Config.autoPause.bool()){
|
|
||||||
state.set(State.playing);
|
|
||||||
autoPaused = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Events.on(PlayerLeave.class, e -> {
|
|
||||||
// The player list length is compared with 1 and not 0 here,
|
|
||||||
// because when PlayerLeave gets fired, the player hasn't been removed from the player list yet
|
|
||||||
if(!state.isPaused() && Config.autoPause.bool() && Groups.player.size() == 1){
|
|
||||||
state.set(State.paused);
|
|
||||||
autoPaused = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerCommands(){
|
protected void registerCommands(){
|
||||||
@@ -402,11 +397,6 @@ public class ServerControl implements ApplicationListener{
|
|||||||
info("Map loaded.");
|
info("Map loaded.");
|
||||||
|
|
||||||
netServer.openServer();
|
netServer.openServer();
|
||||||
|
|
||||||
if(Config.autoPause.bool()){
|
|
||||||
state.set(State.paused);
|
|
||||||
autoPaused = true;
|
|
||||||
}
|
|
||||||
}catch(MapException e){
|
}catch(MapException e){
|
||||||
err("@: @", e.map.plainName(), e.getMessage());
|
err("@: @", e.map.plainName(), e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -1117,7 +1107,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
public void play(boolean wait, Runnable run){
|
public void play(boolean wait, Runnable run){
|
||||||
inGameOverWait = true;
|
inGameOverWait = true;
|
||||||
cancelPlayTask();
|
cancelPlayTask();
|
||||||
|
|
||||||
Runnable reload = () -> {
|
Runnable reload = () -> {
|
||||||
try{
|
try{
|
||||||
WorldReloader reloader = new WorldReloader();
|
WorldReloader reloader = new WorldReloader();
|
||||||
|
|||||||
Reference in New Issue
Block a user