Class Reflection

java.lang.Object
com.djrapitops.plan.utilities.java.Reflection

public final class Reflection extends 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

  • 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

      public static Class<?> getMinecraftClass(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:
      IllegalArgumentException - If the class doesn't exist.
    • getCraftBukkitClass

      public static Class<?> getCraftBukkitClass(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:
      IllegalArgumentException - If the class doesn't exist.