Why is it static?
|
I'm using the following code
Yet when I close the CMD and I log back in im rolledback, I don't understand why. Can anyone help?Code:static { Runtime.getRuntime().addShutdownHook(new Thread(){ public void run() { System.out.println("Saving players..."); synchronized(this) { for(int i = 0; i < Config.MAX_PLAYERS; i++) if(players[i] != null) save.saveGame((Client)players[i]); } } }); }
Why is it static?
Not sure, heres the foll code if that helps
Code:public static PlayerSave save; static { Runtime.getRuntime().addShutdownHook(new Thread(){ public void run() { System.out.println("Saving players..."); synchronized(this) { for(int i = 0; i < Config.MAX_PLAYERS; i++) if(players[i] != null) save.saveGame((Client)players[i]); } } }); }
Is the hook even being run? Does that "Saving players..." message show?
Um, idk how to fix that but you could make a ::restart command for you on the server and everytime you do that it will save everyone.. thats recommended if you got vps.
the shutdown hook isn't ran when u exit the cmd, you need to use System.exit()
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |