cc.funkemunky.api.tinyprotocol.reflection

## Class Reflection

- java.lang.Object
- - cc.funkemunky.api.tinyprotocol.reflection.Reflection

    public final class Reflection
    extends java.lang.Object

An utility class that simplifies reflection in Bukkit plugins.

### Field Summary

Fields
`static java.lang.String` `NMS_PREFIX`
`static java.lang.String` `OBC_PREFIX`
`static java.lang.String` `VERSION`

### Method Summary

All Methods Static Methods Concrete Methods
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### OBC_PREFIX

    public static java.lang.String OBC_PREFIX

#### NMS_PREFIX

    public static java.lang.String NMS_PREFIX

#### VERSION

    public static java.lang.String VERSION

### Method Detail

#### getField

    public 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.

Parameters:
  `target` - - the target type.
  `name` - - the name of the field, or NULL to ignore.
  `fieldType` - - a compatible field type.
Returns:
  The field accessor.

#### getField

    public 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.

Parameters:
  `className` - - lookup name of the class, see `getClass(String)`.
  `name` - - the name of the field, or NULL to ignore.
  `fieldType` - - a compatible field type.
Returns:
  The field accessor.

#### getField

    public 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.

Parameters:
  `target` - - the target type.
  `fieldType` - - a compatible field type.
  `index` - - the number of compatible fields to skip.
Returns:
  The field accessor.

#### getField

    public 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.

Parameters:
  `className` - - lookup name of the class, see `getClass(String)`.
  `fieldType` - - a compatible field type.
  `index` - - the number of compatible fields to skip.
Returns:
  The field accessor.

#### getFieldSafe

    public static <T> FieldAccessor<T> getFieldSafe(java.lang.String className,
                                                    java.lang.Class<T> fieldType,
                                                    int index)

#### getField

    public static <T> FieldAccessor<T> getField(java.lang.Class<?> target,
                                                java.lang.String name,
                                                int index)

#### getMethod

    public 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.

Parameters:
  `className` - - lookup name of the class, see `getClass(String)`.
  `methodName` - - the method name, or NULL to skip.
  `params` - - the expected parameters.
Returns:
  An object that invokes this specific method.
Throws:
  `java.lang.IllegalStateException` - If we cannot find this method.

#### getMethod

    public 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.

Parameters:
  `clazz` - - a class to start with.
  `methodName` - - the method name, or NULL to skip.
  `params` - - the expected parameters.
Returns:
  An object that invokes this specific method.
Throws:
  `java.lang.IllegalStateException` - If we cannot find this method.

#### getMethod

    public static MethodInvoker getMethod(java.lang.Class<?> clazz,
                                          int index,
                                          java.lang.Class<?>... params)

#### getMethod

    public static MethodInvoker getMethod(java.lang.Class<?> clazz,
                                          java.lang.Class<?> returnType,
                                          int index,
                                          java.lang.Class<?>... params)

#### getTypedMethod

    public 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.

Parameters:
  `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.
Returns:
  An object that invokes this specific method.
Throws:
  `java.lang.IllegalStateException` - If we cannot find this method.

#### getTypedMethod

    public static MethodInvoker getTypedMethod(java.lang.Class<?> clazz,
                                               int index,
                                               java.lang.Class<?> returnType,
                                               java.lang.Class<?>... params)

#### getConstructor

    public 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.

Parameters:
  `className` - - lookup name of the class, see `getClass(String)`.
  `params` - - the expected parameters.
Returns:
  An object that invokes this constructor.
Throws:
  `java.lang.IllegalStateException` - If we cannot find this method.

#### getConstructor

    public 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.

Parameters:
  `clazz` - - a class to start with.
  `params` - - the expected parameters.
Returns:
  An object that invokes this constructor.
Throws:
  `java.lang.IllegalStateException` - If we cannot find this method.

#### getUntypedClass

    public 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.

This is useful when looking up fields by a NMS or OBC type.

Parameters:
  `lookupName` - - the class name with variables.
Returns:
  The class.
See Also:
  `#getClass()} for more information.`

#### getClass

    public static java.lang.Class<?> getClass(java.lang.String lookupName)

Retrieve a class from its full name.

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.

Parameters:
  `lookupName` - - the class name with variables.
Returns:
  The looked up class.
Throws:
  `java.lang.IllegalArgumentException` - If a variable or class could not be found.

#### getMinecraftClass

    public static java.lang.Class<?> getMinecraftClass(java.lang.String name)

Retrieve a class in the net.minecraft.server.VERSION.* package.

Parameters:
  `name` - - the name of the class, excluding the package.
Throws:
  `java.lang.IllegalArgumentException` - If the class doesn't exist.

#### getCraftBukkitClass

    public static java.lang.Class<?> getCraftBukkitClass(java.lang.String name)

Retrieve a class in the org.bukkit.craftbukkit.VERSION.* package.

Parameters:
  `name` - - the name of the class, excluding the package.
Throws:
  `java.lang.IllegalArgumentException` - If the class doesn't exist.