Class Reflection
java.lang.Object
com.djrapitops.plan.utilities.java.Reflection
An utility class that simplifies reflection in Bukkit plugins.
Modified Reflection utility from LagMonitor plugin. original code
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
An interface for retrieving the field content. -
Method Summary
Modifier and TypeMethodDescriptionstatic Class<?>
getCraftBukkitClass
(String name) Retrieve a class in the org.bukkit.craftbukkit.VERSION.* package.static <T> Reflection.FieldAccessor<T>
Retrieve a field accessor for a specific field type and name.static Class<?>
getMinecraftClass
(String name) Retrieve a class in the net.minecraft.server.VERSION.* package.
-
Method Details
-
getField
public static <T> Reflection.FieldAccessor<T> getField(Class<?> target, String name, 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
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:
IllegalArgumentException
- If the class doesn't exist.
-
getCraftBukkitClass
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:
IllegalArgumentException
- If the class doesn't exist.
-