TaskScheduler

abstract class TaskScheduler

Represents a generic task scheduler.

Inheritors

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun <T> callSyncMethod(task: Callable<T>): Future<T>

Calls a method on the main thread and returns a Future object. This task will be executed by the main(Bukkit)/global(Folia&Paper) server thread.
Note: The Future.get() methods must NOT be called from the main thread.
Note2: There is at least an average of 10ms latency until the isDone() method returns true.

Link copied to clipboard
abstract fun cancelTasks()

Attempts to cancel all tasks scheduled by this plugin

abstract fun cancelTasks(plugin: Plugin)

Attempts to cancel all tasks scheduled by the specified plugin

Link copied to clipboard
abstract fun execute(runnable: Runnable)

Schedules a task to be executed on the global region

open fun execute(location: Location, runnable: Runnable)

Schedules a task to be executed on the region which owns the location

open fun execute(entity: Entity, runnable: Runnable)

Schedules a task to be executed on the region which owns the location of given entity

Link copied to clipboard
abstract fun isEntityThread(entity: Entity): Boolean

Folia & Paper: Returns whether the current thread is ticking a region and that the region being ticked owns the specified entity. Note that this function is the only appropriate method of checking for ownership of an entity, as retrieving the entity's location is undefined unless the entity is owned by the current region
Bukkit: returns {@link org.bukkit.Server#isPrimaryThread}

Link copied to clipboard
abstract fun isGlobalThread(): Boolean

Folia: Returns whether the current thread is ticking the global region
Paper & Bukkit: Returns {@link org.bukkit.Server#isPrimaryThread}

Link copied to clipboard
abstract fun isRegionThread(location: Location): Boolean

Folia & Paper: Returns whether the current thread is ticking a region and that the region being ticked owns the chunk at the specified world and block position as included in the specified location
Bukkit: returns {@link org.bukkit.Server#isPrimaryThread}

Link copied to clipboard
open fun isTickThread(): Boolean
Link copied to clipboard
abstract fun runTask(runnable: Runnable): ScheduledTask

Schedules a task to be executed on the next tick
Folia & Paper: ...on the global region
Bukkit: ...on the main thread

open fun runTask(location: Location, runnable: Runnable): ScheduledTask

Folia & Paper: Schedules a task to be executed on the region which owns the location on the next tick
Bukkit: same as {@link #runTask(Runnable)}

open fun runTask(entity: Entity, runnable: Runnable): ScheduledTask

Folia & Paper: Schedules a task to be executed on the region which owns the location of given entity on the next tick
Bukkit: same as {@link #runTask(Runnable)}

Link copied to clipboard

Schedules the specified task to be executed asynchronously immediately

Link copied to clipboard
abstract fun runTaskLater(runnable: Runnable, delay: Long): ScheduledTask

Schedules a task to be executed after the specified delay in ticks
Folia & Paper: ...on the global region
Bukkit: ...on the main thread

open fun runTaskLater(location: Location, runnable: Runnable, delay: Long): ScheduledTask

Folia & Paper: Schedules a task to be executed on the region which owns the location after the specified delay in ticks
Bukkit: same as {@link #runTaskLater(Runnable, long)}

open fun runTaskLater(entity: Entity, runnable: Runnable, delay: Long): ScheduledTask

Folia & Paper: Schedules a task to be executed on the region which owns the location of given entity after the specified delay in ticks
Bukkit: same as {@link #runTaskLater(Runnable, long)}

Link copied to clipboard
abstract fun runTaskLaterAsynchronously(runnable: Runnable, delay: Long): ScheduledTask

Schedules the specified task to be executed asynchronously after the time delay has passed

Link copied to clipboard
abstract fun runTaskTimer(runnable: Runnable, delay: Long, period: Long): ScheduledTask

Schedules a repeating task to be executed after the initial delay with the specified period
Folia & Paper: ...on the global region
Bukkit: ...on the main thread

open fun runTaskTimer(location: Location, runnable: Runnable, delay: Long, period: Long): ScheduledTask

Folia & Paper: Schedules a repeating task to be executed on the region which owns the location after the initial delay with the specified period
Bukkit: same as {@link #runTaskTimer(Runnable, long, long)}

open fun runTaskTimer(entity: Entity, runnable: Runnable, delay: Long, period: Long): ScheduledTask

Folia & Paper: Schedules a repeating task to be executed on the region which owns the location of given entity after the initial delay with the specified period
Bukkit: same as {@link #runTaskTimer(Runnable, long, long)}

Link copied to clipboard
abstract fun runTaskTimerAsynchronously(runnable: Runnable, delay: Long, period: Long): ScheduledTask

Schedules the specified task to be executed asynchronously after the initial delay has passed and then periodically executed with the specified period