public class ReflectionUtils
extends java.lang.Object
| Constructor and Description |
|---|
ReflectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Class<?> |
getClass(PackageName path,
java.lang.String name)
Returns an OBC/NMS Class via Reflection
|
static java.lang.Class<?> |
getClass(java.lang.String name)
Shortcut for NMS Classes
|
static java.lang.reflect.Constructor<?> |
getConstructor(java.lang.Class<?> c,
java.lang.Class<?>... paramTypes)
Returns the Constructor of a Class with the specified Parameters
|
static java.lang.Object |
getEnumConstant(java.lang.Class<?> c,
java.lang.String name)
Returns a specific Enum Constant in an Enum
|
static java.util.List<?> |
getEnumConstants(java.lang.Class<?> c)
Returns all Enum Constants in an Enum
|
static java.lang.reflect.Field |
getField(java.lang.Class<?> c,
java.lang.String field)
Returns the Field of a Class
|
static java.lang.Object |
getFieldValue(java.lang.Object object,
java.lang.String field)
Returns the Value of a Field in an Object
|
static java.lang.Object |
getHandle(CraftObject type,
java.lang.Object object)
Returns an Instance of the NMS class for your Object
|
static java.lang.Class<?> |
getInnerClass(PackageName path,
java.lang.String name,
java.lang.String subname)
Returns a Class inside a Class
|
static java.lang.reflect.Method |
getMethod(java.lang.Class<?> c,
java.lang.String method)
Returns a certain Method in the specified Class
|
static java.lang.reflect.Method |
getMethod(java.lang.Class<?> c,
java.lang.String method,
java.lang.Class<?>... paramTypes)
Returns the Method with certain Parameters
|
static java.lang.String |
getVersion()
Returns the formatted Server Version usable for Reflection
|
static void |
sendPacket(org.bukkit.entity.Player p,
java.lang.Object packet)
Sends a Packet to the specified Player
|
static void |
setFieldValue(java.lang.Object object,
java.lang.String field,
java.lang.Object value)
Modifies a Field in an Object
|
static java.lang.Class<?>[] |
toPrimitiveTypeArray(java.lang.Class<?>... classes)
Converts the Classes to a Primitive Type Array
in order to be used as paramaters
|
static java.lang.Class<?>[] |
toPrimitiveTypeArray(java.lang.Object... objects)
Converts the Classes of the specified Objects
to a Primitive Type Array
in order to be used as paramaters
|
static java.lang.Class<?> |
tryClass(PackageName path,
java.lang.String... names)
Returns an OBC/NMS Class via Reflection
|
public static java.lang.reflect.Method getMethod(java.lang.Class<?> c,
java.lang.String method)
c - The Class in which the Method is inmethod - The Method you are looking forpublic static java.lang.reflect.Method getMethod(java.lang.Class<?> c,
java.lang.String method,
java.lang.Class<?>... paramTypes)
c - The Class in which the Method is inmethod - The Method you are looking forparamTypes - The Types of the Parameterspublic static java.lang.reflect.Field getField(java.lang.Class<?> c,
java.lang.String field)
throws java.lang.Exception
c - The Class conating this Fieldfield - The name of the Field you are looking forjava.lang.Exceptionpublic static void setFieldValue(java.lang.Object object,
java.lang.String field,
java.lang.Object value)
throws java.lang.Exception
object - The Object containing the Fieldfield - The Name of that Fieldvalue - The Value for that Fieldjava.lang.Exceptionpublic static java.lang.Object getFieldValue(java.lang.Object object,
java.lang.String field)
throws java.lang.Exception
object - The Object containing the Fieldfield - The Name of that Fieldjava.lang.Exceptionpublic static java.lang.Class<?>[] toPrimitiveTypeArray(java.lang.Class<?>... classes)
classes - The Types you want to convertpublic static java.lang.Class<?>[] toPrimitiveTypeArray(java.lang.Object... objects)
objects - The Types you want to convertpublic static java.lang.reflect.Constructor<?> getConstructor(java.lang.Class<?> c,
java.lang.Class<?>... paramTypes)
c - The Class containing the ConstructorparamTypes - The Parameters for that Constructorpublic static java.lang.Class<?> getClass(java.lang.String name)
throws java.lang.Exception
name - The Name of the Class you are looking forjava.lang.Exceptionpublic static java.lang.Object getHandle(CraftObject type, java.lang.Object object) throws java.lang.Exception
type - The Type of NMS Class you want to getobject - The Object you want to get the Handle ofjava.lang.Exceptionpublic static void sendPacket(org.bukkit.entity.Player p,
java.lang.Object packet)
throws java.lang.Exception
p - The Player you want to send the Packet topacket - The Packet you want to sendjava.lang.Exceptionpublic static java.lang.Class<?> getInnerClass(PackageName path, java.lang.String name, java.lang.String subname) throws java.lang.Exception
path - The Package in which the Class can be found inname - The Name of the Class your Inner class is located insubname - The Name of the inner Class you are looking forjava.lang.Exceptionpublic static java.lang.Class<?> getClass(PackageName path, java.lang.String name) throws java.lang.Exception
path - The Types of the Package you are targetingname - The Name of the Class you are looking forjava.lang.Exceptionpublic static java.lang.Class<?> tryClass(PackageName path, java.lang.String... names) throws java.lang.Exception
path - The Types of the Package you are targetingnames - The Names of the Classes you are looking forjava.lang.Exceptionpublic static java.lang.String getVersion()
public static java.util.List<?> getEnumConstants(java.lang.Class<?> c)
c - The Enum you are targetingpublic static java.lang.Object getEnumConstant(java.lang.Class<?> c,
java.lang.String name)
c - The Enum you are targetingname - The Name of the Constant you are targeting