Class ReflectionUtils

java.lang.Object
com.shanebeestudios.nms.api.util.ReflectionUtils

public class ReflectionUtils extends Object
Utility class with shortcut methods for reflection
  • Constructor Details

    • ReflectionUtils

      public ReflectionUtils()
  • Method Details

    • getField

      @Nullable public static @Nullable Object getField(String field, Class<?> clazz, Object object)
      Get the value of a field from an object
      Parameters:
      field - Name of field
      clazz - Class with field
      object - Object which contains field
      Returns:
      Object from field
    • setField

      public static void setField(String field, Class<?> clazz, Object object, Object toSet)
      Set the value of a field in an object
      Parameters:
      field - Name of field to set
      clazz - Class with field
      object - Object which holds field
      toSet - Object to set
    • setField

      public static void setField(String field, Object object, Object toSet)
      Set the value of a field in an object
      Parameters:
      field - Name of field to set
      object - Object which holds field
      toSet - Object to set