Class Functions

java.lang.Object
ch.njol.skript.lang.function.Functions

public abstract class Functions extends Object
Static methods to work with functions.
  • Field Details

  • Method Details

    • registerFunction

      public static JavaFunction<?> registerFunction(JavaFunction<?> function)
      Registers a function written in Java.
      Returns:
      The passed function
    • loadFunction

      public static @Nullable Function<?> loadFunction(SectionNode node)
      Loads a script function from given node.
      Parameters:
      node - Section node.
      Returns:
      Script function, or null if something went wrong.
    • loadSignature

      public static @Nullable Signature<?> loadSignature(String script, SectionNode node)
      Loads the signature of function from given node.
      Parameters:
      script - Script file name (might be used for some checks).
      node - Section node.
      Returns:
      Signature of function, or null if something went wrong.
    • getFunction

      public static @Nullable Function<?> getFunction(String name)
      Gets a function, if it exists. Note that even if function exists in scripts, it might not have been parsed yet. If you want to check for existance, then use getSignature(String).
      Parameters:
      name - Name of function.
      Returns:
      Function, or null if it does not exist.
    • getSignature

      public static @Nullable Signature<?> getSignature(String name)
      Gets a signature of function with given name.
      Parameters:
      name - Name of function.
      Returns:
      Signature, or null if function does not exist.
    • clearFunctions

      public static int clearFunctions(String script)
      Remember to call validateFunctions() after calling this
      Returns:
      How many functions were removed
    • validateFunctions

      public static void validateFunctions()
    • clearFunctions

      public static void clearFunctions()
      Clears all function calls and removes script functions.
    • getJavaFunctions

      public static Collection<JavaFunction<?>> getJavaFunctions()
    • enableFunctionEvents

      public static void enableFunctionEvents(SkriptAddon addon)
      Normally, function calls do not cause actual Bukkit events to be called. If an addon requires such functionality, it should call this method. After doing so, the events will be called. Calling this method many times will not cause any additional changes.

      Note that calling events is not free; performance might vary once you have enabled that.

      Parameters:
      addon - Addon instance.