mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-16 10:34:49 +00:00
Add in a "server stopped" event
This commit is contained in:
1 parent
6fc7bc4941
commit
d9bfb29d6c
7 files changed
+54
-10
No files matched your search
@@ -453,4 +453,9 @@ public class FMLCommonHandler
|
|||||||
{
|
{
|
||||||
sidedDelegate.disconnectIDMismatch(serverDifference, toKill, network);
|
sidedDelegate.disconnectIDMismatch(serverDifference, toKill, network);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleServerStopped()
|
||||||
|
{
|
||||||
|
Loader.instance().serverStopped();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -60,6 +60,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.FMLServerStartedEvent;
|
import cpw.mods.fml.common.event.FMLServerStartedEvent;
|
||||||
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.event.FMLStateEvent;
|
import cpw.mods.fml.common.event.FMLStateEvent;
|
||||||
import cpw.mods.fml.common.network.FMLNetworkHandler;
|
import cpw.mods.fml.common.network.FMLNetworkHandler;
|
||||||
@@ -92,6 +93,7 @@ public class FMLModContainer implements ModContainer
|
|||||||
.put(FMLServerStartingEvent.class, Mod.ServerStarting.class)
|
.put(FMLServerStartingEvent.class, Mod.ServerStarting.class)
|
||||||
.put(FMLServerStartedEvent.class, Mod.ServerStarted.class)
|
.put(FMLServerStartedEvent.class, Mod.ServerStarted.class)
|
||||||
.put(FMLServerStoppingEvent.class, Mod.ServerStopping.class)
|
.put(FMLServerStoppingEvent.class, Mod.ServerStopping.class)
|
||||||
|
.put(FMLServerStoppedEvent.class, Mod.ServerStopped.class)
|
||||||
.put(IMCEvent.class,Mod.IMCCallback.class)
|
.put(IMCEvent.class,Mod.IMCCallback.class)
|
||||||
.put(FMLFingerprintViolationEvent.class, Mod.FingerprintWarning.class)
|
.put(FMLFingerprintViolationEvent.class, Mod.FingerprintWarning.class)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import java.util.concurrent.Callable;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import net.minecraft.crash.CallableMinecraftVersion;
|
import net.minecraft.crash.CallableMinecraftVersion;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
import com.google.common.base.CharMatcher;
|
import com.google.common.base.CharMatcher;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
@@ -710,8 +711,6 @@ public class Loader
|
|||||||
{
|
{
|
||||||
modController.distributeStateMessage(LoaderState.SERVER_STOPPING);
|
modController.distributeStateMessage(LoaderState.SERVER_STOPPING);
|
||||||
modController.transition(LoaderState.SERVER_STOPPING);
|
modController.transition(LoaderState.SERVER_STOPPING);
|
||||||
modController.transition(LoaderState.AVAILABLE);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiMap<ModContainer, Object> getModObjectList()
|
public BiMap<ModContainer, Object> getModObjectList()
|
||||||
@@ -746,4 +745,11 @@ public class Loader
|
|||||||
public String getMCPVersionString() {
|
public String getMCPVersionString() {
|
||||||
return String.format("MCP v%s", mcpversion);
|
return String.format("MCP v%s", mcpversion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void serverStopped()
|
||||||
|
{
|
||||||
|
modController.distributeStateMessage(LoaderState.SERVER_STOPPED);
|
||||||
|
modController.transition(LoaderState.SERVER_STOPPED);
|
||||||
|
modController.transition(LoaderState.AVAILABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,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.FMLServerStartedEvent;
|
import cpw.mods.fml.common.event.FMLServerStartedEvent;
|
||||||
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.event.FMLStateEvent;
|
import cpw.mods.fml.common.event.FMLStateEvent;
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ public enum LoaderState
|
|||||||
SERVER_STARTING("Server starting", FMLServerStartingEvent.class),
|
SERVER_STARTING("Server starting", FMLServerStartingEvent.class),
|
||||||
SERVER_STARTED("Server started", FMLServerStartedEvent.class),
|
SERVER_STARTED("Server started", FMLServerStartedEvent.class),
|
||||||
SERVER_STOPPING("Server stopping", FMLServerStoppingEvent.class),
|
SERVER_STOPPING("Server stopping", FMLServerStoppingEvent.class),
|
||||||
|
SERVER_STOPPED("Server stopped", FMLServerStoppedEvent.class),
|
||||||
ERRORED("Mod Loading errored",null);
|
ERRORED("Mod Loading errored",null);
|
||||||
|
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@ public enum LoaderState
|
|||||||
return ERRORED;
|
return ERRORED;
|
||||||
}
|
}
|
||||||
// stopping -> available
|
// stopping -> available
|
||||||
if (this == SERVER_STOPPING)
|
if (this == SERVER_STOPPED)
|
||||||
{
|
{
|
||||||
return AVAILABLE;
|
return AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,14 @@ public @interface Mod
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
public @interface ServerStopping {}
|
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
|
* Mark the designated method as the receiver for {@link FMLInterModComms} messages
|
||||||
* Called between {@link Init} and {@link PostInit}
|
* Called between {@link Init} and {@link PostInit}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -40,8 +40,11 @@
|
|||||||
var48.printStackTrace();
|
var48.printStackTrace();
|
||||||
field_71306_a.log(Level.SEVERE, "Encountered an unexpected exception " + var48.getClass().getSimpleName(), var48);
|
field_71306_a.log(Level.SEVERE, "Encountered an unexpected exception " + var48.getClass().getSimpleName(), var48);
|
||||||
CrashReport var2 = null;
|
CrashReport var2 = null;
|
||||||
@@ -455,6 +467,10 @@
|
@@ -453,8 +465,13 @@
|
||||||
|
}
|
||||||
|
finally
|
||||||
{
|
{
|
||||||
|
+ FMLCommonHandler.instance().handleServerStopped();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
+ if (FMLCommonHandler.instance().shouldServerBeKilledQuietly())
|
+ if (FMLCommonHandler.instance().shouldServerBeKilledQuietly())
|
||||||
@@ -51,7 +54,7 @@
|
|||||||
this.func_71260_j();
|
this.func_71260_j();
|
||||||
this.field_71316_v = true;
|
this.field_71316_v = true;
|
||||||
}
|
}
|
||||||
@@ -480,8 +496,10 @@
|
@@ -480,8 +497,10 @@
|
||||||
|
|
||||||
public void func_71217_p()
|
public void func_71217_p()
|
||||||
{
|
{
|
||||||
@@ -62,7 +65,7 @@
|
|||||||
++this.field_71315_w;
|
++this.field_71315_w;
|
||||||
|
|
||||||
if (this.field_71295_T)
|
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();
|
||||||
this.field_71304_b.func_76319_b();
|
this.field_71304_b.func_76319_b();
|
||||||
@@ -70,7 +73,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void func_71190_q()
|
public void func_71190_q()
|
||||||
@@ -554,6 +573,7 @@
|
@@ -554,6 +574,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.field_71304_b.func_76320_a("tick");
|
this.field_71304_b.func_76320_a("tick");
|
||||||
@@ -78,7 +81,7 @@
|
|||||||
CrashReport var6;
|
CrashReport var6;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -578,6 +598,7 @@
|
@@ -578,6 +599,7 @@
|
||||||
throw new ReportedException(var6);
|
throw new ReportedException(var6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +89,7 @@
|
|||||||
this.field_71304_b.func_76319_b();
|
this.field_71304_b.func_76319_b();
|
||||||
this.field_71304_b.func_76320_a("tracker");
|
this.field_71304_b.func_76320_a("tracker");
|
||||||
var4.func_73039_n().func_72788_a();
|
var4.func_73039_n().func_72788_a();
|
||||||
@@ -705,7 +726,7 @@
|
@@ -705,7 +727,7 @@
|
||||||
|
|
||||||
public String getServerModName()
|
public String getServerModName()
|
||||||
{
|
{
|
||||||
@@ -95,7 +98,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CrashReport func_71230_b(CrashReport p_71230_1_)
|
public CrashReport func_71230_b(CrashReport p_71230_1_)
|
||||||
@@ -1146,6 +1167,13 @@
|
@@ -1146,6 +1168,13 @@
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
public static void main(String[] p_main_0_)
|
public static void main(String[] p_main_0_)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user