Class Function<T>

java.lang.Object
ch.njol.skript.lang.function.Function<T>
Direct Known Subclasses:
JavaFunction, ScriptFunction

public abstract class Function<T> extends Object
Functions can be called using arguments.
  • Field Details

    • executeWithNulls

      public static boolean executeWithNulls
      Execute functions even when some parameters are not present. Field is updated by SkriptConfig in case of reloads.
  • Constructor Details

    • Function

      public Function(Signature<T> sign)
  • Method Details

    • getSignature

      public Signature<T> getSignature()
      Gets signature of this function that contains all metadata about it.
      Returns:
      A function signature.
    • getName

      public String getName()
    • getParameters

      public Parameter<?>[] getParameters()
    • getParameter

      public Parameter<?> getParameter(int index)
    • isSingle

      public boolean isSingle()
    • getReturnType

      public @Nullable ClassInfo<T> getReturnType()
    • execute

      public final @Nullable T[] execute(Object[][] params)
      Executes this function with given parameter.
      Parameters:
      params - Function parameters. Must contain at least Signature.getMinParameters() elements and at most Signature.getMaxParameters() elements.
      Returns:
      The result(s) of this function
    • execute

      public abstract @Nullable T[] execute(FunctionEvent<?> e, Object[][] params)
      Executes this function with given parameters. Usually, using execute(Object[][]) is better; it handles optional arguments and function event creation automatically.
      Parameters:
      e - Associated function event. This is usually created by Skript.
      params - Function parameters. There must be Signature.getMaxParameters() amount of them, and you need to manually handle default values.
      Returns:
      Function return value(s).
    • resetReturnValue

      public abstract boolean resetReturnValue()
      Resets the return value of the Function. Should be called right after execution.
      Returns:
      Whether or not the return value was successfully reset
    • toString

      public String toString()
      Overrides:
      toString in class Object