Package net.citizensnpcs.api.scripting
Class SimpleScript
java.lang.Object
net.citizensnpcs.api.scripting.SimpleScript
- All Implemented Interfaces:
Script
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
convertToInterface
(Object obj, Class<T> expected) Converts an object returned by a script to the given Java interface.getAttribute
(String name) Fetches the attribute with the specified name, or null if not found.Invokes a method on the given object, which should be a return value or scripting object.Invokes a root-level method using the method name and args and returns the result.void
setAttribute
(String name, Object value) Sets the attribute with the given name and value.
-
Constructor Details
-
SimpleScript
- Throws:
ScriptException
-
-
Method Details
-
convertToInterface
Description copied from interface:Script
Converts an object returned by a script to the given Java interface. The class should be an interface, as although abstract classes are accepted by the Rhino engine, this is not standard behaviour.- Specified by:
convertToInterface
in interfaceScript
- Parameters:
obj
- The object to convertexpected
- The expected interface- Returns:
- The converted class
-
getAttribute
Description copied from interface:Script
Fetches the attribute with the specified name, or null if not found. The returned attribute can be user-stored or a script variable, such as a function. Script objects should be accessed throughScript.invoke(String, Object...)
- Specified by:
getAttribute
in interfaceScript
- Parameters:
name
- The key of the attribute- Returns:
- The attribute
-
invoke
Description copied from interface:Script
Invokes a method on the given object, which should be a return value or scripting object. -
invoke
Description copied from interface:Script
Invokes a root-level method using the method name and args and returns the result. -
setAttribute
Description copied from interface:Script
Sets the attribute with the given name and value.- Specified by:
setAttribute
in interfaceScript
-