From 4f7ad220df0438b6f3382110577b53f29da46453 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 24 May 2018 15:50:07 -0400 Subject: Update of all changes --- .../jewelrycraft/thirdparty/ThirdPartyManager.java | 289 ++++++++++++--------- 1 file changed, 164 insertions(+), 125 deletions(-) mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java (limited to 'src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java') diff --git a/src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java b/src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java old mode 100644 new mode 100755 index c45bd12..612d23d --- a/src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java +++ b/src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java @@ -4,7 +4,9 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + import org.apache.logging.log4j.Level; + import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.network.IGuiHandler; import darkknight.jewelrycraft.JewelrycraftMod; @@ -14,132 +16,169 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.world.World; -/** +/** * @author MineMarteen from Pneumaticraft */ -public class ThirdPartyManager implements IGuiHandler{ - - private static ThirdPartyManager INSTANCE = new ThirdPartyManager(); - private final List thirdPartyMods = new ArrayList(); - - public static ThirdPartyManager instance(){ - return INSTANCE; - } - - public void index(){ - Map> thirdPartyClasses = new HashMap>(); - thirdPartyClasses.put(ModIds.EE3, EE3.class); - thirdPartyClasses.put(ModIds.NEI, NEI.class); - thirdPartyClasses.put(ModIds.ALPACA, Alpaca.class); - - List enabledThirdParty = new ArrayList(); - ConfigHandler.config.addCustomCategoryComment("third_party_enabling", "With these options you can disable third party content by mod. Useful if something in the mod changes and causes crashes."); - for(String modid : thirdPartyClasses.keySet()) { - if(ConfigHandler.config.get("Third_Party_Enabling", modid, true).getBoolean()) { - enabledThirdParty.add(modid); - } - } - ConfigHandler.config.save(); - - for(Map.Entry> entry : thirdPartyClasses.entrySet()) { - if(enabledThirdParty.contains(entry.getKey()) && Loader.isModLoaded(entry.getKey())) { - try { - thirdPartyMods.add(entry.getValue().newInstance()); - } catch(Exception e) { - JewelrycraftMod.logger.log(Level.ERROR, "Failed to instantiate third party handler!"); - e.printStackTrace(); - } - } - } - } - - public void onItemRegistry(Item item){ - for(IThirdParty thirdParty : thirdPartyMods) { - if(thirdParty instanceof IRegistryListener) ((IRegistryListener)thirdParty).onItemRegistry(item); - } - } - - public void onBlockRegistry(Block block){ - for(IThirdParty thirdParty : thirdPartyMods) { - if(thirdParty instanceof IRegistryListener) ((IRegistryListener)thirdParty).onBlockRegistry(block); - } - } - - public void preInit(){ - for(IThirdParty thirdParty : thirdPartyMods) { - try { - thirdParty.preInit(); - } catch(Throwable e) { - JewelrycraftMod.logger.log(Level.ERROR, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the PreInit phase!"); - e.printStackTrace(); - } - } - } - - public void init(){ - for(IThirdParty thirdParty : thirdPartyMods) { - try { - thirdParty.init(); - } catch(Throwable e) { - JewelrycraftMod.logger.log(Level.ERROR, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the Init phase!"); - e.printStackTrace(); - } - } - } - - public void postInit(){ - for(IThirdParty thirdParty : thirdPartyMods) { - try { - thirdParty.postInit(); - } catch(Throwable e) { - JewelrycraftMod.logger.log(Level.ERROR, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the PostInit phase!"); - e.printStackTrace(); - } - } - } - - public void clientSide(){ - for(IThirdParty thirdParty : thirdPartyMods) { - try { - thirdParty.clientSide(); - } catch(Throwable e) { - JewelrycraftMod.logger.log(Level.ERROR, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " client side!"); - e.printStackTrace(); - } - } - } - - public void clientInit(){ - for(IThirdParty thirdParty : thirdPartyMods) { - try { - thirdParty.clientInit(); - } catch(Throwable e) { - JewelrycraftMod.logger.log(Level.ERROR, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " client side on the init!"); - e.printStackTrace(); - } - } - } - - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){ - for(IThirdParty thirdParty : thirdPartyMods) { - if(thirdParty instanceof IGuiHandler) { - Object obj = ((IGuiHandler)thirdParty).getServerGuiElement(ID, player, world, x, y, z); - if(obj != null) return obj; - } - } - return null; - } - - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){ - for(IThirdParty thirdParty : thirdPartyMods) { - if(thirdParty instanceof IGuiHandler) { - Object obj = ((IGuiHandler)thirdParty).getClientGuiElement(ID, player, world, x, y, z); - if(obj != null) return obj; - } - } - return null; - } +public class ThirdPartyManager implements IGuiHandler { + + private static ThirdPartyManager INSTANCE = + new ThirdPartyManager(); + private final List thirdPartyMods = + new ArrayList<>(); + + public static ThirdPartyManager instance() { + return INSTANCE; + } + + public void index() { + Map> thirdPartyClasses = + new HashMap<>(); + + thirdPartyClasses.put(ModIds.EE3, EE3.class); + thirdPartyClasses.put(ModIds.NEI, NEI.class); + + List enabledThirdParty = new ArrayList<>(); + + ConfigHandler.config.addCustomCategoryComment( + "third_party_enabling", + "With these options you can disable third party content by mod." + + " Useful if something in the mod changes and causes crashes."); + + for (String modid : thirdPartyClasses.keySet()) { + if (ConfigHandler.config + .get("Third_Party_Enabling", modid, true) + .getBoolean()) { + enabledThirdParty.add(modid); + } + } + + ConfigHandler.config.save(); + + for (Map.Entry> entry : thirdPartyClasses + .entrySet()) { + if (enabledThirdParty.contains(entry.getKey()) + && Loader.isModLoaded(entry.getKey())) { + try { + thirdPartyMods.add(entry.getValue().newInstance()); + } catch (Exception e) { + JewelrycraftMod.logger.log(Level.ERROR, + "Failed to instantiate third party handler!"); + e.printStackTrace(); + } + } + } + } + + public void onItemRegistry(Item item) { + for (IThirdParty thirdParty : thirdPartyMods) { + if (thirdParty instanceof IRegistryListener) + ((IRegistryListener) thirdParty).onItemRegistry(item); + } + } + + public void onBlockRegistry(Block block) { + for (IThirdParty thirdParty : thirdPartyMods) { + if (thirdParty instanceof IRegistryListener) + ((IRegistryListener) thirdParty).onBlockRegistry(block); + } + } + + public void preInit() { + for (IThirdParty thirdParty : thirdPartyMods) { + try { + thirdParty.preInit(); + } catch (Throwable e) { + JewelrycraftMod.logger.log(Level.ERROR, + "Jewelrycraft wasn't able to load third party content from the third party class " + + thirdParty.getClass() + + " in the PreInit phase!"); + e.printStackTrace(); + } + } + } + + public void init() { + for (IThirdParty thirdParty : thirdPartyMods) { + try { + thirdParty.init(); + } catch (Throwable e) { + JewelrycraftMod.logger.log(Level.ERROR, + "Jewelrycraft wasn't able to load third party content from the third party class " + + thirdParty.getClass() + + " in the Init phase!"); + e.printStackTrace(); + } + } + } + + public void postInit() { + for (IThirdParty thirdParty : thirdPartyMods) { + try { + thirdParty.postInit(); + } catch (Throwable e) { + JewelrycraftMod.logger.log(Level.ERROR, + "Jewelrycraft wasn't able to load third party content from the third party class " + + thirdParty.getClass() + + " in the PostInit phase!"); + e.printStackTrace(); + } + } + } + + public void clientSide() { + for (IThirdParty thirdParty : thirdPartyMods) { + try { + thirdParty.clientSide(); + } catch (Throwable e) { + JewelrycraftMod.logger.log(Level.ERROR, + "Jewelrycraft wasn't able to load third party content from the third party class " + + thirdParty.getClass() + " client side!"); + e.printStackTrace(); + } + } + } + + public void clientInit() { + for (IThirdParty thirdParty : thirdPartyMods) { + try { + thirdParty.clientInit(); + } catch (Throwable e) { + JewelrycraftMod.logger.log(Level.ERROR, + "Jewelrycraft wasn't able to load third party content from the third party class " + + thirdParty.getClass() + + " client side on the init!"); + e.printStackTrace(); + } + } + } + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, + World world, int x, int y, int z) { + for (IThirdParty thirdParty : thirdPartyMods) { + if (thirdParty instanceof IGuiHandler) { + Object obj = ((IGuiHandler) thirdParty) + .getServerGuiElement(ID, player, world, x, y, z); + if (obj != null) + return obj; + } + } + return null; + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, + World world, int x, int y, int z) { + for (IThirdParty thirdParty : thirdPartyMods) { + if (thirdParty instanceof IGuiHandler) { + Object obj = ((IGuiHandler) thirdParty) + .getClientGuiElement(ID, player, world, x, y, z); + if (obj != null) + return obj; + } + } + return null; + } } \ No newline at end of file -- cgit v1.2.3