mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-19 09:02:54 -04:00
Added shutdown command, added character limit
This commit is contained in:
@@ -35,6 +35,8 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.mina.core.service.IoHandler;
|
||||
|
||||
import protocol.swg.ChatSystemMessage;
|
||||
import net.engio.mbassy.bus.config.BusConfiguration;
|
||||
import resources.common.RadialOptions;
|
||||
import resources.common.ThreadMonitor;
|
||||
@@ -108,6 +110,7 @@ public class NGECore {
|
||||
|
||||
private Config config = null;
|
||||
|
||||
private volatile boolean isShuttingDown = false;
|
||||
|
||||
private ConcurrentHashMap<Integer, Client> clients = new ConcurrentHashMap<Integer, Client>();
|
||||
|
||||
@@ -503,5 +506,39 @@ public class NGECore {
|
||||
return eventBusConfig;
|
||||
}
|
||||
|
||||
public void initiateShutdown() {
|
||||
if(isShuttingDown)
|
||||
return;
|
||||
try {
|
||||
|
||||
for(int minutes = 15; minutes > 1; minutes--) {
|
||||
simulationService.notifyAllClients(new ChatSystemMessage("The server will be shutting down soon. Please find a safe place to logout. (" + minutes + " minutes left)", (byte) 0 ).serialize());
|
||||
Thread.sleep(60000);
|
||||
}
|
||||
setGalaxyStatus(3);
|
||||
simulationService.notifyAllClients(new ChatSystemMessage("The server will be shutting down soon. Please find a safe place to logout. (" + 1 + " minutes left)", (byte) 0 ).serialize());
|
||||
Thread.sleep(30000);
|
||||
simulationService.notifyAllClients(new ChatSystemMessage("You will be disconnected in 30 seconds so the server can perform a final save before shutting down. Please find a safe place to logout now.", (byte) 0 ).serialize());
|
||||
Thread.sleep(20000);
|
||||
simulationService.notifyAllClients(new ChatSystemMessage("You will be disconnected in 10 seconds so the server can perform a final save before shutting down. Please find a safe place to logout now.", (byte) 0 ).serialize());
|
||||
Thread.sleep(10000);
|
||||
simulationService.notifyAllClients(new ChatSystemMessage("You will now be disconnected so the server can perform a final save before shutting down.", (byte) 0 ).serialize());
|
||||
|
||||
synchronized(getActiveConnectionsMap()) {
|
||||
for(Client client : getActiveConnectionsMap().values()) {
|
||||
client.getSession().close(true);
|
||||
}
|
||||
}
|
||||
|
||||
System.exit(0);
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user