From c1bbee9f5f71dd82ca0aef2669d52a34b65fcc2d Mon Sep 17 00:00:00 2001 From: Jordan Byrne Date: Tue, 13 Mar 2018 21:41:03 +1000 Subject: $ Fixed TiCon not accepting GT++ Pyrotheum as a valid Smeltery Fuel. $ Fixed Recipe for the Shaft Extruder shape, which now requires Dark Steel, instead of Dark Iron. --- .../core/util/reflect/ReflectionUtils.java | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/Java/gtPlusPlus/core/util/reflect') diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index d17c861b77..882d16c232 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -203,6 +203,56 @@ public class ReflectionUtils { Logger.REFLECTION("Invoke failed or did something wrong."); return false; } + + public static boolean invokeVoid(Object objectInstance, String methodName, Class[] parameters, Object[] values){ + if (objectInstance == null || methodName == null || parameters == null || values == null){ + 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."); + mInvokingMethod.invoke(objectInstance, values); + Logger.REFLECTION("Successfully invoked "+methodName+"."); + return true; + } + 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; + } + + public static Object invokeNonBool(Object objectInstance, String methodName, Class[] parameters, Object[] values){ + if (objectInstance == null || methodName == null || parameters == null || values == null){ + 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."); + return mInvokingMethod.invoke(objectInstance, values); + } + 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 null; + } /* * @ if (isPresent("com.optionaldependency.DependencyClass")) { // This -- cgit