IntegrationType Re-factor.
This commit is contained in:
@@ -17,13 +17,13 @@ public class IntegrationNode
|
||||
String displayName;
|
||||
String modID;
|
||||
|
||||
String shortName;
|
||||
IntegrationType shortName;
|
||||
String name = null;
|
||||
Class classValue = null;
|
||||
Object instance;
|
||||
IIntegrationModule mod = null;
|
||||
|
||||
public IntegrationNode(String dspname, String _modID, String sName, String n) {
|
||||
public IntegrationNode(String dspname, String _modID, IntegrationType sName, String n) {
|
||||
displayName = dspname;
|
||||
shortName = sName;
|
||||
modID = _modID;
|
||||
|
||||
@@ -9,18 +9,17 @@ public class IntegrationRegistry
|
||||
{
|
||||
|
||||
public static IntegrationRegistry instance = null;
|
||||
|
||||
private LinkedList<IntegrationNode> modules = new LinkedList<IntegrationNode>();
|
||||
|
||||
public void add(IntegrationSide side, String dspname, String modID, String name)
|
||||
public void add( IntegrationType type)
|
||||
{
|
||||
if ( side == IntegrationSide.CLIENT && FMLLaunchHandler.side() == Side.SERVER )
|
||||
if ( type.side == IntegrationSide.CLIENT && FMLLaunchHandler.side() == Side.SERVER )
|
||||
return;
|
||||
|
||||
if ( side == IntegrationSide.SERVER && FMLLaunchHandler.side() == Side.CLIENT )
|
||||
if ( type.side == IntegrationSide.SERVER && FMLLaunchHandler.side() == Side.CLIENT )
|
||||
return;
|
||||
|
||||
modules.add( new IntegrationNode( dspname, modID, name, "appeng.integration.modules." + name ) );
|
||||
modules.add( new IntegrationNode( type.dspName, type.modID, type, "appeng.integration.modules." + type.name() ) );
|
||||
}
|
||||
|
||||
public IntegrationRegistry() {
|
||||
@@ -59,17 +58,17 @@ public class IntegrationRegistry
|
||||
return out;
|
||||
}
|
||||
|
||||
public boolean isEnabled(String name)
|
||||
public boolean isEnabled(IntegrationType name)
|
||||
{
|
||||
for (IntegrationNode node : modules)
|
||||
{
|
||||
if ( node.shortName.equals( name ) )
|
||||
if ( node.shortName == name )
|
||||
return node.isActive();
|
||||
}
|
||||
throw new RuntimeException( "invalid integration" );
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object getInstance(String name)
|
||||
public Object getInstance(IntegrationType name)
|
||||
{
|
||||
for (IntegrationNode node : modules)
|
||||
{
|
||||
@@ -78,7 +77,7 @@ public class IntegrationRegistry
|
||||
return node.instance;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException( "invalid integration" );
|
||||
throw new RuntimeException( "integration with "+name.name()+" is disabled." );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCable;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
@@ -44,7 +45,7 @@ public class Waila extends BaseModule implements IWailaDataProvider, IWailaFMPPr
|
||||
|
||||
public static void register(IWailaRegistrar registrar)
|
||||
{
|
||||
Waila w = (Waila) AppEng.instance.getIntegration( "Waila" );
|
||||
Waila w = (Waila) AppEng.instance.getIntegration( IntegrationType.Waila );
|
||||
|
||||
registrar.registerBodyProvider( w, AEBaseBlock.class );
|
||||
registrar.registerBodyProvider( w, "ae2_cablebus" );
|
||||
|
||||
Reference in New Issue
Block a user