Package dev.majek.pc.util
Class ReflectionUtil
- java.lang.Object
-
- dev.majek.pc.util.ReflectionUtil
-
public class ReflectionUtil extends Object
Useful utility for accessing net.minecraft.server or org.bukkit.craftbukkit classes/methods/fields.
-
-
Constructor Summary
Constructors Constructor Description ReflectionUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Object
getConnection(org.bukkit.entity.Player player)
Get a BukkitPlayer
players NMS playerConnection objectstatic Constructor<?>
getConstructor(Class<?> clazz, Class<?>... params)
Get a classes constructorstatic Field
getField(Class<?> clazz, String fieldName)
Get a field with a particular name from a classstatic Method
getMethod(Class<?> clazz, String methodName, Class<?>... params)
Get a method from a class that has the specific paramatersstatic Class<?>
getNMSClass(String nmsClassName)
Get an NMS Classstatic Class<?>
getOBCClass(String obcClassName)
Get a class from the org.bukkit.craftbukkit packagestatic String
getVersion()
Gets the version string for NMS and OBC class paths
-
-
-
Method Detail
-
getVersion
public static String getVersion()
Gets the version string for NMS and OBC class paths- Returns:
- The version string of OBC and NMS packages
-
getNMSClass
public static Class<?> getNMSClass(String nmsClassName)
Get an NMS Class- Parameters:
nmsClassName
- The name of the class- Returns:
- The class
-
getOBCClass
public static Class<?> getOBCClass(String obcClassName)
Get a class from the org.bukkit.craftbukkit package- Parameters:
obcClassName
- the path to the class- Returns:
- the found class at the specified path
-
getConnection
public static Object getConnection(org.bukkit.entity.Player player)
Get a BukkitPlayer
players NMS playerConnection object- Parameters:
player
- The player- Returns:
- The players connection
-
getConstructor
public static Constructor<?> getConstructor(Class<?> clazz, Class<?>... params)
Get a classes constructor- Parameters:
clazz
- The constructor classparams
- The parameters in the constructor- Returns:
- The constructor object
-
getMethod
public static Method getMethod(Class<?> clazz, String methodName, Class<?>... params)
Get a method from a class that has the specific paramaters- Parameters:
clazz
- The class we are searchingmethodName
- The name of the methodparams
- Any parameters that the method has- Returns:
- The method with appropriate paramaters
-
-