2013-12-27 23:59:59 +01:00
|
|
|
package appeng.integration;
|
|
|
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
2014-04-06 08:55:24 +02:00
|
|
|
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public class IntegrationRegistry
|
|
|
|
{
|
|
|
|
|
|
|
|
public static IntegrationRegistry instance = null;
|
|
|
|
|
|
|
|
private LinkedList<IntegrationNode> modules = new LinkedList<IntegrationNode>();
|
|
|
|
|
2014-04-06 08:55:24 +02:00
|
|
|
public void add(IntegrationSide side, String dspname, String modID, String name)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-04-06 08:55:24 +02:00
|
|
|
if ( side == IntegrationSide.CLIENT && FMLLaunchHandler.side() == Side.SERVER )
|
2013-12-27 23:59:59 +01:00
|
|
|
return;
|
|
|
|
|
2014-04-06 08:55:24 +02:00
|
|
|
if ( side == IntegrationSide.SERVER && FMLLaunchHandler.side() == Side.CLIENT )
|
2013-12-27 23:59:59 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
modules.add( new IntegrationNode( dspname, modID, name, "appeng.integration.modules." + name ) );
|
|
|
|
}
|
|
|
|
|
2014-04-06 08:55:24 +02:00
|
|
|
public IntegrationRegistry() {
|
2013-12-27 23:59:59 +01:00
|
|
|
instance = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void init()
|
|
|
|
{
|
|
|
|
for (IntegrationNode node : modules)
|
|
|
|
node.Call( IntegrationStage.PREINIT );
|
|
|
|
|
|
|
|
for (IntegrationNode node : modules)
|
|
|
|
node.Call( IntegrationStage.INIT );
|
|
|
|
}
|
|
|
|
|
|
|
|
public void postinit()
|
|
|
|
{
|
|
|
|
for (IntegrationNode node : modules)
|
|
|
|
node.Call( IntegrationStage.POSTINIT );
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getStatus()
|
|
|
|
{
|
|
|
|
String out = null;
|
|
|
|
|
|
|
|
for (IntegrationNode node : modules)
|
|
|
|
{
|
|
|
|
String str = node.shortName + ":" + (node.state == IntegrationStage.FAILED ? "OFF" : "ON");
|
|
|
|
|
|
|
|
if ( out == null )
|
|
|
|
out = str;
|
|
|
|
else
|
|
|
|
out += ", " + str;
|
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isEnabled(String name)
|
|
|
|
{
|
|
|
|
for (IntegrationNode node : modules)
|
|
|
|
{
|
|
|
|
if ( node.shortName.equals( name ) )
|
|
|
|
return node.isActive();
|
|
|
|
}
|
|
|
|
throw new RuntimeException( "invalid integration" );
|
|
|
|
}
|
|
|
|
|
|
|
|
public Object getInstance(String name)
|
|
|
|
{
|
|
|
|
for (IntegrationNode node : modules)
|
|
|
|
{
|
|
|
|
if ( node.shortName.equals( name ) && node.isActive() )
|
|
|
|
{
|
|
|
|
return node.instance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new RuntimeException( "invalid integration" );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|