TechReborn/src/main/java/techreborn/compat/CompatManager.java

102 lines
2.8 KiB
Java
Raw Normal View History

package techreborn.compat;
2016-06-04 21:07:34 +02:00
import ic2.api.info.Info;
2016-03-04 20:47:08 +01:00
import net.minecraftforge.fml.common.FMLCommonHandler;
2015-11-23 15:40:30 +01:00
import net.minecraftforge.fml.common.Loader;
2016-03-04 20:47:08 +01:00
import net.minecraftforge.fml.relauncher.Side;
import techreborn.client.render.parts.ClientPartLoader;
2016-06-06 20:52:46 +02:00
import techreborn.compat.ic2.RecipesIC2;
import techreborn.compat.minetweaker.MinetweakerCompat;
2016-06-04 15:53:16 +02:00
import techreborn.compat.theoneprobe.CompactTheOneProbe;
import techreborn.compat.tinkers.CompatModuleTinkers;
import techreborn.compat.waila.CompatModuleWaila;
import techreborn.config.ConfigTechReborn;
2016-03-06 15:51:13 +01:00
import techreborn.parts.StandalonePartCompact;
2016-03-19 19:01:34 +01:00
import techreborn.parts.TechRebornParts;
import techreborn.parts.walia.WailaMcMultiPartCompact;
2016-05-09 03:02:11 +02:00
import java.util.ArrayList;
2016-03-25 10:47:34 +01:00
public class CompatManager
{
2015-06-12 19:40:08 +02:00
2016-03-25 10:47:34 +01:00
public static CompatManager INSTANCE = new CompatManager();
public static boolean isIC2Loaded = false;
public ArrayList<ICompatModule> compatModules = new ArrayList<>();
2015-06-12 19:40:08 +02:00
2016-03-25 10:47:34 +01:00
public CompatManager()
{
isIC2Loaded = Info.isIc2Available();
registerCompact(MinetweakerCompat.class, "MineTweaker3");
2016-06-01 13:06:51 +02:00
registerCompact(TechRebornParts.class, "reborncore-mcmultipart");
registerCompact(ClientPartLoader.class, "reborncore-mcmultipart", "@client");
registerCompact(StandalonePartCompact.class, "!reborncore-mcmultipart");
registerCompact(WailaMcMultiPartCompact.class, "reborncore-mcmultipart", "Waila", "!IC2");
registerCompact(CompatModuleWaila.class, "Waila");
registerCompact(CompatModuleTinkers.class, "tconstruct");
2016-06-04 15:53:16 +02:00
registerCompact(CompactTheOneProbe.class, "theoneprobe");
2016-04-24 17:33:20 +02:00
//registerCompact(CompatModulePsi.class, "Psi");
2016-06-06 20:52:46 +02:00
registerCompact(RecipesIC2.class, "IC2");
2016-03-25 10:47:34 +01:00
}
2016-03-25 10:47:34 +01:00
public void registerCompact(Class<? extends ICompatModule> moduleClass, Object... objs)
{
boolean shouldLoad = ConfigTechReborn.config
.get(ConfigTechReborn.CATEGORY_INTEGRATION, "Compat:" + moduleClass.getSimpleName(), true,
"Should the " + moduleClass.getSimpleName() + " be loaded?")
.getBoolean(true);
if (ConfigTechReborn.config.hasChanged())
ConfigTechReborn.config.save();
if (!shouldLoad)
{
return;
}
for (Object obj : objs)
{
if (obj instanceof String)
{
String modid = (String) obj;
if (modid.startsWith("@"))
{
if (modid.equals("@client"))
{
if (FMLCommonHandler.instance().getSide() != Side.CLIENT)
{
return;
}
}
} else if (modid.startsWith("!"))
{
if (Loader.isModLoaded(modid.replaceAll("!", "")))
{
return;
}
} else
{
if (!Loader.isModLoaded(modid))
{
return;
}
}
} else if (obj instanceof Boolean)
{
Boolean boo = (Boolean) obj;
if (!boo)
2016-03-25 10:47:34 +01:00
{
}
return;
}
}
try
{
compatModules.add(moduleClass.newInstance());
2016-03-25 10:47:34 +01:00
} catch (InstantiationException e)
{
e.printStackTrace();
} catch (IllegalAccessException e)
{
e.printStackTrace();
}
}
}