Added a few guard conditions to shutdown code.

In some cases (such as another mod crashing on startup or something), the
server shutdown even was getting called before anything was actually
initialize.  In these cases, some uninitialized objects were having
cleanup methods called on them, when they were null.  There are now guard
conditions to prevent the resulting NPE's.
This commit is contained in:
Stephen Baynham 2015-07-21 18:31:33 -04:00
parent e0ffcaa98d
commit 337f0240a6

View file

@ -318,13 +318,16 @@ public class mod_pocketDim
try try
{ {
PocketManager.tryUnload(); PocketManager.tryUnload();
if (deathTracker != null) {
deathTracker.writeToFile(); deathTracker.writeToFile();
deathTracker = null; deathTracker = null;
}
worldProperties = null; worldProperties = null;
currrentSaveRootDirectory = null; currrentSaveRootDirectory = null;
// Unregister all tick receivers from serverTickHandler to avoid leaking // Unregister all tick receivers from serverTickHandler to avoid leaking
// scheduled tasks between single-player game sessions // scheduled tasks between single-player game sessions
if (serverTickHandler != null)
serverTickHandler.unregisterReceivers(); serverTickHandler.unregisterReceivers();
spawner = null; spawner = null;
riftRegenerator = null; riftRegenerator = null;