diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2017-12-20 23:39:49 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2017-12-20 23:39:49 +1000 |
commit | 5715a32d2901922503fd850f3a68503fb77467c3 (patch) | |
tree | 7e12520fbc23844e99493d55af4410a785538e35 /src/Java/gtPlusPlus/core/util | |
parent | 2a4795f65d98ff60a177d7d6a5552fd687d9f6e8 (diff) | |
download | GT5-Unofficial-5715a32d2901922503fd850f3a68503fb77467c3.tar.gz GT5-Unofficial-5715a32d2901922503fd850f3a68503fb77467c3.tar.bz2 GT5-Unofficial-5715a32d2901922503fd850f3a68503fb77467c3.zip |
- Disabled some logging.
% Minor Project Clean-up, added missing Override annotations to 100+ methods & removed pointless casts.
% Moved Logging to it's own class.
$ Fixed Multi-block handling of Pollution.
$ Fixed the GT 5.09 material enabler system. (From My Side, it's still borked on GTs).
+ Added a Dynamic Proxy invocation for IMaterialHandler.
+ Added an AutoMap data type, which is a Auto-incremental ID'd Hashmap wrapper.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
22 files changed, 330 insertions, 311 deletions
diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index f8ae3e4cba..ab11dccd4e 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -16,12 +16,8 @@ import java.util.Timer; import java.util.TimerTask; import org.apache.commons.lang3.EnumUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.relauncher.FMLRelaunchLog; import gregtech.GT_Mod; import gregtech.api.enums.Materials; import gregtech.api.enums.TC_Aspects; @@ -30,10 +26,10 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.proxy.ClientProxy; import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; @@ -73,7 +69,7 @@ public class Utils { static class ShortTimerTask extends TimerTask { @Override public void run() { - Utils.LOG_WARNING("Timer expired."); + Logger.WARNING("Timer expired."); } } @@ -109,47 +105,47 @@ public class Utils { // Adds in Compat for older GT Versions which Misspell aspects. try { if (EnumUtils.isValidEnum(TC_Aspects.class, "COGNITIO")) { - Utils.LOG_WARNING("TC Aspect found - " + aspect); + Logger.WARNING("TC Aspect found - " + aspect); returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITIO"), size); } else { - Utils.LOG_INFO("Fallback TC Aspect found - " + aspect + Logger.INFO("Fallback TC Aspect found - " + aspect + " - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITO"), size); } } catch (final NoSuchFieldError r) { - Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); + Logger.INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } } else if (aspect.toUpperCase().equals("EXANIMUS")) { // Adds in Compat for older GT Versions which Misspell aspects. try { if (EnumUtils.isValidEnum(TC_Aspects.class, "EXANIMUS")) { - Utils.LOG_WARNING("TC Aspect found - " + aspect); + Logger.WARNING("TC Aspect found - " + aspect); returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXANIMUS"), size); } else { - Utils.LOG_INFO("Fallback TC Aspect found - " + aspect + Logger.INFO("Fallback TC Aspect found - " + aspect + " - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXAMINIS"), size); } } catch (final NoSuchFieldError r) { - Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); + Logger.INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } } else if (aspect.toUpperCase().equals("PRAECANTATIO")) { // Adds in Compat for older GT Versions which Misspell aspects. try { if (EnumUtils.isValidEnum(TC_Aspects.class, "PRAECANTATIO")) { - Utils.LOG_WARNING("TC Aspect found - " + aspect); + Logger.WARNING("TC Aspect found - " + aspect); returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTATIO"), size); } else { - Utils.LOG_INFO("Fallback TC Aspect found - " + aspect + Logger.INFO("Fallback TC Aspect found - " + aspect + " - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTIO"), size); } } catch (final NoSuchFieldError r) { - Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); + Logger.INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } } else { - Utils.LOG_WARNING("TC Aspect found - " + aspect); + Logger.WARNING("TC Aspect found - " + aspect); returnValue = new TC_AspectStack(TC_Aspects.valueOf(aspect), size); } @@ -175,73 +171,6 @@ public class Utils { || (target.getItemDamage() == input.getItemDamage()))); } - // Logging Functions - private static final Logger modLogger = makeLogger(); - - // Generate GT++ Logger - public static Logger makeLogger() { - final Logger gtPlusPlusLogger = LogManager.getLogger("GT++"); - return gtPlusPlusLogger; - } - - public static final Logger getLogger(){ - return modLogger; - } - - // Non-Dev Comments - public static void LOG_INFO(final String s) { - // if (CORE.DEBUG){ - modLogger.info(s); - // } - } - - // Non-Dev Comments - public static void LOG_MACHINE_INFO(final String s) { - - boolean localPlayer = false; - try { - if (ClientProxy.playerName != null){ - if (ClientProxy.playerName.toLowerCase().contains("draknyte1")){ - localPlayer = true; - } - } - } - catch (final Throwable t){ - - } - - if (CORE.ConfigSwitches.MACHINE_INFO || localPlayer) { - final String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); - modLogger.info("Machine Info: " + s + " | " + name1); - } - } - - // Developer Comments - public static void LOG_WARNING(final String s) { - if (CORE.DEBUG) { - modLogger.warn(s); - } - } - - // Errors - public static void LOG_ERROR(final String s) { - if (CORE.DEBUG) { - modLogger.fatal(s); - } - } - - // Developer Logger - public static void LOG_SPECIFIC_WARNING(final String whatToLog, final String msg, final int line) { - // if (!CORE.DEBUG){ - FMLLog.warning("GT++ |" + line + "| " + whatToLog + " | " + msg); - // } - } - - // Non-Dev Comments - public static void LOG_ASM(final String s) { - FMLRelaunchLog.info("", s); - } - //Register an event to both busses. public static void registerEvent(Object o){ MinecraftForge.EVENT_BUS.register(o); @@ -293,7 +222,7 @@ public class Utils { if (!currentWorld.isRemote) { try { correctTool = currentBlock.getHarvestTool(0); - Utils.LOG_WARNING(correctTool); + Logger.WARNING(correctTool); } catch (final NullPointerException e) { @@ -434,8 +363,8 @@ public class Utils { // System.out.println( "hex: " + Integer.toHexString( c.getRGB() & // 0xFFFFFF ) + " hex value:"+temp); temp = Utils.appenedHexNotationToString(String.valueOf(temp)); - Utils.LOG_WARNING("Made " + temp + " - Hopefully it's not a mess."); - Utils.LOG_WARNING("It will decode into " + Integer.decode(temp) + "."); + Logger.WARNING("Made " + temp + " - Hopefully it's not a mess."); + Logger.WARNING("It will decode into " + Integer.decode(temp) + "."); return Integer.decode(temp); } @@ -486,7 +415,7 @@ public class Utils { code = code + code + code; final int i = Integer.parseInt(code); hexColorMap.put(a, Integer.toHexString(0x1000000 | i).substring(1).toUpperCase()); - Utils.LOG_WARNING("" + Integer.toHexString(0x1000000 | i).substring(1).toUpperCase()); + Logger.WARNING("" + Integer.toHexString(0x1000000 | i).substring(1).toUpperCase()); } return hexColorMap; } @@ -517,7 +446,7 @@ public class Utils { public static Integer appenedHexNotationToInteger(final int hexAsStringOrInt) { final String hexChar = "0x"; String result; - Utils.LOG_WARNING(String.valueOf(hexAsStringOrInt)); + Logger.WARNING(String.valueOf(hexAsStringOrInt)); result = hexChar + String.valueOf(hexAsStringOrInt); return Integer.getInteger(result); } @@ -546,21 +475,21 @@ public class Utils { private static short cellID = 15; public static ItemStack createInternalNameAndFluidCell(final String s) { - Utils.LOG_WARNING("1"); + Logger.WARNING("1"); final InternalName yourName = EnumHelper.addEnum(InternalName.class, s, new Class[0], new Object[0]); - Utils.LOG_WARNING("2 " + yourName.name()); + Logger.WARNING("2 " + yourName.name()); final ItemCell item = (ItemCell) Ic2Items.cell.getItem(); - Utils.LOG_WARNING("3 " + item.getUnlocalizedName()); + Logger.WARNING("3 " + item.getUnlocalizedName()); try { - Utils.LOG_WARNING("4"); + Logger.WARNING("4"); final Class<? extends ItemCell> clz = item.getClass(); - Utils.LOG_WARNING("5 " + clz.getSimpleName()); + Logger.WARNING("5 " + clz.getSimpleName()); final Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); - Utils.LOG_WARNING("6 " + methode.getName()); + Logger.WARNING("6 " + methode.getName()); methode.setAccessible(true); - Utils.LOG_WARNING("7 " + methode.isAccessible()); + Logger.WARNING("7 " + methode.isAccessible()); final ItemStack temp = (ItemStack) methode.invoke(item, cellID++, yourName, new Block[0]); - Utils.LOG_WARNING("Successfully created " + temp.getDisplayName() + "s."); + Logger.WARNING("Successfully created " + temp.getDisplayName() + "s."); FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack(s.toLowerCase(), 1000), temp.copy(), Ic2Items.cell.copy()); ItemUtils.addItemToOreDictionary(temp.copy(), "cell" + s); @@ -572,21 +501,21 @@ public class Utils { } public static ItemStack createInternalNameAndFluidCellNoOreDict(final String s) { - Utils.LOG_WARNING("1"); + Logger.WARNING("1"); final InternalName yourName = EnumHelper.addEnum(InternalName.class, s, new Class[0], new Object[0]); - Utils.LOG_WARNING("2 " + yourName.name()); + Logger.WARNING("2 " + yourName.name()); final ItemCell item = (ItemCell) Ic2Items.cell.getItem(); - Utils.LOG_WARNING("3 " + item.getUnlocalizedName()); + Logger.WARNING("3 " + item.getUnlocalizedName()); try { - Utils.LOG_WARNING("4"); + Logger.WARNING("4"); final Class<? extends ItemCell> clz = item.getClass(); - Utils.LOG_WARNING("5 " + clz.getSimpleName()); + Logger.WARNING("5 " + clz.getSimpleName()); final Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); - Utils.LOG_WARNING("6 " + methode.getName()); + Logger.WARNING("6 " + methode.getName()); methode.setAccessible(true); - Utils.LOG_WARNING("7 " + methode.isAccessible()); + Logger.WARNING("7 " + methode.isAccessible()); final ItemStack temp = (ItemStack) methode.invoke(item, cellID++, yourName, new Block[0]); - Utils.LOG_WARNING("Successfully created " + temp.getDisplayName() + "s."); + Logger.WARNING("Successfully created " + temp.getDisplayName() + "s."); FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack(s.toLowerCase(), 1000), temp.copy(), Ic2Items.cell.copy()); // ItemUtils.addItemToOreDictionary(temp.copy(), "cell"+s); @@ -739,7 +668,7 @@ public class Utils { final float damage = material.vToolQuality; final int efficiency = material.vToolQuality; // int enchantability = material.mEnchantmentToolsLevel; - Utils.LOG_INFO("ToolMaterial stats for " + material.getLocalizedName() + " | harvestLevel:" + harvestLevel + Logger.INFO("ToolMaterial stats for " + material.getLocalizedName() + " | harvestLevel:" + harvestLevel + " | durability:" + durability + " | toolQuality:" + damage + " | toolSpeed:" + damage); final ToolMaterial temp = EnumHelper.addToolMaterial(name, harvestLevel, durability, efficiency, damage, 0); return temp; @@ -814,7 +743,7 @@ public class Utils { .append("'").toString()); NBTUtils.createIntegerTagCompound(rStack, "stats", "mMeta", vMeta); CORE.sBookList.put(aMapping, rStack); - Utils.LOG_INFO("Creating book: " + aTitle + " by " + aAuthor + ". Using Meta " + vMeta + "."); + Logger.INFO("Creating book: " + aTitle + " by " + aAuthor + ". Using Meta " + vMeta + "."); return GT_Utility.copy(new Object[] { rStack }); } diff --git a/src/Java/gtPlusPlus/core/util/array/AutoMap.java b/src/Java/gtPlusPlus/core/util/array/AutoMap.java new file mode 100644 index 0000000000..ea5e1dd25e --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/array/AutoMap.java @@ -0,0 +1,77 @@ +package gtPlusPlus.core.util.array; + +import java.io.Serializable; +import java.util.*; + +public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable { + + /** + * The Internal Map + */ + private Map<Integer, V> mInternalMap = new HashMap<Integer, V>(); + + /** + * The Internal ID + */ + private int mInternalID = 0; + private static final long serialVersionUID = 3771412318075131790L; + + @Override + public Iterator<V> iterator() { + return values().iterator(); + } + + public synchronized boolean setValue(V object){ + int mOriginalID = this.mInternalID; + put(object); + if (this.mInternalMap.get(mOriginalID).equals(object) || mOriginalID > this.mInternalID){ + return true; + } + else { + return false; + } + } + + public synchronized V put(V object){ + return set(object); + } + + public synchronized V set(V object){ + return mInternalMap.put(mInternalID++, object); + } + + public synchronized V get(int id){ + return mInternalMap.get(id); + } + + public synchronized Collection<V> values(){ + return mInternalMap.values(); + } + + public synchronized int size(){ + return mInternalMap.size(); + } + + public synchronized int hashcode(){ + return mInternalMap.hashCode(); + } + + public synchronized boolean containsKey(int key){ + return mInternalMap.containsKey(key); + } + + public synchronized boolean containsValue(V value){ + return mInternalMap.containsValue(value); + } + + public synchronized boolean isEmpty(){ + return mInternalMap.isEmpty(); + } + + public synchronized boolean clear(){ + this.mInternalID = 0; + this.mInternalMap.clear(); + return true; + } + +} diff --git a/src/Java/gtPlusPlus/core/util/debug/DEBUG_ITEM_ShapeSpawner.java b/src/Java/gtPlusPlus/core/util/debug/DEBUG_ITEM_ShapeSpawner.java index a35d2c26de..35c8f5caad 100644 --- a/src/Java/gtPlusPlus/core/util/debug/DEBUG_ITEM_ShapeSpawner.java +++ b/src/Java/gtPlusPlus/core/util/debug/DEBUG_ITEM_ShapeSpawner.java @@ -5,9 +5,9 @@ import static net.minecraftforge.event.entity.player.PlayerInteractEvent.Action. import java.util.List; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.BaseItemGeneric; -import gtPlusPlus.core.util.Utils; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -29,7 +29,7 @@ public class DEBUG_ITEM_ShapeSpawner extends BaseItemGeneric{ public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player){ if (!world.isRemote){ - Utils.LOG_INFO("Constructing the shape for the "+"VACUUM FREEZER"); + Logger.INFO("Constructing the shape for the "+"VACUUM FREEZER"); final Thread thread = new Thread(new DEBUG_TimerThread(world, player)); thread.start(); } diff --git a/src/Java/gtPlusPlus/core/util/debug/DEBUG_TimerThread.java b/src/Java/gtPlusPlus/core/util/debug/DEBUG_TimerThread.java index a0690c9440..778809b486 100644 --- a/src/Java/gtPlusPlus/core/util/debug/DEBUG_TimerThread.java +++ b/src/Java/gtPlusPlus/core/util/debug/DEBUG_TimerThread.java @@ -2,7 +2,7 @@ package gtPlusPlus.core.util.debug; import java.util.concurrent.TimeUnit; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.api.objects.Logger; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -28,9 +28,9 @@ public class DEBUG_TimerThread implements Runnable { final int stepX = Minecraft.getMinecraft().objectMouseOver.blockX; final int stepY = Minecraft.getMinecraft().objectMouseOver.blockY; final int stepZ = Minecraft.getMinecraft().objectMouseOver.blockZ; - Utils.LOG_INFO("Clicked on a Block @ "+"[X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"+" with xDir:"+xDir+" zDir:"+zDir); + Logger.INFO("Clicked on a Block @ "+"[X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"+" with xDir:"+xDir+" zDir:"+zDir); this.world.setBlock(stepX, stepY, stepZ, Blocks.bedrock,0,3); - Utils.LOG_INFO("Makng it Bedrock for future investment."); + Logger.INFO("Makng it Bedrock for future investment."); //for (int i = -1; i <= 1; i++) { //stepX = stepX+i; for (int i = stepX-1; i <= (stepX+1); i++){ @@ -44,12 +44,12 @@ public class DEBUG_TimerThread implements Runnable { //stepZ = stepZ+j; //for (int h = -1; h <= 1; h++) { //stepY = stepY+h; - Utils.LOG_INFO("Placing Block @ "+"[X:"+i+"][Y:"+h+"][Z:"+j+"]"+" with xDir:"+xDir+" zDir:"+zDir); + Logger.INFO("Placing Block @ "+"[X:"+i+"][Y:"+h+"][Z:"+j+"]"+" with xDir:"+xDir+" zDir:"+zDir); if ((h != 0) || ((((xDir + i) != 0) || ((zDir + j) != 0)) && ((i != 0) || (j != 0)))) { this.world.setBlock(i, h, j, Blocks.stone,0,3); } else { - Utils.LOG_INFO("Not even sure what this is for, but I got here."); + Logger.INFO("Not even sure what this is for, but I got here."); } try { TimeUnit.MILLISECONDS.sleep(500); diff --git a/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java b/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java index 76336d4298..288ca2e2cc 100644 --- a/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java +++ b/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java @@ -1,6 +1,6 @@ package gtPlusPlus.core.util.enchanting; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.api.objects.Logger; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -78,7 +78,7 @@ public class EnchantingUtils { //Xp Fluids public static FluidStack getMobEssence(final int amount){ - Utils.LOG_WARNING("Trying to get a fluid stack of Mob Essence."); + Logger.WARNING("Trying to get a fluid stack of Mob Essence."); try { return FluidRegistry.getFluidStack("mobessence", amount).copy(); } @@ -89,7 +89,7 @@ public class EnchantingUtils { } public static FluidStack getLiquidXP(final int amount){ - Utils.LOG_WARNING("Trying to get a fluid stack of Liquid XP."); + Logger.WARNING("Trying to get a fluid stack of Liquid XP."); try { return FluidRegistry.getFluidStack("xpjuice", amount).copy(); } diff --git a/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java b/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java index 611c7fe897..444f35a46f 100644 --- a/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java +++ b/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java @@ -4,6 +4,7 @@ import gregtech.api.enums.Dyes; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.fluids.GenericFluid; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.item.base.cell.BaseItemCell; @@ -26,7 +27,7 @@ import net.minecraftforge.fluids.IFluidContainerItem; public class FluidUtils { public static FluidStack getFluidStack(final String fluidName, final int amount){ - Utils.LOG_WARNING("Trying to get a fluid stack of "+fluidName); + Logger.WARNING("Trying to get a fluid stack of "+fluidName); try { return FluidRegistry.getFluidStack(fluidName, amount).copy(); } @@ -37,7 +38,7 @@ public class FluidUtils { } public static FluidStack getFluidStack(final FluidStack vmoltenFluid, final int fluidAmount) { - Utils.LOG_WARNING("Trying to get a fluid stack of "+vmoltenFluid.getFluid().getName()); + Logger.WARNING("Trying to get a fluid stack of "+vmoltenFluid.getFluid().getName()); try { return FluidRegistry.getFluidStack(vmoltenFluid.getFluid().getName(), fluidAmount).copy(); } @@ -47,7 +48,7 @@ public class FluidUtils { } public static FluidStack getFluidStack(final Fluid vFluid, final int fluidAmount) { - Utils.LOG_WARNING("Trying to get a fluid stack of "+vFluid.getName()); + Logger.WARNING("Trying to get a fluid stack of "+vFluid.getName()); try { return FluidRegistry.getFluidStack(vFluid.getName(), fluidAmount).copy(); } @@ -57,7 +58,7 @@ public class FluidUtils { } public static FluidStack[] getFluidStackArray(final String fluidName, final int amount){ - Utils.LOG_WARNING("Trying to get a fluid stack of "+fluidName); + Logger.WARNING("Trying to get a fluid stack of "+fluidName); try { final FluidStack[] singleFluid = {FluidRegistry.getFluidStack(fluidName, amount)}; return singleFluid; @@ -69,7 +70,7 @@ public class FluidUtils { } public static FluidStack[] getFluidStackArray(final FluidStack fluidName, final int amount){ - Utils.LOG_WARNING("Trying to get a fluid stack of "+fluidName); + Logger.WARNING("Trying to get a fluid stack of "+fluidName); try { final FluidStack[] singleFluid = {FluidRegistry.getFluidStack(fluidName.getLocalizedName(), amount)}; return singleFluid; @@ -244,13 +245,13 @@ public class FluidUtils { if (aMaterial.getLocalizedName().toLowerCase().contains("clay") || (aMaterial.getComposites().size()>1) || aMaterial.getLocalizedName().toLowerCase().contains("wrought")){ return null; } - Utils.LOG_INFO("Generating a "+aMaterial.getLocalizedName()+" Plasma Cell"); + Logger.INFO("Generating a "+aMaterial.getLocalizedName()+" Plasma Cell"); if (aMaterial.vComponentCount != 1){ - Utils.LOG_INFO("Compound made from: "); + Logger.INFO("Compound made from: "); for (final MaterialStack x : aMaterial.getComposites()){ - Utils.LOG_INFO(x.getStackMaterial().getLocalizedName()); + Logger.INFO(x.getStackMaterial().getLocalizedName()); } - Utils.LOG_INFO("Material is a composite, not generating plasma."); + Logger.INFO("Material is a composite, not generating plasma."); return null; } @@ -410,7 +411,7 @@ public class FluidUtils { public final static Fluid generateFluid(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA){ if ((FluidUtils.getFluidStack("molten"+"."+unlocalizedName.toLowerCase(), 1) == null) && (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dust"+Utils.sanitizeString(localizedName), 1) != null)){ - Utils.LOG_WARNING("Generating our own fluid."); + Logger.WARNING("Generating our own fluid."); //Generate a Cell if we need to if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+unlocalizedName, 1) == null){ @@ -439,7 +440,7 @@ public class FluidUtils { ); return gtFluid; } - Utils.LOG_INFO("FLUID GENERATION FAILED FOR "+localizedName); + Logger.INFO("FLUID GENERATION FAILED FOR "+localizedName); return null; } @@ -452,7 +453,7 @@ public class FluidUtils { dustStack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dust"+Utils.sanitizeString(localizedName), 1); } if ((FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1) == null)/* && ((dustStack != null) || (dustStack2 != null))*/){ - Utils.LOG_WARNING("Generating our own fluid."); + Logger.WARNING("Generating our own fluid."); //Generate a Cell if we need to if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+unlocalizedName, 1) == null){ @@ -494,14 +495,14 @@ public class FluidUtils { return gtFluid; } - Utils.LOG_INFO("FLUID GENERATION FAILED FOR "+localizedName); + Logger.INFO("FLUID GENERATION FAILED FOR "+localizedName); return null; } public final static Fluid generateFluidNoPrefix(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA){ Fluid gtFluid; if (FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1) == null){ - Utils.LOG_WARNING("Generating our own fluid."); + Logger.WARNING("Generating our own fluid."); gtFluid = FluidUtils.addGTFluidNoPrefix( unlocalizedName, localizedName, diff --git a/src/Java/gtPlusPlus/core/util/geo/GeoUtils.java b/src/Java/gtPlusPlus/core/util/geo/GeoUtils.java index e1dba3b22d..84528e0cd5 100644 --- a/src/Java/gtPlusPlus/core/util/geo/GeoUtils.java +++ b/src/Java/gtPlusPlus/core/util/geo/GeoUtils.java @@ -5,7 +5,7 @@ import java.net.*; import org.apache.http.client.utils.URIBuilder; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.networking.NetworkUtils; public class GeoUtils { @@ -19,7 +19,7 @@ public class GeoUtils { return "Offline."; } } catch (Throwable T){ - Utils.LOG_INFO("Failed to initialise GeoUtils."); + Logger.INFO("Failed to initialise GeoUtils."); return "Failed."; } } @@ -78,7 +78,7 @@ public class GeoUtils { return result; //Catch block for bad connection } catch (IOException e) { - Utils.LOG_INFO("Method 1 - Failed."); + Logger.INFO("Method 1 - Failed."); } //Secondary method @@ -87,19 +87,19 @@ public class GeoUtils { return r.replaceAll("(\\r|\\n)", ""); //Catch block for bad connection } catch (java.io.IOException e) { - Utils.LOG_INFO("Method 2 - Failed."); + Logger.INFO("Method 2 - Failed."); } } //Catch block for all the Bad URI/URL building catch (URISyntaxException | MalformedURLException e1) { if (e1 instanceof URISyntaxException){ - Utils.LOG_INFO("Bad URI Syntax for builder."); + Logger.INFO("Bad URI Syntax for builder."); } else { - Utils.LOG_INFO("Malformed URL."); + Logger.INFO("Malformed URL."); } - Utils.LOG_INFO("Country Check - Failed."); + Logger.INFO("Country Check - Failed."); } return "Error getting users Country. "+ipAddress; } diff --git a/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java b/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java index 8ba355d57f..9bc5ee804d 100644 --- a/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java +++ b/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java @@ -3,23 +3,23 @@ package gtPlusPlus.core.util.gregtech.recipehandlers; import java.lang.reflect.Method; import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; import net.minecraft.item.ItemStack; public final class GregtechRecipe { public LibraryProxy ourProxy; public GregtechRecipe(){ - Utils.LOG_INFO("Initializing a recipe handler for different versions of Gregtech 5."); + Logger.INFO("Initializing a recipe handler for different versions of Gregtech 5."); try { if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ this.ourProxy = new LibProxy1(); - Utils.LOG_INFO("Selecting GT 5.7/5.8 Recipe Set"); + Logger.INFO("Selecting GT 5.7/5.8 Recipe Set"); } if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ this.ourProxy = new LibProxy2(); - Utils.LOG_INFO("Selecting GT 5.9 Recipe Set"); + Logger.INFO("Selecting GT 5.9 Recipe Set"); } } catch (final NoSuchMethodException e) { this.ourProxy = null; @@ -27,7 +27,7 @@ public final class GregtechRecipe { } public boolean addSmeltingAndAlloySmeltingRecipe(final ItemStack aInput, final ItemStack aOutput) { - Utils.LOG_WARNING("Adding a GT Furnace/Alloy Smelter Recipe"+"| Input:"+aInput.getDisplayName()+" | Output:"+aOutput.getDisplayName()+" |"); + Logger.WARNING("Adding a GT Furnace/Alloy Smelter Recipe"+"| Input:"+aInput.getDisplayName()+" | Output:"+aOutput.getDisplayName()+" |"); return this.ourProxy.addSmeltingAndAlloySmeltingRecipe(aInput, aOutput); } @@ -47,7 +47,7 @@ class LibProxy1 extends LibraryProxy { @Override public boolean addSmeltingAndAlloySmeltingRecipe(final ItemStack aInput, final ItemStack aOutput) { try { - Utils.LOG_INFO("Trying with Gt 5.7/5.8 Method."); + Logger.INFO("Trying with Gt 5.7/5.8 Method."); return (boolean) this.m1.invoke(null, aInput, aOutput); } catch (final Exception e) { throw new RuntimeException(e); @@ -65,7 +65,7 @@ class LibProxy2 extends LibraryProxy { @Override public boolean addSmeltingAndAlloySmeltingRecipe(final ItemStack aInput, final ItemStack aOutput) { try { - Utils.LOG_INFO("Trying with Gt 5.9 Method."); + Logger.INFO("Trying with Gt 5.9 Method."); return (boolean) this.m2.invoke(null, aInput, aOutput, true); } catch (final Exception e) { throw new RuntimeException(e); diff --git a/src/Java/gtPlusPlus/core/util/inventory/InventoryUtils.java b/src/Java/gtPlusPlus/core/util/inventory/InventoryUtils.java index 51ae393c06..779f9b14c1 100644 --- a/src/Java/gtPlusPlus/core/util/inventory/InventoryUtils.java +++ b/src/Java/gtPlusPlus/core/util/inventory/InventoryUtils.java @@ -20,7 +20,7 @@ public class InventoryUtils { { for (int i1 = 0; i1 < ((IInventory) tileentity).getSizeInventory(); ++i1) { - ItemStack itemstack = (ItemStack) ((IInventory) tileentity).getStackInSlot(i1); + ItemStack itemstack = ((IInventory) tileentity).getStackInSlot(i1); if (itemstack != null) { @@ -38,11 +38,11 @@ public class InventoryUtils { } itemstack.stackSize -= j1; - entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); float f3 = 0.05F; - entityitem.motionX = (double)((float)mRandom.nextGaussian() * f3); - entityitem.motionY = (double)((float)mRandom.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = (double)((float)mRandom.nextGaussian() * f3); + entityitem.motionX = (float)mRandom.nextGaussian() * f3; + entityitem.motionY = (float)mRandom.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)mRandom.nextGaussian() * f3; if (itemstack.hasTagCompound()) { diff --git a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java index c212afda2f..098cb3e953 100644 --- a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java @@ -11,6 +11,7 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.base.BasicSpawnEgg; import gtPlusPlus.core.item.base.dusts.BaseItemDust; @@ -115,7 +116,7 @@ public class ItemUtils { GT_OreDictUnificator.registerOre(oreDictName, new ItemStack(itemStackWithMeta.getItem()));*/ } } catch (final NullPointerException e) { - Utils.LOG_ERROR(itemName+" not found. [NULL]"); + Logger.ERROR(itemName+" not found. [NULL]"); } } @@ -123,7 +124,7 @@ public class ItemUtils { try { GT_OreDictUnificator.registerOre(oreDictName, stack); } catch (final NullPointerException e) { - Utils.LOG_ERROR(stack.getDisplayName()+" not registered. [NULL]"); + Logger.ERROR(stack.getDisplayName()+" not registered. [NULL]"); } } @@ -144,7 +145,7 @@ public class ItemUtils { } return null; } catch (final NullPointerException e) { - Utils.LOG_ERROR(itemName+" not found. [NULL]"); + Logger.ERROR(itemName+" not found. [NULL]"); return null; } } @@ -167,7 +168,7 @@ public class ItemUtils { } return null; } catch (final NullPointerException e) { - Utils.LOG_ERROR(FQRN+" not found. [NULL]"); + Logger.ERROR(FQRN+" not found. [NULL]"); return null; } } @@ -180,7 +181,7 @@ public class ItemUtils { } Item em = item; final Item em1 = item; - Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + Logger.WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); if (em1 != null){ if (null == em){ em = em1; @@ -282,11 +283,11 @@ public class ItemUtils { public static ItemStack getItemStackOfAmountFromOreDictNoBroken(final String oredictName, final int amount){ if (CORE.DEBUG){ - Utils.LOG_WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(1)); - Utils.LOG_WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(2)); - Utils.LOG_WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(3)); - Utils.LOG_WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(4)); - Utils.LOG_WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(5)); + Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(1)); + Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(2)); + Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(3)); + Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(4)); + Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(5)); } try{ @@ -309,7 +310,7 @@ public class ItemUtils { } } } - Utils.LOG_WARNING(oredictName+" was not valid."); + Logger.WARNING(oredictName+" was not valid."); return null; } catch (final Throwable t){ @@ -324,7 +325,7 @@ public class ItemUtils { return returnValue.copy(); } } - Utils.LOG_WARNING(material+" was not valid."); + Logger.WARNING(material+" was not valid."); return null; } @@ -400,20 +401,20 @@ public class ItemUtils { } public static MultiPickaxeBase generateMultiPick(final boolean GT_Durability, final ToolMaterial customMaterial, final String name, final int durability, final short[] rgba, final Object enchantment){ - Utils.LOG_WARNING("Generating a Multi-Pick out of "+name); + Logger.WARNING("Generating a Multi-Pick out of "+name); final short[] rgb = rgba; int dur = customMaterial.getMaxUses(); - Utils.LOG_WARNING("Determined durability for "+name+" is "+dur); + Logger.WARNING("Determined durability for "+name+" is "+dur); if (GT_Durability){ dur = durability*100; - Utils.LOG_WARNING("Using gregtech durability value, "+name+" is now "+dur+"."); + Logger.WARNING("Using gregtech durability value, "+name+" is now "+dur+"."); } else if (dur <= 0){ dur = durability; - Utils.LOG_WARNING("Determined durability too low, "+name+" is now "+dur+" based on the GT material durability."); + Logger.WARNING("Determined durability too low, "+name+" is now "+dur+" based on the GT material durability."); } if (dur <= 0){ - Utils.LOG_WARNING("Still too low, "+name+" will now go unused."); + Logger.WARNING("Still too low, "+name+" will now go unused."); return null; } @@ -437,7 +438,7 @@ public class ItemUtils { if (MP_Redstone.isValid){ return MP_Redstone; } - Utils.LOG_WARNING("Pickaxe was not valid."); + Logger.WARNING("Pickaxe was not valid."); return null; } @@ -457,20 +458,20 @@ public class ItemUtils { } public static MultiSpadeBase generateMultiShovel(final boolean GT_Durability, final ToolMaterial customMaterial, final String name, final int durability, final short[] rgba){ - Utils.LOG_WARNING("Generating a Multi-Spade out of "+name); + Logger.WARNING("Generating a Multi-Spade out of "+name); final short[] rgb = rgba; int dur = customMaterial.getMaxUses(); - Utils.LOG_WARNING("Determined durability for "+name+" is "+dur); + Logger.WARNING("Determined durability for "+name+" is "+dur); if (GT_Durability){ dur = durability*100; - Utils.LOG_WARNING("Using gregtech durability value, "+name+" is now "+dur+"."); + Logger.WARNING("Using gregtech durability value, "+name+" is now "+dur+"."); } else if (dur <= 0){ dur = durability; - Utils.LOG_WARNING("Determined durability too low, "+name+" is now "+dur+" based on the GT material durability."); + Logger.WARNING("Determined durability too low, "+name+" is now "+dur+" based on the GT material durability."); } if (dur <= 0){ - Utils.LOG_WARNING("Still too low, "+name+" will now go unused."); + Logger.WARNING("Still too low, "+name+" will now go unused."); return null; } final MultiSpadeBase MP_Redstone = new MultiSpadeBase( diff --git a/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java index 66c991ce99..48279a91d9 100644 --- a/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java @@ -1,19 +1,14 @@ package gtPlusPlus.core.util.materials; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.List; import org.apache.commons.lang3.reflect.FieldUtils; import gregtech.api.enums.*; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.StringUtils; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; @@ -217,6 +212,7 @@ public class MaterialUtils { }*/ + @SuppressWarnings("deprecation") public static String getMaterialName(Materials mat){ String mName; try { @@ -231,26 +227,4 @@ public class MaterialUtils { return mName; } - public static boolean tryEnableMaterial(Materials mMaterial){ - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - return false; - } - return ReflectionUtils.setField(mMaterial, "mHasParentMod", true); - } - - public static boolean tryEnableMaterialPart(OrePrefixes prefix, Materials mMaterial){ - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - return false; - } - try { - Method enableComponent = Class.forName("gregtech.api.enums.OrePrefixes").getDeclaredMethod("enableComponent", Materials.class); - enableComponent.invoke(prefix, mMaterial); - return true; - } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException e) { - Utils.LOG_INFO("Failed to enabled "+prefix.mRegularLocalName+" for "+mMaterial.mDefaultLocalName); - } - return false; - } - } diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 3361591ce8..adb5548f1d 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -4,6 +4,7 @@ import java.util.Map; import java.util.Random; import gregtech.api.enums.GT_Values; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.objects.XSTR; @@ -315,10 +316,10 @@ public class MathUtils { temp = "0F0F0F"; } - Utils.LOG_WARNING("Operating with "+temp); + Logger.WARNING("Operating with "+temp); temp = Utils.appenedHexNotationToString(String.valueOf(temp)); - Utils.LOG_WARNING("Made "+temp+" - Hopefully it's not a mess."); - Utils.LOG_WARNING("It will decode into "+Integer.decode(temp)+"."); + Logger.WARNING("Made "+temp+" - Hopefully it's not a mess."); + Logger.WARNING("It will decode into "+Integer.decode(temp)+"."); return Integer.decode(temp); } diff --git a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java index 5d9da4da1e..2e8e29c372 100644 --- a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java +++ b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java @@ -2,7 +2,7 @@ package gtPlusPlus.core.util.nbt; import baubles.api.BaubleType; import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.array.Pair; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -115,7 +115,7 @@ public class ModularArmourUtils { } public static void setBaubleType(ItemStack aStack, BT aMod) { - Utils.LOG_INFO("Changing bauble type."); + Logger.INFO("Changing bauble type."); NBTTagCompound tNBT = NBTUtils.getNBT(aStack); if (aMod != null) { tNBT.setInteger("mBaubleType", aMod.getID()); diff --git a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java index 31d00efc94..58d47eb0fa 100644 --- a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java +++ b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java @@ -7,7 +7,7 @@ import java.util.Map; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.entity.Entity; @@ -210,11 +210,11 @@ public class NBTUtils { Map<?, ?> mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); if (mInternalMap != null) { for (Map.Entry<?, ?> e : mInternalMap.entrySet()) { - Utils.LOG_INFO("Key: " + e.getKey().toString() + " | Value: " + e.getValue()); + Logger.INFO("Key: " + e.getKey().toString() + " | Value: " + e.getValue()); } return true; } else { - Utils.LOG_INFO("Data map reflected from NBTTagCompound was not valid."); + Logger.INFO("Data map reflected from NBTTagCompound was not valid."); return false; } } @@ -408,7 +408,7 @@ public class NBTUtils { Map<?, ?> mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); if (mInternalMap != null) { for (Map.Entry<?, ?> e : mInternalMap.entrySet()) { - Utils.LOG_INFO("Key: " + e.getKey().toString() + " | Value: " + e.getValue().toString()); + Logger.INFO("Key: " + e.getKey().toString() + " | Value: " + e.getValue().toString()); if (e.getValue().getClass() == String.class){ createStringTagCompound(aStack, "mEntityTag", (String) e.getKey(), (String) e.getValue()); } diff --git a/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java b/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java index b09b1a1056..ce2888ef29 100644 --- a/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java +++ b/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java @@ -4,7 +4,7 @@ import java.io.*; import java.net.*; import java.util.Enumeration; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.api.objects.Logger; public class NetworkUtils { @@ -26,13 +26,13 @@ public class NetworkUtils { return tempLine; } catch (final MalformedURLException e) { - Utils.LOG_INFO("Bad URL for Version Check."); + Logger.INFO("Bad URL for Version Check."); } catch (final IOException e) { - Utils.LOG_INFO("IOException during Version Check."); + Logger.INFO("IOException during Version Check."); } } - Utils.LOG_INFO("Network Not Available during Version Check."); + Logger.INFO("Network Not Available during Version Check."); return "offline"; } @@ -50,11 +50,11 @@ public class NetworkUtils { return true; } else { - Utils.LOG_INFO("No sites responded to network connectivity test."); + Logger.INFO("No sites responded to network connectivity test."); } } else { - Utils.LOG_INFO("Network Adapter was not valid."); + Logger.INFO("Network Adapter was not valid."); } } catch (SocketException e) {} diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerCache.java b/src/Java/gtPlusPlus/core/util/player/PlayerCache.java index c397e0f12f..5d4581910c 100644 --- a/src/Java/gtPlusPlus/core/util/player/PlayerCache.java +++ b/src/Java/gtPlusPlus/core/util/player/PlayerCache.java @@ -3,8 +3,8 @@ package gtPlusPlus.core.util.player; import java.io.*; import java.util.*; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; @@ -18,12 +18,12 @@ public class PlayerCache { if (cache != null){ CORE.PlayerCache = PlayerCache.readPropertiesFileAsMap(); - Utils.LOG_INFO("Loaded PlayerCache.dat"); + Logger.INFO("Loaded PlayerCache.dat"); } } catch (final Exception e) { - Utils.LOG_INFO("Failed to initialise PlayerCache.dat"); + Logger.INFO("Failed to initialise PlayerCache.dat"); PlayerCache.createPropertiesFile("PLAYER_", "DATA"); //e.printStackTrace(); } @@ -36,7 +36,7 @@ public class PlayerCache { props.setProperty(playerName+" ", playerUUIDasString); final OutputStream out = new FileOutputStream(cache); props.store(out, "Player Cache."); - Utils.LOG_INFO("PlayerCache.dat created for future use."); + Logger.INFO("PlayerCache.dat created for future use."); out.close(); } catch (final Exception e ) { @@ -71,11 +71,11 @@ public class PlayerCache { oos.writeObject(playerInfo); oos.close(); fos.close(); - Utils.LOG_INFO("Serialized Player data saved in PlayerCache.dat"); + Logger.INFO("Serialized Player data saved in PlayerCache.dat"); } catch (final IOException e) { - Utils.LOG_INFO("No PlayerCache file found, creating one."); + Logger.INFO("No PlayerCache file found, creating one."); createPropertiesFile(playerName, playerUUIDasString); } } @@ -136,11 +136,11 @@ public class PlayerCache { return null; }catch(final ClassNotFoundException c) { - Utils.LOG_INFO("Class not found"); + Logger.INFO("Class not found"); c.printStackTrace(); return null; } - Utils.LOG_WARNING("Deserialized PlayerCache.."); + Logger.WARNING("Deserialized PlayerCache.."); return map; } diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java index 306e3ca6b5..32488f074d 100644 --- a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java +++ b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java @@ -24,7 +24,7 @@ public class PlayerUtils { final List<EntityPlayer> i = new ArrayList<>(); final Iterator<EntityPlayerMP> iterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator(); while (iterator.hasNext()) { - i.add((EntityPlayer) (iterator.next())); + i.add((iterator.next())); } for (final EntityPlayer temp : i) { if (temp.getDisplayName().toLowerCase().equals(name.toLowerCase())){ diff --git a/src/Java/gtPlusPlus/core/util/player/UtilsMining.java b/src/Java/gtPlusPlus/core/util/player/UtilsMining.java index d52dd7ee88..4f0402a18e 100644 --- a/src/Java/gtPlusPlus/core/util/player/UtilsMining.java +++ b/src/Java/gtPlusPlus/core/util/player/UtilsMining.java @@ -1,6 +1,6 @@ package gtPlusPlus.core.util.player; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.api.objects.Logger; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -35,7 +35,7 @@ public class UtilsMining { } else { - Utils.LOG_WARNING("Incorrect Tool for mining this block."); + Logger.WARNING("Incorrect Tool for mining this block."); } } } catch (final NullPointerException e){ @@ -179,29 +179,29 @@ public class UtilsMining { try { blockClass = block.getClass().toString().toLowerCase(); - Utils.LOG_WARNING(blockClass); + Logger.WARNING(blockClass); if (blockClass.toLowerCase().contains(LIQUID)){ - Utils.LOG_WARNING(block.toString()+" is a Liquid."); + Logger.WARNING(block.toString()+" is a Liquid."); return false; } else if (blockClass.toLowerCase().contains(ORE)){ - Utils.LOG_WARNING(block.toString()+" is an Ore."); + Logger.WARNING(block.toString()+" is an Ore."); return true; } else if (block.getHarvestLevel(world.getBlockMetadata(xyz[0], xyz[1], xyz[2])) >= miningLevel){ - Utils.LOG_WARNING(block.toString()+" is minable."); + Logger.WARNING(block.toString()+" is minable."); return true; } else if (blockClass.toLowerCase().contains(AIR)){ - Utils.LOG_WARNING(block.toString()+" is Air."); + Logger.WARNING(block.toString()+" is Air."); return false; } else if (blockClass.toLowerCase().contains(BLOCK)){ - Utils.LOG_WARNING(block.toString()+" is a block of some kind."); + Logger.WARNING(block.toString()+" is a block of some kind."); return false; } else { - Utils.LOG_WARNING(block.toString()+" is mystery."); + Logger.WARNING(block.toString()+" is mystery."); return false; } } diff --git a/src/Java/gtPlusPlus/core/util/recipe/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/recipe/RecipeUtils.java index 7d094b7a43..cdb8255231 100644 --- a/src/Java/gtPlusPlus/core/util/recipe/RecipeUtils.java +++ b/src/Java/gtPlusPlus/core/util/recipe/RecipeUtils.java @@ -4,11 +4,11 @@ import java.util.*; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.recipe.shapeless.ShapelessUtils; import net.minecraft.item.Item; @@ -23,15 +23,15 @@ public class RecipeUtils { final ArrayList<Object> validSlots = new ArrayList<>(); if (resultItem == null){ - Utils.LOG_WARNING("Found a recipe with an invalid output, yet had a valid inputs. Skipping."); + Logger.WARNING("Found a recipe with an invalid output, yet had a valid inputs. Skipping."); return false; } if ((slot_1 == null) && (slot_2 == null) && (slot_3 == null) && (slot_4 == null) && (slot_5 == null) && (slot_6 == null) && (slot_7 == null) && (slot_8 == null) && (slot_9 == null)){ - Utils.LOG_WARNING("Found a recipe with 0 inputs, yet had a valid output."); - Utils.LOG_WARNING("Error found while adding a recipe for: "+resultItem.getDisplayName()+" | Please report this issue on Github."); + Logger.WARNING("Found a recipe with 0 inputs, yet had a valid output."); + Logger.WARNING("Error found while adding a recipe for: "+resultItem.getDisplayName()+" | Please report this issue on Github."); RegistrationHandler.recipesFailed++; return false; } @@ -39,35 +39,35 @@ public class RecipeUtils { //Utils.LOG_WARNING("Trying to add a recipe for "+resultItem.toString()); String a,b,c,d,e,f,g,h,i; if (slot_1 == null){ a = " ";} else { a = "1";validSlots.add('1');validSlots.add(slot_1);} - Utils.LOG_WARNING(a); + Logger.WARNING(a); if (slot_2 == null){ b = " ";} else { b = "2";validSlots.add('2');validSlots.add(slot_2);} - Utils.LOG_WARNING(b); + Logger.WARNING(b); if (slot_3 == null){ c = " ";} else { c = "3";validSlots.add('3');validSlots.add(slot_3);} - Utils.LOG_WARNING(c); + Logger.WARNING(c); if (slot_4 == null){ d = " ";} else { d = "4";validSlots.add('4');validSlots.add(slot_4);} - Utils.LOG_WARNING(d); + Logger.WARNING(d); if (slot_5 == null){ e = " ";} else { e = "5";validSlots.add('5');validSlots.add(slot_5);} - Utils.LOG_WARNING(e); + Logger.WARNING(e); if (slot_6 == null){ f = " ";} else { f = "6";validSlots.add('6');validSlots.add(slot_6);} - Utils.LOG_WARNING(f); + Logger.WARNING(f); if (slot_7 == null){ g = " ";} else { g = "7";validSlots.add('7');validSlots.add(slot_7);} - Utils.LOG_WARNING(g); + Logger.WARNING(g); if (slot_8 == null){ h = " ";} else { h = "8";validSlots.add('8');validSlots.add(slot_8);} - Utils.LOG_WARNING(h); + Logger.WARNING(h); if (slot_9 == null){ i = " ";} else { i = "9";validSlots.add('9');validSlots.add(slot_9);} - Utils.LOG_WARNING(i); + Logger.WARNING(i); - Utils.LOG_ERROR("_______"); + Logger.ERROR("_______"); final String lineOne = a+b+c; - Utils.LOG_ERROR("|"+a+"|"+b+"|"+c+"|"); - Utils.LOG_ERROR("_______"); + Logger.ERROR("|"+a+"|"+b+"|"+c+"|"); + Logger.ERROR("_______"); final String lineTwo = d+e+f; - Utils.LOG_ERROR("|"+d+"|"+e+"|"+f+"|"); - Utils.LOG_ERROR("_______"); + Logger.ERROR("|"+d+"|"+e+"|"+f+"|"); + Logger.ERROR("_______"); final String lineThree = g+h+i; - Utils.LOG_ERROR("|"+g+"|"+h+"|"+i+"|"); - Utils.LOG_ERROR("_______"); + Logger.ERROR("|"+g+"|"+h+"|"+i+"|"); + Logger.ERROR("_______"); validSlots.add(0, lineOne); validSlots.add(1, lineTwo); @@ -79,26 +79,26 @@ public class RecipeUtils { if (advancedLog){ int j = 0; final int l = validSlots.size(); - Utils.LOG_WARNING("l:"+l); + Logger.WARNING("l:"+l); while (j <= l) { - Utils.LOG_WARNING("j:"+j); + Logger.WARNING("j:"+j); if (j <= 2){ - Utils.LOG_WARNING("ArrayList Values: "+validSlots.get(j)); - Utils.LOG_WARNING("Adding 1."); + Logger.WARNING("ArrayList Values: "+validSlots.get(j)); + Logger.WARNING("Adding 1."); j++; } else if (j == l){ - Utils.LOG_WARNING("Done iteration."); + Logger.WARNING("Done iteration."); break; } else { - Utils.LOG_WARNING("ArrayList Values: '"+validSlots.get(j)+"' "+validSlots.get(j+1)); + Logger.WARNING("ArrayList Values: '"+validSlots.get(j)+"' "+validSlots.get(j+1)); if (j < (l-2)){ - Utils.LOG_WARNING("Adding 2."); + Logger.WARNING("Adding 2."); j=j+2; } else { - Utils.LOG_WARNING("Done iteration."); + Logger.WARNING("Done iteration."); break; } } @@ -124,7 +124,7 @@ public class RecipeUtils { //k.getClass(); //k.printStackTrace(); //k.getLocalizedMessage(); - Utils.LOG_INFO("@@@: Invalid Recipe detected for: "+resultItem.getUnlocalizedName()); + Logger.INFO("@@@: Invalid Recipe detected for: "+resultItem.getUnlocalizedName()); if (!COMPAT_HANDLER.areInitItemsLoaded){ RegistrationHandler.recipesFailed++; } @@ -140,35 +140,35 @@ public class RecipeUtils { final ArrayList<Object> validSlots = new ArrayList<>(); - Utils.LOG_WARNING("Trying to add a recipe for "+Output.toString()); + Logger.WARNING("Trying to add a recipe for "+Output.toString()); String a,b,c,d,e,f,g,h,i; if (slot_1 == null){ a = " ";} else { a = "1";validSlots.add('1');validSlots.add(slot_1);} - Utils.LOG_WARNING(a); + Logger.WARNING(a); if (slot_2 == null){ b = " ";} else { b = "2";validSlots.add('2');validSlots.add(slot_2);} - Utils.LOG_WARNING(b); + Logger.WARNING(b); if (slot_3 == null){ c = " ";} else { c = "3";validSlots.add('3');validSlots.add(slot_3);} - Utils.LOG_WARNING(c); + Logger.WARNING(c); if (slot_4 == null){ d = " ";} else { d = "4";validSlots.add('4');validSlots.add(slot_4);} - Utils.LOG_WARNING(d); + Logger.WARNING(d); if (slot_5 == null){ e = " ";} else { e = "5";validSlots.add('5');validSlots.add(slot_5);} - Utils.LOG_WARNING(e); + Logger.WARNING(e); if (slot_6 == null){ f = " ";} else { f = "6";validSlots.add('6');validSlots.add(slot_6);} - Utils.LOG_WARNING(f); + Logger.WARNING(f); if (slot_7 == null){ g = " ";} else { g = "7";validSlots.add('7');validSlots.add(slot_7);} - Utils.LOG_WARNING(g); + Logger.WARNING(g); if (slot_8 == null){ h = " ";} else { h = "8";validSlots.add('8');validSlots.add(slot_8);} - Utils.LOG_WARNING(h); + Logger.WARNING(h); if (slot_9 == null){ i = " ";} else { i = "9";validSlots.add('9');validSlots.add(slot_9);} - Utils.LOG_WARNING(i); + Logger.WARNING(i); - Utils.LOG_ERROR("_______"); - Utils.LOG_ERROR("|"+a+"|"+b+"|"+c+"|"); - Utils.LOG_ERROR("_______"); - Utils.LOG_ERROR("|"+d+"|"+e+"|"+f+"|"); - Utils.LOG_ERROR("_______"); - Utils.LOG_ERROR("|"+g+"|"+h+"|"+i+"|"); - Utils.LOG_ERROR("_______"); + Logger.ERROR("_______"); + Logger.ERROR("|"+a+"|"+b+"|"+c+"|"); + Logger.ERROR("_______"); + Logger.ERROR("|"+d+"|"+e+"|"+f+"|"); + Logger.ERROR("_______"); + Logger.ERROR("|"+g+"|"+h+"|"+i+"|"); + Logger.ERROR("_______"); validSlots.add(0, a); validSlots.add(1, b); @@ -184,7 +184,7 @@ public class RecipeUtils { //GameRegistry.addRecipe(new ShapelessOreRecipe(Output, outputAmount), (Object[]) validSlots.toArray()); GameRegistry.addRecipe(new ShapelessOreRecipe(Output, validSlots.toArray())); //GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2}); - Utils.LOG_WARNING("Success! Added a recipe for "+Output.getDisplayName()); + Logger.WARNING("Success! Added a recipe for "+Output.getDisplayName()); RegistrationHandler.recipesSuccess++; } catch(final RuntimeException k){ @@ -192,7 +192,7 @@ public class RecipeUtils { k.getClass(); k.printStackTrace(); k.getLocalizedMessage(); - Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+Output.getUnlocalizedName()); + Logger.WARNING("@@@: Invalid Recipe detected for: "+Output.getUnlocalizedName()); RegistrationHandler.recipesFailed++; } @@ -201,7 +201,7 @@ public class RecipeUtils { } public static void recipeBuilder(final Object[] array, final ItemStack outPut) { - Utils.LOG_SPECIFIC_WARNING("object Array - recipeBuilder", "Attempting to build a recipe using an object array as an input, splitting it, then running the normal recipeBuilder() method.", 396); + Logger.SPECIFIC_WARNING("object Array - recipeBuilder", "Attempting to build a recipe using an object array as an input, splitting it, then running the normal recipeBuilder() method.", 396); Object a=null; Object b=null; Object c=null; @@ -263,10 +263,10 @@ public class RecipeUtils { if ((x instanceof Item) || (x instanceof ItemStack)){ if (x instanceof Item){ final ItemStack r = new ItemStack((Item) x); - Utils.LOG_WARNING("Removing Recipe for "+r.getUnlocalizedName()); + Logger.WARNING("Removing Recipe for "+r.getUnlocalizedName()); } else { - Utils.LOG_WARNING("Removing Recipe for "+((ItemStack) x).getUnlocalizedName()); + Logger.WARNING("Removing Recipe for "+((ItemStack) x).getUnlocalizedName()); } if (x instanceof ItemStack){ final Item r = ((ItemStack) x).getItem(); @@ -274,49 +274,49 @@ public class RecipeUtils { x = r; } else { - Utils.LOG_WARNING("Recipe removal failed - Tell Alkalus."); + Logger.WARNING("Recipe removal failed - Tell Alkalus."); return false; } } if (RecipeUtils.attemptRecipeRemoval((Item) x)){ - Utils.LOG_WARNING("Recipe removal successful"); + Logger.WARNING("Recipe removal successful"); return true; } - Utils.LOG_WARNING("Recipe removal failed - Tell Alkalus."); + Logger.WARNING("Recipe removal failed - Tell Alkalus."); return false; } return false; } private static boolean attemptRecipeRemoval(final Item I){ - Utils.LOG_WARNING("Create list of recipes."); + Logger.WARNING("Create list of recipes."); final List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList(); final Iterator<IRecipe> items = recipes.iterator(); - Utils.LOG_WARNING("Begin list iteration."); + Logger.WARNING("Begin list iteration."); while (items.hasNext()) { final ItemStack is = items.next().getRecipeOutput(); if ((is != null) && (is.getItem() == I)){ items.remove(); - Utils.LOG_WARNING("Remove a recipe with "+I.getUnlocalizedName()+" as output."); + Logger.WARNING("Remove a recipe with "+I.getUnlocalizedName()+" as output."); continue; } } - Utils.LOG_WARNING("All recipes should be gone?"); + Logger.WARNING("All recipes should be gone?"); if (!items.hasNext()){ - Utils.LOG_WARNING("We iterated once, let's try again to double check."); + Logger.WARNING("We iterated once, let's try again to double check."); final Iterator<IRecipe> items2 = recipes.iterator(); while (items2.hasNext()) { final ItemStack is = items2.next().getRecipeOutput(); if ((is != null) && (is.getItem() == I)){ items.remove(); - Utils.LOG_WARNING("REMOVING MISSED RECIPE - RECHECK CONSTRUCTORS"); + Logger.WARNING("REMOVING MISSED RECIPE - RECHECK CONSTRUCTORS"); return true; } } - Utils.LOG_WARNING("Should be all gone now after double checking, so return true."); + Logger.WARNING("Should be all gone now after double checking, so return true."); return true; } - Utils.LOG_WARNING("Return false, because something went wrong."); + Logger.WARNING("Return false, because something went wrong."); return false; } @@ -394,7 +394,7 @@ public class RecipeUtils { } else { if (OutputItem != null){ - Utils.LOG_WARNING("Adding recipe for "+OutputItem.getDisplayName()+" failed. Error 62."); + Logger.WARNING("Adding recipe for "+OutputItem.getDisplayName()+" failed. Error 62."); } RegistrationHandler.recipesFailed++; return false; @@ -404,7 +404,7 @@ public class RecipeUtils { public static boolean addShapedGregtechRecipe(final Object[] inputs, ItemStack output){ if (inputs.length != 9){ - Utils.LOG_WARNING("Input array for "+output.getDisplayName()+" does not equal 9. "+inputs.length+" is the actual size."); + Logger.WARNING("Input array for "+output.getDisplayName()+" does not equal 9. "+inputs.length+" is the actual size."); RegistrationHandler.recipesFailed++; return false; @@ -413,17 +413,17 @@ public class RecipeUtils { for (int x=0;x<9;x++){ if (inputs[x] == null){ inputs[x] = " "; - Utils.LOG_WARNING("Input slot "+x+" changed from NULL to a blank space."); + Logger.WARNING("Input slot "+x+" changed from NULL to a blank space."); } else if (!(inputs[x] instanceof ItemStack) && !(inputs[x] instanceof String)){ if (output != null){ - Utils.LOG_WARNING("Invalid Item inserted into inputArray. Item:"+output.getDisplayName()+" has a bad recipe. Please report to Alkalus."); + Logger.WARNING("Invalid Item inserted into inputArray. Item:"+output.getDisplayName()+" has a bad recipe. Please report to Alkalus."); RegistrationHandler.recipesFailed++; return false; } else { - Utils.LOG_WARNING("Output is Null for a recipe. Report to Alkalus."); + Logger.WARNING("Output is Null for a recipe. Report to Alkalus."); output = ItemUtils.getItemStackOfAmountFromOreDict("sadibasdkjnad", 1); } } @@ -442,13 +442,13 @@ public class RecipeUtils { 'G', inputs[6], 'H', inputs[7], 'I', inputs[8]})){ - Utils.LOG_WARNING("Success! Added a recipe for "+output.getDisplayName()); + Logger.WARNING("Success! Added a recipe for "+output.getDisplayName()); RegistrationHandler.recipesSuccess++; return true; } else { if (output != null){ - Utils.LOG_WARNING("Adding recipe for "+output.getDisplayName()+" failed. Error 61."); + Logger.WARNING("Adding recipe for "+output.getDisplayName()+" failed. Error 61."); } return false; } @@ -458,7 +458,7 @@ public class RecipeUtils { //Catch Invalid Recipes if (inputItems.length > 9 || inputItems.length < 1){ if (OutputItem != null){ - Utils.LOG_WARNING("Invalid input array for shapeless recipe, which should output "+OutputItem.getDisplayName()); + Logger.WARNING("Invalid input array for shapeless recipe, which should output "+OutputItem.getDisplayName()); } return false; } diff --git a/src/Java/gtPlusPlus/core/util/recipe/shapeless/ShapelessUtils.java b/src/Java/gtPlusPlus/core/util/recipe/shapeless/ShapelessUtils.java index d0ad6d3361..29ca257134 100644 --- a/src/Java/gtPlusPlus/core/util/recipe/shapeless/ShapelessUtils.java +++ b/src/Java/gtPlusPlus/core/util/recipe/shapeless/ShapelessUtils.java @@ -2,7 +2,7 @@ package gtPlusPlus.core.util.recipe.shapeless; import java.util.ArrayList; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.api.objects.Logger; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -34,11 +34,11 @@ public class ShapelessUtils { { if ((object1 == null)) { - Utils.LOG_INFO(("Invalid shapeless input, ignoring!")); + Logger.INFO(("Invalid shapeless input, ignoring!")); } else if (!(object1 instanceof Block) && (object1 != null)) { - Utils.LOG_INFO(("Invalid shapeless recipe!")); + Logger.INFO(("Invalid shapeless recipe!")); return false; } else { diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 5f7a60f546..bc92328595 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -1,7 +1,6 @@ package gtPlusPlus.core.util.reflect; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; +import java.lang.reflect.*; import java.net.URL; import java.util.HashSet; import java.util.Scanner; @@ -9,8 +8,8 @@ import java.util.Scanner; import org.apache.commons.lang3.reflect.FieldUtils; import gregtech.GT_Mod; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; import net.minecraft.client.Minecraft; public class ReflectionUtils { @@ -21,8 +20,10 @@ public class ReflectionUtils { } catch (final NoSuchFieldException e) { final Class<?> superClass = clazz.getSuperclass(); if (superClass == null) { + Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+"."); throw e; } + Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+". Trying super class."); return getField(superClass, fieldName); } } @@ -45,8 +46,10 @@ public class ReflectionUtils { field.setAccessible(true); return (V) field.get(object); } catch (final NoSuchFieldException e) { + Logger.REFLECTION("getField("+object.toString()+", "+fieldName+") failed."); clazz = clazz.getSuperclass(); } catch (final Exception e) { + Logger.REFLECTION("getField("+object.toString()+", "+fieldName+") failed."); throw new IllegalStateException(e); } } @@ -62,8 +65,10 @@ public class ReflectionUtils { field.set(object, fieldValue); return true; } catch (final NoSuchFieldException e) { + Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); clazz = clazz.getSuperclass(); } catch (final Exception e) { + Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); throw new IllegalStateException(e); } } @@ -71,7 +76,7 @@ public class ReflectionUtils { } public static boolean becauseIWorkHard(){ - /* TODO: fix this stuff \u002a\u002f\u0066\u0069\u006e\u0061\u006c\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u003c\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u003b\u0009\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u0020\u003d\u0020\u0043\u006c\u0069\u0065\u006e\u0074\u0050\u0072\u006f\u0078\u0079\u0046\u0069\u006e\u0064\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0047\u0054\u005f\u004d\u006f\u0064\u002e\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0029\u003b\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0052\u0065\u0066\u006c\u0065\u0063\u0074\u0069\u0076\u0065\u004f\u0070\u0065\u0072\u0061\u0074\u0069\u006f\u006e\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0031\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u0020\u003d\u0020\u006e\u0075\u006c\u006c\u003b\u000a\u0009\u0009\u0009\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0049\u004e\u0046\u004f\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u006f\u0062\u0074\u0061\u0069\u006e\u0065\u0064\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u006f\u0066\u0020\u0061\u0020\u0063\u006c\u0069\u0065\u006e\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0028\u006e\u0065\u0077\u0020\u0055\u0052\u004c\u0028\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0067\u0072\u0065\u0067\u0074\u0065\u0063\u0068\u002e\u006f\u0076\u0065\u0072\u006d\u0069\u006e\u0064\u0064\u006c\u0031\u002e\u0063\u006f\u006d\u002f\u0063\u006f\u006d\u002f\u0067\u0072\u0065\u0067\u006f\u0072\u0069\u0075\u0073\u0074\u002f\u0067\u0072\u0065\u0067\u0074\u0065\u0063\u0068\u002f\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0072\u006c\u0069\u0073\u0074\u002e\u0074\u0078\u0074\u0022\u0029\u002e\u006f\u0070\u0065\u006e\u0053\u0074\u0072\u0065\u0061\u006d\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0009\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0057\u0041\u0052\u004e\u0049\u004e\u0047\u0028\u0022\u0054\u0072\u0079\u0069\u006e\u0067\u0020\u0074\u006f\u0020\u0062\u0075\u0069\u006c\u0064\u0020\u0061\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u0068\u0061\u0073\u004e\u0065\u0078\u0074\u004c\u0069\u006e\u0065\u0028\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0074\u004e\u0061\u006d\u0065\u0020\u003d\u0020\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u006e\u0065\u0078\u0074\u004c\u0069\u006e\u0065\u0028\u0029\u003b\u000a\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0074\u004e\u0061\u006d\u0065\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0074\u004e\u0061\u006d\u0065\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0009\u002f\u002f\u0041\u0064\u0064\u0020\u004d\u0079\u0073\u0065\u006c\u0066\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0022\u0064\u0072\u0061\u006b\u006e\u0079\u0074\u0065\u0031\u0022\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0057\u0041\u0052\u004e\u0049\u004e\u0047\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0022\u0064\u0072\u0061\u006b\u006e\u0079\u0074\u0065\u0031\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0009\u002f\u002f\u0041\u0064\u0064\u0020\u0074\u0068\u0065\u0020\u0063\u0061\u0070\u0065\u0064\u0020\u0074\u0065\u0073\u0074\u0020\u0068\u0065\u0072\u006f\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0043\u004f\u0052\u0045\u002e\u0044\u0045\u0056\u0045\u004e\u0056\u0029\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0020\u003d\u0020\u004d\u0069\u006e\u0065\u0063\u0072\u0061\u0066\u0074\u002e\u0067\u0065\u0074\u004d\u0069\u006e\u0065\u0063\u0072\u0061\u0066\u0074\u0028\u0029\u002e\u0067\u0065\u0074\u0053\u0065\u0073\u0073\u0069\u006f\u006e\u0028\u0029\u002e\u0067\u0065\u0074\u0055\u0073\u0065\u0072\u006e\u0061\u006d\u0065\u0028\u0029\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0049\u004e\u0046\u004f\u0028\u0022\u0046\u006f\u0075\u006e\u0064\u0020\u0022\u002b\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0057\u0041\u0052\u004e\u0049\u004e\u0047\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u007d\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u0009\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0074\u0029\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0049\u004e\u0046\u004f\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u0061\u0064\u0064\u0069\u006e\u0067\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0069\u006e\u0020\u0063\u0075\u0072\u0072\u0065\u006e\u0074\u0020\u0065\u006e\u0076\u0069\u0072\u006f\u006e\u006d\u0065\u006e\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u000a\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u0063\u006c\u006f\u0073\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0057\u0041\u0052\u004e\u0049\u004e\u0047\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u0067\u0065\u0074\u0074\u0069\u006e\u0067\u0020\u0074\u0068\u0065\u0020\u0077\u0065\u0062\u0020\u006c\u0069\u0073\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u007d\u0009\u0009\u000a\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u0009\u0046\u0069\u0065\u006c\u0064\u0055\u0074\u0069\u006c\u0073\u002e\u0077\u0072\u0069\u0074\u0065\u0046\u0069\u0065\u006c\u0064\u0028\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u002c\u0020\u0022\u006d\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u0022\u002c\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002c\u0020\u0074\u0072\u0075\u0065\u0029\u003b\u000a\u0009\u0009\u0009\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0057\u0041\u0052\u004e\u0049\u004e\u0047\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0064\u0020\u0068\u0061\u0073\u0068\u0073\u0065\u0074\u0020\u0062\u0061\u0063\u006b\u0020\u0069\u006e\u0074\u006f\u0020\u0074\u0068\u0065\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u002e\u0022\u0029\u003b\u0020\u0020\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0074\u0072\u0075\u0065\u003b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0049\u004e\u0046\u004f\u0028\u0022\u0052\u0065\u0066\u006c\u0065\u0063\u0074\u0069\u006f\u006e\u0020\u0069\u006e\u0074\u006f\u0020\u0061\u0063\u0074\u0069\u0076\u0065\u0020\u0063\u006c\u0069\u0065\u006e\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u0020\u0020\u0020\u0020\u0020\u0020\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u0020\u0020\u0009\u000a\u0009\u0009\u007d\u002f\u002a */ + /* TODO: fix this stuff \u002a\u002f\u0066\u0069\u006e\u0061\u006c\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u003c\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u003b\u0009\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u0020\u003d\u0020\u0043\u006c\u0069\u0065\u006e\u0074\u0050\u0072\u006f\u0078\u0079\u0046\u0069\u006e\u0064\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0047\u0054\u005f\u004d\u006f\u0064\u002e\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0029\u003b\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0052\u0065\u0066\u006c\u0065\u0063\u0074\u0069\u0076\u0065\u004f\u0070\u0065\u0072\u0061\u0074\u0069\u006f\u006e\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0031\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u0020\u003d\u0020\u006e\u0075\u006c\u006c\u003b\u000a\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u006f\u0062\u0074\u0061\u0069\u006e\u0065\u0064\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u006f\u0066\u0020\u0061\u0020\u0063\u006c\u0069\u0065\u006e\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0028\u006e\u0065\u0077\u0020\u0055\u0052\u004c\u0028\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0067\u0072\u0065\u0067\u0074\u0065\u0063\u0068\u002e\u006f\u0076\u0065\u0072\u006d\u0069\u006e\u0064\u0064\u006c\u0031\u002e\u0063\u006f\u006d\u002f\u0063\u006f\u006d\u002f\u0067\u0072\u0065\u0067\u006f\u0072\u0069\u0075\u0073\u0074\u002f\u0067\u0072\u0065\u0067\u0074\u0065\u0063\u0068\u002f\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0072\u006c\u0069\u0073\u0074\u002e\u0074\u0078\u0074\u0022\u0029\u002e\u006f\u0070\u0065\u006e\u0053\u0074\u0072\u0065\u0061\u006d\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0054\u0072\u0079\u0069\u006e\u0067\u0020\u0074\u006f\u0020\u0062\u0075\u0069\u006c\u0064\u0020\u0061\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u0068\u0061\u0073\u004e\u0065\u0078\u0074\u004c\u0069\u006e\u0065\u0028\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0074\u004e\u0061\u006d\u0065\u0020\u003d\u0020\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u006e\u0065\u0078\u0074\u004c\u0069\u006e\u0065\u0028\u0029\u003b\u000a\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0074\u004e\u0061\u006d\u0065\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0074\u004e\u0061\u006d\u0065\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0009\u002f\u002f\u0041\u0064\u0064\u0020\u004d\u0079\u0073\u0065\u006c\u0066\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0022\u0064\u0072\u0061\u006b\u006e\u0079\u0074\u0065\u0031\u0022\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0022\u0064\u0072\u0061\u006b\u006e\u0079\u0074\u0065\u0031\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0009\u002f\u002f\u0041\u0064\u0064\u0020\u0074\u0068\u0065\u0020\u0063\u0061\u0070\u0065\u0064\u0020\u0074\u0065\u0073\u0074\u0020\u0068\u0065\u0072\u006f\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0043\u004f\u0052\u0045\u002e\u0044\u0045\u0056\u0045\u004e\u0056\u0029\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0020\u003d\u0020\u004d\u0069\u006e\u0065\u0063\u0072\u0061\u0066\u0074\u002e\u0067\u0065\u0074\u004d\u0069\u006e\u0065\u0063\u0072\u0061\u0066\u0074\u0028\u0029\u002e\u0067\u0065\u0074\u0053\u0065\u0073\u0073\u0069\u006f\u006e\u0028\u0029\u002e\u0067\u0065\u0074\u0055\u0073\u0065\u0072\u006e\u0061\u006d\u0065\u0028\u0029\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0046\u006f\u0075\u006e\u0064\u0020\u0022\u002b\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u007d\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u0009\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0074\u0029\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u0061\u0064\u0064\u0069\u006e\u0067\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0069\u006e\u0020\u0063\u0075\u0072\u0072\u0065\u006e\u0074\u0020\u0065\u006e\u0076\u0069\u0072\u006f\u006e\u006d\u0065\u006e\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u000a\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u0063\u006c\u006f\u0073\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u0067\u0065\u0074\u0074\u0069\u006e\u0067\u0020\u0074\u0068\u0065\u0020\u0077\u0065\u0062\u0020\u006c\u0069\u0073\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u007d\u0009\u0009\u000a\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u0009\u0046\u0069\u0065\u006c\u0064\u0055\u0074\u0069\u006c\u0073\u002e\u0077\u0072\u0069\u0074\u0065\u0046\u0069\u0065\u006c\u0064\u0028\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u002c\u0020\u0022\u006d\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u0022\u002c\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002c\u0020\u0074\u0072\u0075\u0065\u0029\u003b\u000a\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0064\u0020\u0068\u0061\u0073\u0068\u0073\u0065\u0074\u0020\u0062\u0061\u0063\u006b\u0020\u0069\u006e\u0074\u006f\u0020\u0074\u0068\u0065\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u002e\u0022\u0029\u003b\u0020\u0020\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0074\u0072\u0075\u0065\u003b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0052\u0065\u0066\u006c\u0065\u0063\u0074\u0069\u006f\u006e\u0020\u0069\u006e\u0074\u006f\u0020\u0061\u0063\u0074\u0069\u0076\u0065\u0020\u0063\u006c\u0069\u0065\u006e\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u0020\u0020\u0020\u0020\u0020\u0020\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u0020\u0020\u0009\u000a\u0009\u0009\u007d\u002f\u002a */ } public static boolean doesClassExist(final String classname) { @@ -162,6 +167,37 @@ public class ReflectionUtils { fieldA.setByte(clazz, newValue);*/ } + + public static boolean invoke(Object objectInstance, String methodName, Class[] parameters, Object[] values){ + if (objectInstance == null || methodName == null || parameters == null || values == null){ + Logger.REFLECTION("Null value when trying to Dynamically invoke "+methodName+" on an object of type: "+objectInstance.getClass().getName()); + return false; + } + Class mLocalClass = (objectInstance instanceof Class ? (Class) objectInstance : objectInstance.getClass()); + Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+mLocalClass.getCanonicalName()+"."); + try { + Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters); + if (mInvokingMethod != null){ + Logger.REFLECTION(methodName+" was not null."); + if ((boolean) mInvokingMethod.invoke(objectInstance, values)){ + Logger.REFLECTION("Successfully invoked "+methodName+"."); + return true; + } + else { + Logger.REFLECTION("Invocation failed for "+methodName+"."); + } + } + else { + Logger.REFLECTION(methodName+" is null."); + } + } + catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName()); + } + + Logger.REFLECTION("Invoke failed or did something wrong."); + return false; + } diff --git a/src/Java/gtPlusPlus/core/util/wrapper/var.java b/src/Java/gtPlusPlus/core/util/wrapper/var.java index 1b73d035bc..06de3cde73 100644 --- a/src/Java/gtPlusPlus/core/util/wrapper/var.java +++ b/src/Java/gtPlusPlus/core/util/wrapper/var.java @@ -1,7 +1,7 @@ package gtPlusPlus.core.util.wrapper; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.ItemUtils; import net.minecraft.item.ItemStack; @@ -23,7 +23,7 @@ public class var{ for (int i=0;i<input.length();i++) { if (input.charAt(i) == token) { input = input.replace(input.charAt(i), ' '); - Utils.LOG_WARNING("MATCH FOUND"); + Logger.WARNING("MATCH FOUND"); } input = input.replaceAll(" ", ""); } |