Class ReflectionUtils
java.lang.Object
fr.andross.banitem.utils.attributes.ReflectionUtils
Package utils that use the reflection api of java
- Version:
- 3.4
- Author:
- EpiCanard
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
asNMSCopy
(org.bukkit.inventory.ItemStack itemStack) Create an NMSItemStack from Bukkit ItemStackstatic <T> T
callMethodWithName
(Object obj, String name) Call the first method matching the namestatic <T> T
callMethodWithReturnType
(Object obj, Class<? extends T> returnType) Call the first method matching the returnType
-
Constructor Details
-
ReflectionUtils
public ReflectionUtils()
-
-
Method Details
-
asNMSCopy
public static Object asNMSCopy(@NotNull org.bukkit.inventory.ItemStack itemStack) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException, NoSuchMethodException Create an NMSItemStack from Bukkit ItemStack- Parameters:
itemStack
- Bukkit ItemStack to convert- Returns:
- Converted ItemStack
- Throws:
ClassNotFoundException
InvocationTargetException
IllegalAccessException
NoSuchMethodException
-
callMethodWithReturnType
public static <T> T callMethodWithReturnType(@NotNull Object obj, @NotNull Class<? extends T> returnType) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException Call the first method matching the returnType- Type Parameters:
T
- Return type- Parameters:
obj
- Object that contains the methodreturnType
- Return type class that must be returned by the method- Returns:
- The value returned by the call to the method
- Throws:
InvocationTargetException
IllegalAccessException
NoSuchMethodException
-
callMethodWithName
public static <T> T callMethodWithName(@NotNull Object obj, @NotNull String name) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException Call the first method matching the name- Type Parameters:
T
- Return type- Parameters:
obj
- Object that contains the methodname
- Name of method to call- Returns:
- The value returned by the call to the method
- Throws:
NoSuchMethodException
InvocationTargetException
IllegalAccessException
-