Added debug command to save the game

This commit is contained in:
simon
2018-05-11 10:25:40 -04:00
parent e97ecbe380
commit 9c41c16079
6 changed files with 41 additions and 3 deletions

View File

@@ -42,5 +42,4 @@ public class HealObjCommandListener implements GameEventListener {
}
}
}
}

View File

@@ -0,0 +1,27 @@
package net.simon987.server.game.debug;
import net.simon987.server.GameServer;
import net.simon987.server.event.DebugCommandEvent;
import net.simon987.server.event.GameEvent;
import net.simon987.server.event.GameEventListener;
public class SaveGameCommandListener implements GameEventListener {
@Override
public Class getListenedEventType() {
return DebugCommandEvent.class;
}
@Override
public void handle(GameEvent event) {
DebugCommandEvent e = (DebugCommandEvent) event;
if (e.getName().equals("saveGame")) {
GameServer.INSTANCE.save();
e.reply("Saved the game");
}
}
}

View File

@@ -34,6 +34,8 @@ public class MessageDispatcher {
handler.handle(user, json);
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
//Socket is closed
}
}
} else {

View File

@@ -13,7 +13,7 @@ public class ObjectsRequestHandler implements MessageHandler {
@Override
public void handle(OnlineUser user, JSONObject json) throws IOException {
public void handle(OnlineUser user, JSONObject json) throws IllegalStateException, IOException {
if (json.get("t").equals("object")) {
// LogManager.LOGGER.fine("(WS) Objects request from " + user.getUser().getUsername());