Package redempt.redlib.nms
Class NMSObject
java.lang.Object
redempt.redlib.nms.NMSObject
Wraps any Object and provides easy access to reflection methods
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncallMethod
(int supers, String name, Object... args) Calls a method on the wrapped objectcallMethod
(String name, Object... args) Calls a method on the wrapped objectGets the value stored in a field in the wrapped objectGets the value stored in a field in the wrapped objectgetType()
boolean
isNull()
void
Sets the value stored in a field in the wrapped objectvoid
Sets the value stored in a field in the wrapped object
-
Constructor Details
-
NMSObject
Constructs an NMSObject with the object it should wrap- Parameters:
obj
- The object to wrap
-
-
Method Details
-
getObject
- Returns:
- The wrapped object
-
getTypeName
- Returns:
- The name of the class of the wrapped object
-
getType
- Returns:
- A wrapped NMSClass of the class of the wrapped object
-
isNull
public boolean isNull()- Returns:
- Whether this NMSObject is wrapping null
-
callMethod
Calls a method on the wrapped object- Parameters:
name
- The name of the methodargs
- The arguments to pass to the methodsupers
- The number of superclasses to move up before getting the declared method- Returns:
- An NMSObject which is the returned value from the method
-
callMethod
Calls a method on the wrapped object- Parameters:
name
- The name of the methodargs
- The arguments to pass to the method- Returns:
- An NMSObject which is the returned value from the method
-
getField
Gets the value stored in a field in the wrapped object- Parameters:
name
- The name of the fieldsupers
- The number of superclasses to move up before getting the declared field- Returns:
- A wrapped NMSObject with the value of the field
-
getField
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
Sets the value stored in a field in the wrapped object- Parameters:
name
- The name of the fieldsupers
- The number of superclasses to move up before getting the declared fieldobj
- The object to set. Will be unwrapped if it is an NMSObject.
-
setField
Sets the value stored in a field in the wrapped object- Parameters:
name
- The name of the fieldobj
- The object to set. Will be unwrapped if it is an NMSObject.
-