Package ch.njol.skript.lang.function
Class Functions
java.lang.Object
ch.njol.skript.lang.function.Functions
Static methods to work with functions.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Deprecated.static int
clearFunctions
(String script) Deprecated.static void
enableFunctionEvents
(SkriptAddon addon) Normally, function calls do not cause actual Bukkit events to be called.static @Nullable Function
<?> getFunction
(String name) Deprecated.static @Nullable Function
<?> getFunction
(String name, @Nullable String script) Gets a local function, if it doesn't exist it'll fall back to a global function, if it exists.static @Nullable Function
<?> getGlobalFunction
(String name) Gets a function, if it exists.static @Nullable Signature
<?> getGlobalSignature
(String name) Gets a signature of function with given name.static Collection
<JavaFunction<?>> static @Nullable Function
<?> getLocalFunction
(String name, String script) Gets a function, if it exists.static @Nullable Signature
<?> getLocalSignature
(String name, String script) Gets a signature of function with given name.static @Nullable Namespace
getScriptNamespace
(String script) static @Nullable Signature
<?> getSignature
(String name) Deprecated.in favour ofgetGlobalSignature(String)
for proper name.static @Nullable Signature
<?> getSignature
(String name, @Nullable String script) Gets a signature of local function with the given name, if no signature was found, it will fall back to a global function.static @Nullable Function
<?> loadFunction
(Script script, SectionNode node, Signature<?> signature) Loads a script function from given node.static @Nullable Signature
<?> parseSignature
(String script, String name, String args, @Nullable String returnType, boolean local) Parses the signature from the given arguments.static JavaFunction
<?> registerFunction
(JavaFunction<?> function) Registers a function written in Java.static @Nullable Signature
<?> registerSignature
(Signature<?> signature) Registers the signature.static void
unregisterFunction
(Signature<?> signature) static void
-
Field Details
-
currentFunction
-
functionNamePattern
- See Also:
-
-
Method Details
-
registerFunction
Registers a function written in Java.- Returns:
- The passed function
-
loadFunction
@Nullable public static @Nullable Function<?> loadFunction(Script script, SectionNode node, Signature<?> signature) Loads a script function from given node.- Parameters:
script
- The script the function is declared innode
- Section node.signature
- The signature of the function. UseparseSignature(String, String, String, String, boolean)
to get a new signature instance andregisterSignature(Signature)
to register the signature- Returns:
- Script function, or null if something went wrong.
-
parseSignature
@Nullable public static @Nullable Signature<?> parseSignature(String script, String name, String args, @Nullable @Nullable String returnType, boolean local) Parses the signature from the given arguments.- Parameters:
script
- Script file name (might be used for some checks).name
- The name of the function.args
- The parameters of the function. SeeParameter.parse(String)
returnType
- The return type of the functionlocal
- If the signature of function is local.- Returns:
- Parsed signature or null if something went wrong.
- See Also:
-
registerSignature
Registers the signature.- Parameters:
signature
- The signature to register.- Returns:
- Signature of function, or null if something went wrong.
- See Also:
-
getFunction
Deprecated.in favour ofgetGlobalFunction(String)
for proper 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 existence, then usegetGlobalSignature(String)
.- Parameters:
name
- Name of function.- Returns:
- Function, or null if it does not exist.
-
getGlobalFunction
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 existence, then usegetGlobalSignature(String)
.- Parameters:
name
- Name of function.- Returns:
- Function, or null if it does not exist.
-
getLocalFunction
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 existence, then usegetLocalSignature(String, String)
.- Parameters:
name
- Name of function.script
- The script where the function is declared in. Used to get local functions.- Returns:
- Function, or null if it does not exist.
-
getFunction
@Nullable public static @Nullable Function<?> getFunction(String name, @Nullable @Nullable String script) Gets a local function, if it doesn't exist it'll fall back to a global 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 existence, then usegetSignature(String, String)
.- Parameters:
name
- Name of function.script
- The script where the function is declared in. Used to get local functions.- Returns:
- Function, or null if it does not exist.
-
getSignature
Deprecated.in favour ofgetGlobalSignature(String)
for proper name.Gets a signature of function with given name.- Parameters:
name
- Name of function.- Returns:
- Signature, or null if function does not exist.
-
getGlobalSignature
Gets a signature of function with given name.- Parameters:
name
- Name of function.- Returns:
- Signature, or null if function does not exist.
-
getLocalSignature
Gets a signature of function with given name.- Parameters:
name
- Name of function.script
- The script where the function is declared in. Used to get local functions.- Returns:
- Signature, or null if function does not exist.
-
getSignature
@Nullable public static @Nullable Signature<?> getSignature(String name, @Nullable @Nullable String script) Gets a signature of local function with the given name, if no signature was found, it will fall back to a global function.- Parameters:
name
- Name of function.script
- The script where the function is declared in. Used to get local functions.- Returns:
- Signature, or null if function does not exist.
-
getScriptNamespace
-
clearFunctions
Deprecated.Remember to callvalidateFunctions()
after calling this- Returns:
- How many functions were removed
-
unregisterFunction
-
validateFunctions
public static void validateFunctions() -
clearFunctions
Deprecated.Clears all function calls and removes script functions. -
getJavaFunctions
-
enableFunctionEvents
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.
-
getGlobalFunction(String)
for proper name.