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:
Christian 2013-01-22 09:11:44 -05:00
parent 509b5f8e7e
commit 6962786e4b
6 changed files with 71 additions and 5 deletions

View file

@ -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()

View file

@ -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.FMLPostInitializationEvent;
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.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
@ -90,6 +91,7 @@ public class FMLModContainer implements ModContainer
.put(FMLPreInitializationEvent.class, Mod.PreInit.class)
.put(FMLInitializationEvent.class, Mod.Init.class)
.put(FMLPostInitializationEvent.class, Mod.PostInit.class)
.put(FMLServerAboutToStartEvent.class, Mod.ServerAboutToStart.class)
.put(FMLServerStartingEvent.class, Mod.ServerStarting.class)
.put(FMLServerStartedEvent.class, Mod.ServerStarted.class)
.put(FMLServerStoppingEvent.class, Mod.ServerStopping.class)

View file

@ -695,11 +695,20 @@ public class Loader
return "Minecraft " + mccversion;
}
public void serverStarting(Object server)
public boolean serverStarting(Object server)
{
try
{
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()
{
@ -752,4 +761,19 @@ public class Loader
modController.transition(LoaderState.SERVER_STOPPED);
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;
}
}

View file

@ -8,6 +8,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
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.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
@ -28,6 +29,7 @@ public enum LoaderState
INITIALIZATION("Initializing mods", FMLInitializationEvent.class),
POSTINITIALIZATION("Post-initializing mods", FMLPostInitializationEvent.class),
AVAILABLE("Mod loading complete", FMLLoadCompleteEvent.class),
SERVER_ABOUT_TO_START("Server about to start", FMLServerAboutToStartEvent.class),
SERVER_STARTING("Server starting", FMLServerStartingEvent.class),
SERVER_STARTED("Server started", FMLServerStartedEvent.class),
SERVER_STOPPING("Server stopping", FMLServerStoppingEvent.class),

View file

@ -144,6 +144,14 @@ public @interface Mod
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
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
* @author cpw

View file

@ -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;
}
}