diff --git a/common/cpw/mods/fml/common/FMLCommonHandler.java b/common/cpw/mods/fml/common/FMLCommonHandler.java index c0f6c6a5ad..b4627773a8 100644 --- a/common/cpw/mods/fml/common/FMLCommonHandler.java +++ b/common/cpw/mods/fml/common/FMLCommonHandler.java @@ -453,4 +453,9 @@ public class FMLCommonHandler { sidedDelegate.disconnectIDMismatch(serverDifference, toKill, network); } + + public void handleServerStopped() + { + Loader.instance().serverStopped(); + } } diff --git a/common/cpw/mods/fml/common/FMLModContainer.java b/common/cpw/mods/fml/common/FMLModContainer.java index 69b97fe1f5..7ab6449bbe 100644 --- a/common/cpw/mods/fml/common/FMLModContainer.java +++ b/common/cpw/mods/fml/common/FMLModContainer.java @@ -60,6 +60,7 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartedEvent; 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.FMLStateEvent; import cpw.mods.fml.common.network.FMLNetworkHandler; @@ -92,6 +93,7 @@ public class FMLModContainer implements ModContainer .put(FMLServerStartingEvent.class, Mod.ServerStarting.class) .put(FMLServerStartedEvent.class, Mod.ServerStarted.class) .put(FMLServerStoppingEvent.class, Mod.ServerStopping.class) + .put(FMLServerStoppedEvent.class, Mod.ServerStopped.class) .put(IMCEvent.class,Mod.IMCCallback.class) .put(FMLFingerprintViolationEvent.class, Mod.FingerprintWarning.class) .build(); diff --git a/common/cpw/mods/fml/common/Loader.java b/common/cpw/mods/fml/common/Loader.java index e0626cf651..a8a5b670d8 100644 --- a/common/cpw/mods/fml/common/Loader.java +++ b/common/cpw/mods/fml/common/Loader.java @@ -27,6 +27,7 @@ import java.util.concurrent.Callable; import java.util.logging.Level; import net.minecraft.crash.CallableMinecraftVersion; +import net.minecraft.server.MinecraftServer; import com.google.common.base.CharMatcher; import com.google.common.base.Function; @@ -710,8 +711,6 @@ public class Loader { modController.distributeStateMessage(LoaderState.SERVER_STOPPING); modController.transition(LoaderState.SERVER_STOPPING); - modController.transition(LoaderState.AVAILABLE); - } public BiMap getModObjectList() @@ -746,4 +745,11 @@ public class Loader public String getMCPVersionString() { return String.format("MCP v%s", mcpversion); } + + public void serverStopped() + { + modController.distributeStateMessage(LoaderState.SERVER_STOPPED); + modController.transition(LoaderState.SERVER_STOPPED); + modController.transition(LoaderState.AVAILABLE); + } } diff --git a/common/cpw/mods/fml/common/LoaderState.java b/common/cpw/mods/fml/common/LoaderState.java index 731e2a4e75..0bd780301b 100644 --- a/common/cpw/mods/fml/common/LoaderState.java +++ b/common/cpw/mods/fml/common/LoaderState.java @@ -10,6 +10,7 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartedEvent; 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.FMLStateEvent; @@ -30,6 +31,7 @@ public enum LoaderState SERVER_STARTING("Server starting", FMLServerStartingEvent.class), SERVER_STARTED("Server started", FMLServerStartedEvent.class), SERVER_STOPPING("Server stopping", FMLServerStoppingEvent.class), + SERVER_STOPPED("Server stopped", FMLServerStoppedEvent.class), ERRORED("Mod Loading errored",null); @@ -49,7 +51,7 @@ public enum LoaderState return ERRORED; } // stopping -> available - if (this == SERVER_STOPPING) + if (this == SERVER_STOPPED) { return AVAILABLE; } diff --git a/common/cpw/mods/fml/common/Mod.java b/common/cpw/mods/fml/common/Mod.java index 781bf9cb84..5aa5cd4f22 100644 --- a/common/cpw/mods/fml/common/Mod.java +++ b/common/cpw/mods/fml/common/Mod.java @@ -168,6 +168,14 @@ public @interface Mod @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface ServerStopping {} + /** + * Mark the designated method as being called at the "server-stopped" phase + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + public @interface ServerStopped {} /** * Mark the designated method as the receiver for {@link FMLInterModComms} messages * Called between {@link Init} and {@link PostInit} diff --git a/common/cpw/mods/fml/common/event/FMLServerStoppedEvent.java b/common/cpw/mods/fml/common/event/FMLServerStoppedEvent.java new file mode 100644 index 0000000000..019a9a4efe --- /dev/null +++ b/common/cpw/mods/fml/common/event/FMLServerStoppedEvent.java @@ -0,0 +1,18 @@ +package cpw.mods.fml.common.event; + +import cpw.mods.fml.common.LoaderState; +import cpw.mods.fml.common.LoaderState.ModState; + +public class FMLServerStoppedEvent extends FMLStateEvent { + + public FMLServerStoppedEvent(Object... data) + { + super(data); + } + @Override + public ModState getModState() + { + return ModState.AVAILABLE; + } + +} diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index 3440bd1b96..04ce78b8e3 100644 --- a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch @@ -40,8 +40,11 @@ var48.printStackTrace(); field_71306_a.log(Level.SEVERE, "Encountered an unexpected exception " + var48.getClass().getSimpleName(), var48); CrashReport var2 = null; -@@ -455,6 +467,10 @@ +@@ -453,8 +465,13 @@ + } + finally { ++ FMLCommonHandler.instance().handleServerStopped(); try { + if (FMLCommonHandler.instance().shouldServerBeKilledQuietly()) @@ -51,7 +54,7 @@ this.func_71260_j(); this.field_71316_v = true; } -@@ -480,8 +496,10 @@ +@@ -480,8 +497,10 @@ public void func_71217_p() { @@ -62,7 +65,7 @@ ++this.field_71315_w; if (this.field_71295_T) -@@ -527,6 +545,7 @@ +@@ -527,6 +546,7 @@ this.field_71304_b.func_76319_b(); this.field_71304_b.func_76319_b(); @@ -70,7 +73,7 @@ } public void func_71190_q() -@@ -554,6 +573,7 @@ +@@ -554,6 +574,7 @@ } this.field_71304_b.func_76320_a("tick"); @@ -78,7 +81,7 @@ CrashReport var6; try -@@ -578,6 +598,7 @@ +@@ -578,6 +599,7 @@ throw new ReportedException(var6); } @@ -86,7 +89,7 @@ this.field_71304_b.func_76319_b(); this.field_71304_b.func_76320_a("tracker"); var4.func_73039_n().func_72788_a(); -@@ -705,7 +726,7 @@ +@@ -705,7 +727,7 @@ public String getServerModName() { @@ -95,7 +98,7 @@ } public CrashReport func_71230_b(CrashReport p_71230_1_) -@@ -1146,6 +1167,13 @@ +@@ -1146,6 +1168,13 @@ @SideOnly(Side.SERVER) public static void main(String[] p_main_0_) {