mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-16 18:45:09 +00:00
The "ServerStarting" event should now properly crash the server if it fails,
so the client will properly exit. Also, added in a "pre-server-start" event that fires before the worlds are loaded for a save, just for you immibis.
This commit is contained in:
1 parent
e1c6630569
commit
cd67596d57
6 files changed
+71
-5
No files matched your search
@@ -304,9 +304,14 @@ public class FMLCommonHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleServerStarting(MinecraftServer server)
|
public boolean handleServerAboutToStart(MinecraftServer server)
|
||||||
{
|
{
|
||||||
Loader.instance().serverStarting(server);
|
return Loader.instance().serverAboutToStart(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean handleServerStarting(MinecraftServer server)
|
||||||
|
{
|
||||||
|
return Loader.instance().serverStarting(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleServerStarted()
|
public void handleServerStarted()
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
|||||||
import cpw.mods.fml.common.event.FMLFingerprintViolationEvent;
|
import cpw.mods.fml.common.event.FMLFingerprintViolationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
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.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.FMLServerStoppedEvent;
|
||||||
@@ -90,6 +91,7 @@ public class FMLModContainer implements ModContainer
|
|||||||
.put(FMLPreInitializationEvent.class, Mod.PreInit.class)
|
.put(FMLPreInitializationEvent.class, Mod.PreInit.class)
|
||||||
.put(FMLInitializationEvent.class, Mod.Init.class)
|
.put(FMLInitializationEvent.class, Mod.Init.class)
|
||||||
.put(FMLPostInitializationEvent.class, Mod.PostInit.class)
|
.put(FMLPostInitializationEvent.class, Mod.PostInit.class)
|
||||||
|
.put(FMLServerAboutToStartEvent.class, Mod.ServerAboutToStart.class)
|
||||||
.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)
|
||||||
|
|||||||
@@ -695,10 +695,19 @@ public class Loader
|
|||||||
return "Minecraft " + mccversion;
|
return "Minecraft " + mccversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serverStarting(Object server)
|
public boolean serverStarting(Object server)
|
||||||
{
|
{
|
||||||
modController.distributeStateMessage(LoaderState.SERVER_STARTING, server);
|
try
|
||||||
modController.transition(LoaderState.SERVER_STARTING);
|
{
|
||||||
|
modController.distributeStateMessage(LoaderState.SERVER_STARTING, server);
|
||||||
|
modController.transition(LoaderState.SERVER_STARTING);
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
FMLLog.log(Level.SEVERE, t, "A fatal exception occurred during the server starting event");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serverStarted()
|
public void serverStarted()
|
||||||
@@ -752,4 +761,19 @@ public class Loader
|
|||||||
modController.transition(LoaderState.SERVER_STOPPED);
|
modController.transition(LoaderState.SERVER_STOPPED);
|
||||||
modController.transition(LoaderState.AVAILABLE);
|
modController.transition(LoaderState.AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean serverAboutToStart(MinecraftServer server)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
modController.distributeStateMessage(LoaderState.SERVER_ABOUT_TO_START, server);
|
||||||
|
modController.transition(LoaderState.SERVER_ABOUT_TO_START);
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
FMLLog.log(Level.SEVERE, t, "A fatal exception occurred during the server about to start event");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
|||||||
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
|
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
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.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.FMLServerStoppedEvent;
|
||||||
@@ -28,6 +29,7 @@ public enum LoaderState
|
|||||||
INITIALIZATION("Initializing mods", FMLInitializationEvent.class),
|
INITIALIZATION("Initializing mods", FMLInitializationEvent.class),
|
||||||
POSTINITIALIZATION("Post-initializing mods", FMLPostInitializationEvent.class),
|
POSTINITIALIZATION("Post-initializing mods", FMLPostInitializationEvent.class),
|
||||||
AVAILABLE("Mod loading complete", FMLLoadCompleteEvent.class),
|
AVAILABLE("Mod loading complete", FMLLoadCompleteEvent.class),
|
||||||
|
SERVER_ABOUT_TO_START("Server about to start", FMLServerAboutToStartEvent.class),
|
||||||
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),
|
||||||
|
|||||||
@@ -144,6 +144,14 @@ public @interface Mod
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
public @interface PostInit {}
|
public @interface PostInit {}
|
||||||
|
/**
|
||||||
|
* Mark the designated method as being called at the "server-about-to-start" phase
|
||||||
|
* @author cpw
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface ServerAboutToStart {}
|
||||||
/**
|
/**
|
||||||
* Mark the designated method as being called at the "server-starting" phase
|
* Mark the designated method as being called at the "server-starting" phase
|
||||||
* @author cpw
|
* @author cpw
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package cpw.mods.fml.common.event;
|
||||||
|
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import cpw.mods.fml.common.LoaderState.ModState;
|
||||||
|
|
||||||
|
public class FMLServerAboutToStartEvent extends FMLStateEvent {
|
||||||
|
|
||||||
|
private MinecraftServer server;
|
||||||
|
|
||||||
|
public FMLServerAboutToStartEvent(Object... data)
|
||||||
|
{
|
||||||
|
super(data);
|
||||||
|
this.server = (MinecraftServer) data[0];
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public ModState getModState()
|
||||||
|
{
|
||||||
|
return ModState.AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MinecraftServer getServer()
|
||||||
|
{
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user