task
Allows for seamless scheduling with multithreading and the server
Overview:
Functions:
API Reference
spawn()
spawn()Runs a function asynchronously.
Bukkit: Uses async scheduler
Folia: Runs on a separate thread
Parameters:
function(Function) Function to execute.
Returns:
taskId(Number) Identifier used to cancel the task.
main()
main()Executes a function safely on the server main thread. (If on Folia use task.entitySchedule(..) instead)
Parameters:
function(Function) Function to execute.
Returns:
taskId(Number)
entitySchedule()
entitySchedule()Schedules a task bound to a specific entity. (Folia alternative to task.main(..))
Parameters:
entity(Entity) The entity to bind the task to.function(Function) Function to execute.
Returns:
taskId(Number)
thread()
thread()Executes a function parallel on a thread.
Parameters:
function(Function) Function to execute.
Returns:
taskId(Number)
delay()
delay()Executes a function after a delay asynchronously.
Parameters:
delay(Number) Delay in seconds.function(Function) Function to execute.
Returns:
taskId(Number)
repeat()
repeat()Runs a repeating task asynchronously .
Parameters:
delay(Number) Initial delay in seconds.period(Number) Repeat interval in ticks.function(Function) Function to run.
Returns:
taskId(Number)
cancel()
cancel()Cancels a scheduled task.
Parameters:
taskId(Number) The task identifier.
bindToUnload()
bindToUnload()Registers a function to be executed when the script unloads.
Parameters:
function(Function) Cleanup handler.
wait()
wait()Pauses execution of the current script for a given number of seconds.
Parameters:
seconds(Number) Time to wait in seconds.
Returns:
BooleanReturnstruewhen completed. Throws if interrupted.
waitForScript()
waitForScript()Blocks execution until specified script finishes loading.
Parameters:
scriptName(String) Name of the script to wait for.
waitForPlugin()
waitForPlugin()Blocks execution until a plugin becomes available.
Parameters:
pluginName(String) Name of the plugin.
Last updated
Was this helpful?