Class Reflection
- java.lang.Object
-
- com.djrapitops.plan.utilities.java.Reflection
-
public final class Reflection extends java.lang.Object
An utility class that simplifies reflection in Bukkit plugins.Modified Reflection utility from LagMonitor plugin. https://github.com/games647/LagMonitor/blob/master/src/main/java/com/github/games647/lagmonitor/traffic/Reflection.java
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Reflection.FieldAccessor<T>
An interface for retrieving the field content.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Class<?>
getCraftBukkitClass(java.lang.String name)
Retrieve a class in the org.bukkit.craftbukkit.VERSION.* package.static <T> Reflection.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 java.lang.Class<?>
getMinecraftClass(java.lang.String name)
Retrieve a class in the net.minecraft.server.VERSION.* package.
-
-
-
Method Detail
-
getField
public static <T> Reflection.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.- Type Parameters:
T
- Type of the field.- Parameters:
target
- - the target type.name
- - the name of the field, or NULL to ignore.fieldType
- - a compatible field type.- Returns:
- The field accessor.
-
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.- Returns:
- The found class.
- 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.- Returns:
- The found class
- Throws:
java.lang.IllegalArgumentException
- If the class doesn't exist.
-
-