2017-02-23 13:29:43 +01:00
|
|
|
/*
|
|
|
|
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
|
|
|
*
|
|
|
|
* Copyright (c) 2017 TechReborn
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2015-04-12 12:39:06 +02:00
|
|
|
package techreborn.compat;
|
|
|
|
|
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;
|
2017-06-02 16:44:00 +02:00
|
|
|
import techreborn.compat.buildcraft.BuildcraftBuildersCompat;
|
|
|
|
import techreborn.compat.buildcraft.BuildcraftCompat;
|
2017-03-14 13:59:17 +01:00
|
|
|
import techreborn.compat.crafttweaker.CraftTweakerCompat;
|
2017-06-12 11:55:26 +02:00
|
|
|
import techreborn.compat.ic2.RecipesIC2;
|
2017-06-09 04:12:58 +02:00
|
|
|
import techreborn.compat.theoneprobe.TheOneProbeCompat;
|
2017-07-07 00:49:00 +02:00
|
|
|
import techreborn.compat.thermalexpansion.RecipeThermalExpansion;
|
2016-06-04 12:31:53 +02:00
|
|
|
import techreborn.compat.tinkers.CompatModuleTinkers;
|
2016-03-26 16:58:38 +01:00
|
|
|
|
2016-05-09 03:02:11 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2016-10-08 21:46:16 +02: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;
|
2016-09-27 18:50:34 +02:00
|
|
|
public static boolean isQuantumStorageLoaded = false;
|
2016-04-03 15:34:39 +02:00
|
|
|
public ArrayList<ICompatModule> compatModules = new ArrayList<>();
|
2015-06-12 19:40:08 +02:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public CompatManager() {
|
2017-04-21 10:09:28 +02:00
|
|
|
isIC2Loaded = Loader.isModLoaded("ic2");
|
2016-09-27 18:50:34 +02:00
|
|
|
isQuantumStorageLoaded = Loader.isModLoaded("quantumstorage");
|
2017-03-14 13:59:17 +01:00
|
|
|
register(CraftTweakerCompat.class, "crafttweaker");
|
2016-10-08 22:56:24 +02:00
|
|
|
register(CompatModuleTinkers.class, "tconstruct");
|
2017-06-09 04:12:58 +02:00
|
|
|
register(TheOneProbeCompat.class, "theoneprobe");
|
2016-10-08 22:56:24 +02:00
|
|
|
//register(CompatModulePsi.class, "Psi");
|
2017-04-21 10:09:28 +02:00
|
|
|
register(RecipesIC2.class, "ic2");
|
2017-06-02 16:44:00 +02:00
|
|
|
register(BuildcraftBuildersCompat.class, "buildcraftbuilders");
|
|
|
|
register(BuildcraftCompat.class, "buildcraftcore");
|
2017-07-07 00:49:00 +02:00
|
|
|
register(RecipeThermalExpansion.class, "thermalexpansion");
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
2015-05-30 12:47:01 +02:00
|
|
|
|
2016-11-25 14:25:51 +01:00
|
|
|
public void register(Class<? extends ICompatModule> moduleClass, Object... objs) {
|
2016-10-08 22:56:24 +02:00
|
|
|
registerCompact(moduleClass, true, objs);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void registerCompact(Class<? extends ICompatModule> moduleClass, boolean config, Object... objs) {
|
2017-09-08 01:03:35 +02:00
|
|
|
//boolean shouldLoad = true;
|
2017-06-12 21:51:36 +02:00
|
|
|
//TODO config
|
2017-06-28 21:54:12 +02:00
|
|
|
// if (config) {
|
|
|
|
// shouldLoad = ConfigTechReborn.config
|
|
|
|
// .get(ConfigTechReborn.CATEGORY_INTEGRATION, "Compat:" + moduleClass.getSimpleName(), true,
|
|
|
|
// "Should the " + moduleClass.getSimpleName() + " be loaded?")
|
|
|
|
// .getBoolean(true);
|
|
|
|
// }
|
2016-10-08 21:46:16 +02:00
|
|
|
for (Object obj : objs) {
|
|
|
|
if (obj instanceof String) {
|
2016-03-25 10:47:34 +01:00
|
|
|
String modid = (String) obj;
|
2016-10-08 21:46:16 +02:00
|
|
|
if (modid.startsWith("@")) {
|
|
|
|
if (modid.equals("@client")) {
|
|
|
|
if (FMLCommonHandler.instance().getSide() != Side.CLIENT) {
|
2016-03-25 10:47:34 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-10-08 21:46:16 +02:00
|
|
|
} else if (modid.startsWith("!")) {
|
|
|
|
if (Loader.isModLoaded(modid.replaceAll("!", ""))) {
|
2016-03-25 10:47:34 +01:00
|
|
|
return;
|
|
|
|
}
|
2016-10-08 21:46:16 +02:00
|
|
|
} else {
|
|
|
|
if (!Loader.isModLoaded(modid)) {
|
2016-03-25 10:47:34 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-10-08 21:46:16 +02:00
|
|
|
} else if (obj instanceof Boolean) {
|
2016-03-25 10:47:34 +01:00
|
|
|
Boolean boo = (Boolean) obj;
|
2016-10-08 21:46:16 +02:00
|
|
|
if (!boo) {
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-10-08 21:46:16 +02:00
|
|
|
try {
|
2016-04-03 15:34:39 +02:00
|
|
|
compatModules.add(moduleClass.newInstance());
|
2016-10-08 21:46:16 +02:00
|
|
|
} catch (InstantiationException e) {
|
2016-03-25 10:47:34 +01:00
|
|
|
e.printStackTrace();
|
2016-10-08 21:46:16 +02:00
|
|
|
} catch (IllegalAccessException e) {
|
2016-03-25 10:47:34 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
2015-04-12 12:39:06 +02:00
|
|
|
}
|