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,14 +318,17 @@ public class mod_pocketDim
try
{
PocketManager.tryUnload();
deathTracker.writeToFile();
deathTracker = null;
if (deathTracker != null) {
deathTracker.writeToFile();
deathTracker = null;
}
worldProperties = null;
currrentSaveRootDirectory = null;
// Unregister all tick receivers from serverTickHandler to avoid leaking
// scheduled tasks between single-player game sessions
serverTickHandler.unregisterReceivers();
if (serverTickHandler != null)
serverTickHandler.unregisterReceivers();
spawner = null;
riftRegenerator = null;
limboDecayScheduler = null;