IntegrationType Re-factor.

This commit is contained in:
AlgorithmX2
2014-07-23 17:26:23 -05:00
parent 50b0285c15
commit 980dff203f
30 changed files with 120 additions and 105 deletions
+2 -2
View File
@@ -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 -10
View File
@@ -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." );
}
}
+2 -1
View File
@@ -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" );