Added verification code to make sure no idiot found the need to override the internal method handler even though they told not to.

This commit is contained in:
Vasco Lavos committed 2015-09-24 21:17:46 +01:00
1 parent f074f803cd
commit 53fe7e1244
3 files changed
+24 -2

No files matched your search

@@ -231,12 +231,13 @@ public final class BotaniaAPI {
}
/**
* The internal method handler in use. Do not overwrite.
* The internal method handler in use.
* <b>DO NOT OVERWRITE THIS OR YOU'RE GOING TO FEEL MY WRATH WHEN I UPDATE THE API.</b>
* The fact I have to write that means some moron already tried, don't be that moron.
* @see IInternalMethodHandler
*/
public static IInternalMethodHandler internalHandler = new DummyMethodHandler();
/**
* Registers a new Knowledge Type.
* @param id The ID for this knowledge type.
@@ -27,6 +27,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
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.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
@@ -72,6 +73,11 @@ public class Botania {
public void postInit(FMLPostInitializationEvent event) {
proxy.postInit(event);
}
@EventHandler
public void serverStarting(FMLServerAboutToStartEvent event) {
proxy.serverAboutToStart(event);
}
@EventHandler
public void serverStarting(FMLServerStartingEvent event) {
@@ -72,6 +72,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
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.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
@@ -158,6 +159,20 @@ public class CommonProxy {
return s1.split(" ").length;
}
// Overriding the internal method handler will break everything as it changes regularly.
// So just don't be a moron and don't override it. Thanks.
public void serverAboutToStart(FMLServerAboutToStartEvent event) {
String clname = BotaniaAPI.internalHandler.getClass().getName();
String expect = "vazkii.botania.common.core.handler.InternalMethodHandler";
if(!clname.equals(expect)) {
new IllegalAccessError("The Botania API internal method handler has been overriden. "
+ "This will cause crashes and compatibility issues, and that's why it's marked as"
+ " \"Do not Override\". Whoever had the brilliant idea of overriding it needs to go"
+ " back to elementary school and learn to read. (Expected classname: " + expect + ", Actual classname: " + clname + ")").printStackTrace();
FMLCommonHandler.instance().exitJava(1, true);
}
}
public void serverStarting(FMLServerStartingEvent event) {
event.registerServerCommand(new CommandDownloadLatest());
event.registerServerCommand(new CommandShare());