Skip to content

Commit

Permalink
Update ServerControl.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkness6030 authored Aug 14, 2023
1 parent ad47810 commit 3fcf938
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions server/src/mindustry/server/ServerControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import arc.util.Timer.*;
import arc.util.serialization.*;
import arc.util.serialization.JsonValue.*;
import mindustry.Vars;
import mindustry.core.GameState.*;
import mindustry.core.*;
import mindustry.game.EventType.*;
Expand Down Expand Up @@ -62,12 +63,10 @@ public class ServerControl implements ApplicationListener{
/** Whether the server is currently waiting for the next map to be loaded. */
public boolean inGameOverWait;

/** The current timer for loading the next map. */
public Task lastTask;

/** The last gamemode loaded on this server. */
public Gamemode lastMode;

private Task lastTask;
private Thread socketThread;
private ServerSocket serverSocket;
private PrintWriter socketOutput;
Expand Down Expand Up @@ -207,8 +206,9 @@ protected void setup(String[] args){
}

Events.on(GameOverEvent.class, event -> {
if(!inGameOverWait && gameOverListener != null)
if(!inGameOverWait && gameOverListener != null){
gameOverListener.get(event);
}
});

//reset autosave on world load
Expand Down Expand Up @@ -287,7 +287,7 @@ protected void setup(String[] args){
toggleSocket(Config.socketInput.bool());

Events.on(ServerLoadEvent.class, e -> {
if (serverInput != null) {
if(serverInput != null){
Thread thread = new Thread(serverInput, "Server Controls");
thread.setDaemon(true);
thread.start();
Expand Down Expand Up @@ -400,7 +400,7 @@ protected void registerCommands(){
autoPaused = true;
}
}catch(MapException e){
err(e.map.plainName() + ": " + e.getMessage());
err("@: @", e.map.plainName(), e.getMessage());
}
});

Expand Down Expand Up @@ -1056,15 +1056,29 @@ public void handleCommandString(String line){
}
}


/**
* @deprecated
* Use {@link Maps#setNextMapOverride(Map)} instead.
*/
@Deprecated
public void setNextMap(Map map){
maps.setNextMapOverride(map);
}

/**
* Resets the world state, starts a new game.
* @param run What task to run to load a new world.
*/
public void play(Runnable run){
play(true, run);
}

/**
* Resets the world state, starts a new game.
* @param wait Whether to wait for {@link Config#roundExtraTime} seconds before starting a new game.
* @param run What task to run to load a new world.
*/
public void play(boolean wait, Runnable run){
inGameOverWait = true;
Runnable r = () -> {
Expand All @@ -1088,7 +1102,7 @@ public void run(){
try{
r.run();
}catch(MapException e){
err(e.map.plainName() + ": " + e.getMessage());
err("@: @", e.map.plainName(), e.getMessage());
net.closeServer();
}
}
Expand Down

0 comments on commit 3fcf938

Please sign in to comment.