From dff394c077c5dcc78d665a3dda5a606a313c5bc3 Mon Sep 17 00:00:00 2001 From: Zing Date: Thu, 7 Aug 2014 23:49:20 -0700 Subject: [PATCH] Configured /server admin command for server related needs. Added initiateStop to NGECore. --- scripts/commands/server.py | 14 +++++++++----- src/main/NGECore.java | 20 +++++++++++++++++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/scripts/commands/server.py b/scripts/commands/server.py index 09765edc..fc7b1f5c 100644 --- a/scripts/commands/server.py +++ b/scripts/commands/server.py @@ -28,14 +28,18 @@ def run(core, actor, target, commandString): if command == 'lockServer': core.setGalaxyStatus(GalaxyStatus.Locked) + actor.sendSystemMessage('GM: Command completed successfully, Server is now in Locked Status', 0) if command == 'unlockServer': core.setGalaxyStatus(GalaxyStatus.Online) - if command == 'info': - actor.sendSystemMessage(str(core.getActiveZoneClients()) + ' online characters.', 0) + actor.sendSystemMessage('GM: Command completed successfully, Server is now in Online Status', 0) + #if command == 'restart': //This command currently causes an error at NGEcore.java like 593 whole attempting to close databaseConnection2 + #core.restart() + #actor.sendSystemMessage('GM: Command completed successfully, Server restart initiated', 0) if command == 'shutdown': core.initiateShutdown() - if command == 'getheight': - actor.sendSystemMessage(str(core.terrainService.getHeight(actor.getPlanetId(), actor.getWorldPosition().x, actor.getWorldPosition().z)), 0) - + actor.sendSystemMessage('GM: Command completed successfully, Server shutdown initiated', 0) + if command == 'stop': + core.initiateStop() + actor.sendSystemMessage('GM: Command completed successfully, Emergency server shutdown initiated', 0) return diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 2bd40112..8e47a007 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -796,8 +796,26 @@ public class NGECore { } catch (InterruptedException e) { e.printStackTrace(); } + } - + public void initiateStop() { + if(isShuttingDown) + return; + try { + chatService.broadcastGalaxy("You will now be disconnected so the server can perform a final save before shutting down."); + Thread.sleep(10000); + synchronized(getActiveConnectionsMap()) { + for(Client client : getActiveConnectionsMap().values()) { + client.getSession().close(true); + connectionService.disconnect(client); + } + } + + System.exit(0); + + } catch (InterruptedException e) { + e.printStackTrace(); + } }