mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-18 03:25:10 +00:00
Initial test of Gradle (not working yet)
This commit is contained in:
1 parent
e8b7378831
commit
cb87c836c8
519 files changed
+351
No files matched your search
@@ -0,0 +1,87 @@
|
||||
package tconstruct.plugins;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.plugins.fmp.ForgeMultiPart;
|
||||
import tconstruct.plugins.minefactoryreloaded.MineFactoryReloaded;
|
||||
import tconstruct.plugins.nei.NotEnoughItems;
|
||||
import tconstruct.plugins.waila.Waila;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PluginController
|
||||
{
|
||||
|
||||
private enum Phase {
|
||||
PRELAUNCH, PREINIT, INIT, POSTINIT, DONE
|
||||
}
|
||||
|
||||
private static PluginController instance;
|
||||
private List<ICompatPlugin> plugins = new ArrayList<ICompatPlugin>();
|
||||
private Phase currPhase = Phase.PRELAUNCH;
|
||||
|
||||
private PluginController() {}
|
||||
|
||||
public static PluginController getController()
|
||||
{
|
||||
if (instance == null) instance = new PluginController();
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void registerPlugin(ICompatPlugin plugin)
|
||||
{
|
||||
if (Loader.isModLoaded(plugin.getModId()))
|
||||
{
|
||||
TConstruct.logger.info("Registering compat plugin for " + plugin.getModId());
|
||||
plugins.add(plugin);
|
||||
|
||||
switch (currPhase) // Play catch-up if plugin is registered late
|
||||
{
|
||||
case DONE:
|
||||
case POSTINIT:
|
||||
plugin.preInit();
|
||||
plugin.init();
|
||||
plugin.postInit();
|
||||
break;
|
||||
case INIT:
|
||||
plugin.preInit();
|
||||
plugin.init();
|
||||
break;
|
||||
case PREINIT:
|
||||
plugin.preInit();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void preInit()
|
||||
{
|
||||
currPhase = Phase.PREINIT;
|
||||
for (ICompatPlugin plugin : plugins) plugin.preInit();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
currPhase = Phase.INIT;
|
||||
for (ICompatPlugin plugin : plugins) plugin.init();
|
||||
}
|
||||
|
||||
public void postInit()
|
||||
{
|
||||
currPhase = Phase.POSTINIT;
|
||||
for (ICompatPlugin plugin : plugins) plugin.postInit();
|
||||
currPhase = Phase.DONE;
|
||||
}
|
||||
|
||||
public void registerBuiltins()
|
||||
{
|
||||
registerPlugin(new ForgeMultiPart());
|
||||
registerPlugin(new MineFactoryReloaded());
|
||||
registerPlugin(new NotEnoughItems());
|
||||
registerPlugin(new Waila());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user