Class SimpleScript

java.lang.Object
net.citizensnpcs.api.scripting.SimpleScript
All Implemented Interfaces:
Script

public class SimpleScript extends Object implements Script
  • Constructor Details

  • Method Details

    • convertToInterface

      public <T> T convertToInterface(Object obj, Class<T> expected)
      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 interface Script
      Parameters:
      obj - The object to convert
      expected - The expected interface
      Returns:
      The converted class
    • getAttribute

      public Object getAttribute(String name)
      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 through Script.invoke(String, Object...)
      Specified by:
      getAttribute in interface Script
      Parameters:
      name - The key of the attribute
      Returns:
      The attribute
    • invoke

      public Object invoke(Object instance, String name, Object... args)
      Description copied from interface: Script
      Invokes a method on the given object, which should be a return value or scripting object.
      Specified by:
      invoke in interface Script
      Parameters:
      instance - The object instance to invoke the method on
      name - The name of the method
      args - The method arguments
      Returns:
      The result of the method, if any
    • invoke

      public Object invoke(String name, Object... args)
      Description copied from interface: Script
      Invokes a root-level method using the method name and args and returns the result.
      Specified by:
      invoke in interface Script
      Parameters:
      name - The method name
      args - The method arguments
      Returns:
      The result of the method call, or null if there was none
    • setAttribute

      public void setAttribute(String name, Object value)
      Description copied from interface: Script
      Sets the attribute with the given name and value.
      Specified by:
      setAttribute in interface Script