public final class Reflection
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
NMS_PREFIX |
static java.lang.String |
OBC_PREFIX |
static java.lang.String |
VERSION |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Class<?> |
getClass(java.lang.String lookupName)
Retrieve a class from its full name.
|
static ConstructorInvoker |
getConstructor(java.lang.Class<?> clazz,
java.lang.Class<?>... params)
Search for the first publically and privately defined constructor of the given name and parameter count.
|
static ConstructorInvoker |
getConstructor(java.lang.String className,
java.lang.Class<?>... params)
Search for the first publically and privately defined constructor of the given name and parameter count.
|
static java.lang.Class<?> |
getCraftBukkitClass(java.lang.String name)
Retrieve a class in the org.bukkit.craftbukkit.VERSION.* package.
|
static <T> FieldAccessor<T> |
getField(java.lang.Class<?> target,
java.lang.Class<T> fieldType,
int index)
Retrieve a field accessor for a specific field type and name.
|
static <T> FieldAccessor<T> |
getField(java.lang.Class<?> target,
java.lang.String name,
java.lang.Class<T> fieldType)
Retrieve a field accessor for a specific field type and name.
|
static <T> FieldAccessor<T> |
getField(java.lang.Class<?> target,
java.lang.String name,
int index) |
static <T> FieldAccessor<T> |
getField(java.lang.String className,
java.lang.Class<T> fieldType,
int index)
Retrieve a field accessor for a specific field type and name.
|
static <T> FieldAccessor<T> |
getField(java.lang.String className,
java.lang.String name,
java.lang.Class<T> fieldType)
Retrieve a field accessor for a specific field type and name.
|
static <T> FieldAccessor<T> |
getFieldSafe(java.lang.String className,
java.lang.Class<T> fieldType,
int index) |
static MethodInvoker |
getMethod(java.lang.Class<?> clazz,
java.lang.Class<?> returnType,
int index,
java.lang.Class<?>... params) |
static MethodInvoker |
getMethod(java.lang.Class<?> clazz,
int index,
java.lang.Class<?>... params) |
static MethodInvoker |
getMethod(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Class<?>... params)
Search for the first publicly and privately defined method of the given name and parameter count.
|
static MethodInvoker |
getMethod(java.lang.String className,
java.lang.String methodName,
java.lang.Class<?>... params)
Search for the first publicly and privately defined method of the given name and parameter count.
|
static java.lang.Class<?> |
getMinecraftClass(java.lang.String name)
Retrieve a class in the net.minecraft.server.VERSION.* package.
|
static MethodInvoker |
getTypedMethod(java.lang.Class<?> clazz,
int index,
java.lang.Class<?> returnType,
java.lang.Class<?>... params) |
static MethodInvoker |
getTypedMethod(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Class<?> returnType,
java.lang.Class<?>... params)
Search for the first publicly and privately defined method of the given name and parameter count.
|
static java.lang.Class<java.lang.Object> |
getUntypedClass(java.lang.String lookupName)
Retrieve a class from its full name, without knowing its type on compile time.
|
public static java.lang.String OBC_PREFIX
public static java.lang.String NMS_PREFIX
public static java.lang.String VERSION
public static <T> FieldAccessor<T> getField(java.lang.Class<?> target, java.lang.String name, java.lang.Class<T> fieldType)
target - - the target type.name - - the name of the field, or NULL to ignore.fieldType - - a compatible field type.public static <T> FieldAccessor<T> getField(java.lang.String className, java.lang.String name, java.lang.Class<T> fieldType)
className - - lookup name of the class, see getClass(String).name - - the name of the field, or NULL to ignore.fieldType - - a compatible field type.public static <T> FieldAccessor<T> getField(java.lang.Class<?> target, java.lang.Class<T> fieldType, int index)
target - - the target type.fieldType - - a compatible field type.index - - the number of compatible fields to skip.public static <T> FieldAccessor<T> getField(java.lang.String className, java.lang.Class<T> fieldType, int index)
className - - lookup name of the class, see getClass(String).fieldType - - a compatible field type.index - - the number of compatible fields to skip.public static <T> FieldAccessor<T> getFieldSafe(java.lang.String className, java.lang.Class<T> fieldType, int index)
public static <T> FieldAccessor<T> getField(java.lang.Class<?> target, java.lang.String name, int index)
public static MethodInvoker getMethod(java.lang.String className, java.lang.String methodName, java.lang.Class<?>... params)
className - - lookup name of the class, see getClass(String).methodName - - the method name, or NULL to skip.params - - the expected parameters.java.lang.IllegalStateException - If we cannot find this method.public static MethodInvoker getMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?>... params)
clazz - - a class to start with.methodName - - the method name, or NULL to skip.params - - the expected parameters.java.lang.IllegalStateException - If we cannot find this method.public static MethodInvoker getMethod(java.lang.Class<?> clazz, int index, java.lang.Class<?>... params)
public static MethodInvoker getMethod(java.lang.Class<?> clazz, java.lang.Class<?> returnType, int index, java.lang.Class<?>... params)
public static MethodInvoker getTypedMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?> returnType, java.lang.Class<?>... params)
clazz - - a class to start with.methodName - - the method name, or NULL to skip.returnType - - the expected return type, or NULL to ignore.params - - the expected parameters.java.lang.IllegalStateException - If we cannot find this method.public static MethodInvoker getTypedMethod(java.lang.Class<?> clazz, int index, java.lang.Class<?> returnType, java.lang.Class<?>... params)
public static ConstructorInvoker getConstructor(java.lang.String className, java.lang.Class<?>... params)
className - - lookup name of the class, see getClass(String).params - - the expected parameters.java.lang.IllegalStateException - If we cannot find this method.public static ConstructorInvoker getConstructor(java.lang.Class<?> clazz, java.lang.Class<?>... params)
clazz - - a class to start with.params - - the expected parameters.java.lang.IllegalStateException - If we cannot find this method.public static java.lang.Class<java.lang.Object> getUntypedClass(java.lang.String lookupName)
This is useful when looking up fields by a NMS or OBC type.
lookupName - - the class name with variables.#getClass()} for more information.public static java.lang.Class<?> getClass(java.lang.String lookupName)
Strings enclosed with curly brackets - such as {TEXT} - will be replaced according to the following table:
| Variable | Content |
|---|---|
| {nms} | Actual package name of net.minecraft.server.VERSION |
| {obc} | Actual pacakge name of org.bukkit.craftbukkit.VERSION |
| {version} | The current Minecraft package VERSION, if any. |
lookupName - - the class name with variables.java.lang.IllegalArgumentException - If a variable or class could not be found.public static java.lang.Class<?> getMinecraftClass(java.lang.String name)
name - - the name of the class, excluding the package.java.lang.IllegalArgumentException - If the class doesn't exist.public static java.lang.Class<?> getCraftBukkitClass(java.lang.String name)
name - - the name of the class, excluding the package.java.lang.IllegalArgumentException - If the class doesn't exist.