Post: [PI]Restart Server Command
03-09-2015, 10:09 PM #1
Stunz
Former Staff
(adsbygoogle = window.adsbygoogle || []).push({});
This is a tutorial on how to add a restart command to your server so you do not have to close out the server and log everybody out. With this command your players will be temporarily disconnected(roughly 3 seconds) and then brought back into the game.

Difficulty: 1/10
Knowledge: Copy and paste.

First open up commands.java and under this code:
    import server.Config;
import server.Connection;
import server.Server;
import server.model.players.Client;
import server.model.players.PacketType;
import server.model.players.PlayerHandler;
import server.util.Misc;


Add this:
    import server.model.players.PlayerSave;
import server.model.players.Player;


Now still in commands.java add this code under your other player commands:
    if(playerCommand.startsWith("restart") && c.playerName.equalsIgnoreCase("YOURNAMEHERE")) {
for(Player p : PlayerHandler.players) {
if(p == null)
continue;
PlayerSave.saveGame((Client)p);
}
System.exit(0);
}


Make sure to add your own name where it says "YOURNAMEHERE".

Now save and close out of commands.java then COMPILE.

Now go to your Run.bat or Runserver.bat file.(what you use to run your server) right click on Run.bat and click edit.

Now, where it says something like "java -Xmx1000m -cp bin;deps/poi.jar;deps/mysql.jar;deps/mina.jar;deps/slf4j.jar;deps/slf4j-nop.jar;deps/jython.jar;log4j-1.2.15.jar; server.Server", it may not be exactly like this, but copy that and save it somewhere you will need it. This is your personal server's run stuff.

Now replace everything in your Run.bat or Runserver.bat with this code:

    @echo off
title Project Insanity
:run
CLS
YOUR SERVERS RUN STUFF HERE.(copy and paste that "java -Xmx1000m -cp....etc, etc." stuff that you saved earlier into here.
goto run
pause


So your run.bat should look like this now

    @echo off
title Project Insanity
:run
CLS
java -Xmx1000m -cp bin;deps/poi.jar;deps/mysql.jar;deps/mina.jar;deps/slf4j.jar;deps/slf4j-nop.jar;deps/jython.jar;log4j-1.2.15.jar; server.Server
goto run
pause


Post any errors that you get(there shouldn't be any if you do it all correctly)
(adsbygoogle = window.adsbygoogle || []).push({});

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo