Class NMSObject

java.lang.Object
redempt.redlib.nms.NMSObject

public class NMSObject extends Object
Wraps any Object and provides easy access to reflection methods
  • Constructor Details

    • NMSObject

      public NMSObject(Object obj)
      Constructs an NMSObject with the object it should wrap
      Parameters:
      obj - The object to wrap
  • Method Details

    • getObject

      public Object getObject()
      Returns:
      The wrapped object
    • getTypeName

      public String getTypeName()
      Returns:
      The name of the class of the wrapped object
    • getType

      public NMSClass getType()
      Returns:
      A wrapped NMSClass of the class of the wrapped object
    • isNull

      public boolean isNull()
      Returns:
      Whether this NMSObject is wrapping null
    • callMethod

      public NMSObject callMethod(int supers, String name, Object... args)
      Calls a method on the wrapped object
      Parameters:
      name - The name of the method
      args - The arguments to pass to the method
      supers - The number of superclasses to move up before getting the declared method
      Returns:
      An NMSObject which is the returned value from the method
    • callMethod

      public NMSObject callMethod(String name, Object... args)
      Calls a method on the wrapped object
      Parameters:
      name - The name of the method
      args - The arguments to pass to the method
      Returns:
      An NMSObject which is the returned value from the method
    • getField

      public NMSObject getField(int supers, String name)
      Gets the value stored in a field in the wrapped object
      Parameters:
      name - The name of the field
      supers - The number of superclasses to move up before getting the declared field
      Returns:
      A wrapped NMSObject with the value of the field
    • getField

      public NMSObject getField(String name)
      Gets the value stored in a field in the wrapped object
      Parameters:
      name - The name of the field
      Returns:
      A wrapped NMSObject with the value of the field
    • setField

      public void setField(int supers, String name, Object obj)
      Sets the value stored in a field in the wrapped object
      Parameters:
      name - The name of the field
      supers - The number of superclasses to move up before getting the declared field
      obj - The object to set. Will be unwrapped if it is an NMSObject.
    • setField

      public void setField(String name, Object obj)
      Sets the value stored in a field in the wrapped object
      Parameters:
      name - The name of the field
      obj - The object to set. Will be unwrapped if it is an NMSObject.