Fixes #1983: WorldData cleared too early when still needed.

This commit is contained in:
yueh 2015-11-02 12:13:09 +01:00
parent c83946420e
commit 3c19350b9b
3 changed files with 18 additions and 5 deletions

View file

@ -21,6 +21,7 @@ package appeng.core;
import java.io.File; import java.io.File;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import com.google.common.base.Stopwatch; import com.google.common.base.Stopwatch;
@ -37,6 +38,7 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent; import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
@ -233,6 +235,12 @@ public final class AppEng
private void serverStopping( final FMLServerStoppingEvent event ) private void serverStopping( final FMLServerStoppingEvent event )
{ {
WorldData.instance().onServerStopping(); WorldData.instance().onServerStopping();
}
@EventHandler
private void serverStopped( final FMLServerStoppedEvent event )
{
WorldData.instance().onServerStoppped();
TickHandler.INSTANCE.shutdown(); TickHandler.INSTANCE.shutdown();
} }

View file

@ -24,13 +24,15 @@ import javax.annotation.Nonnull;
/** /**
* @author thatsIch * @author thatsIch
* @version rv3 - 30.05.2015 * @version rv3 - 02.11.2015
* @since rv3 30.05.2015 * @since rv3 30.05.2015
*/ */
public interface IWorldData public interface IWorldData
{ {
void onServerStopping(); void onServerStopping();
void onServerStoppped();
@Nonnull @Nonnull
IWorldGridStorageData storageData(); IWorldGridStorageData storageData();

View file

@ -45,7 +45,7 @@ import appeng.services.compass.CompassThreadFactory;
* different worlds. * different worlds.
* *
* @author thatsIch * @author thatsIch
* @version rv3 - 30.05.2015 * @version rv3 - 02.11.2015
* @since rv3 30.05.2015 * @since rv3 30.05.2015
*/ */
public final class WorldData implements IWorldData public final class WorldData implements IWorldData
@ -162,15 +162,18 @@ public final class WorldData implements IWorldData
@Override @Override
public void onServerStopping() public void onServerStopping()
{ {
Preconditions.checkNotNull( instance );
for( final IOnWorldStoppable stoppable : this.stoppables ) for( final IOnWorldStoppable stoppable : this.stoppables )
{ {
stoppable.onWorldStop(); stoppable.onWorldStop();
} }
}
@Override
public void onServerStoppped()
{
Preconditions.checkNotNull( instance );
this.stoppables.clear(); this.stoppables.clear();
instance = null; instance = null;
} }