FoliaScheduler

open class FoliaScheduler(plugin: Plugin) : TaskScheduler

Wrapper class for Folia's scheduler.

Inheritors

Constructors

Link copied to clipboard
constructor(plugin: Plugin)

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
open override fun cancelTasks()

Attempts to cancel all tasks scheduled by this plugin

open override fun cancelTasks(plugin: Plugin)

Attempts to cancel all tasks scheduled by the specified plugin

Link copied to clipboard
open override fun execute(runnable: Runnable)

Schedules a task to be executed on the global region

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

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

open override 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
open override 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
open override 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
open override 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
open override fun runTask(runnable: Runnable): FoliaScheduledTask

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

open override fun runTask(location: Location, runnable: Runnable): FoliaScheduledTask

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 override fun runTask(entity: Entity, runnable: Runnable): FoliaScheduledTask

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
open override fun runTaskAsynchronously(runnable: Runnable): FoliaScheduledTask

Schedules the specified task to be executed asynchronously immediately

Link copied to clipboard
open override fun runTaskLater(runnable: Runnable, delay: Long): FoliaScheduledTask

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

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

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 override fun runTaskLater(entity: Entity, runnable: Runnable, delay: Long): FoliaScheduledTask

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
open override fun runTaskLaterAsynchronously(runnable: Runnable, delay: Long): FoliaScheduledTask

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

Link copied to clipboard
open override fun runTaskTimer(runnable: Runnable, delay: Long, period: Long): FoliaScheduledTask

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 override fun runTaskTimer(location: Location, runnable: Runnable, delay: Long, period: Long): FoliaScheduledTask

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 override fun runTaskTimer(entity: Entity, runnable: Runnable, delay: Long, period: Long): FoliaScheduledTask

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
open override fun runTaskTimerAsynchronously(runnable: Runnable, delay: Long, period: Long): FoliaScheduledTask

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