Added openServer method

This commit is contained in:
Anuken
2019-12-28 22:18:16 -05:00
parent 8c941c7165
commit df4a0dd5e4
2 changed files with 21 additions and 17 deletions

View File

@ -251,7 +251,7 @@ public class ServerControl implements ApplicationListener{
info("Map loaded.");
host();
netServer.openServer();
}catch(MapException e){
Log.err(e.map.name() + ": " + e.getMessage());
}
@ -711,8 +711,8 @@ public class ServerControl implements ApplicationListener{
SaveIO.load(file);
state.rules.zone = null;
info("Save loaded.");
host();
state.set(State.playing);
netServer.openServer();
}catch(Throwable t){
err("Failed to load save. Outdated or corrupt file.");
}
@ -869,19 +869,6 @@ public class ServerControl implements ApplicationListener{
}
}
private void host(){
try{
net.host(Config.port.num());
info("&lcOpened a server on port {0}.", Config.port.num());
}catch(BindException e){
Log.err("Unable to host: Port already in use! Make sure no other servers are running on the same port in your network.");
state.set(State.menu);
}catch(IOException e){
err(e);
state.set(State.menu);
}
}
private void logToFile(String text){
if(currentLogFile != null && currentLogFile.length() > maxLogLength){
String date = DateTimeFormatter.ofPattern("MM-dd-yyyy | HH:mm:ss").format(LocalDateTime.now());