Interface PlatformScheduler
- All Known Implementing Classes:
BukkitPlatformScheduler,FoliaPlatformScheduler
public interface PlatformScheduler
Platform-neutral scheduling. On Folia every task is bound to a region (an entity's, a
location's, or the global region); on legacy Spigot/Paper all variants fall back to the
single main thread. Obtain the configured instance by injecting this type.
Times are in server ticks (20 per second), matching the legacy scheduler.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanownsRegion(@NotNull org.bukkit.entity.Entity entity) booleanownsRegion(@NotNull org.bukkit.Location location) @NotNull PlatformTaskrunAtRegion(@NotNull org.bukkit.Location location, @NotNull Runnable task) Runs a task on the thread owning the given location's region (Folia) or the main thread (legacy).@NotNull PlatformTaskrunAtRegionLater(@NotNull org.bukkit.Location location, @NotNull Runnable task, long delayTicks) Runs a task on the thread owning the given location's region (Folia) or the main thread (legacy), after a delay.@NotNull PlatformTaskRuns a task on the global region thread (Folia) or the main thread (legacy).@NotNull PlatformTaskrunGlobalLater(@NotNull Runnable task, long delayTicks) Runs a task on the global region thread (Folia) or the main thread (legacy), after a delay.@NotNull PlatformTaskrunOnEntity(@NotNull org.bukkit.entity.Entity entity, @NotNull Runnable task, @Nullable Runnable retired) Runs a task on the thread owning the entity's region (Folia) or the main thread (legacy).@NotNull PlatformTaskrunOnEntityAtFixedRate(@NotNull org.bukkit.entity.Entity entity, @NotNull Runnable task, @Nullable Runnable retired, long delayTicks, long periodTicks) Runs a task repeatedly on the thread owning the entity's region (Folia) or the main thread (legacy).@NotNull PlatformTaskrunOnEntityLater(@NotNull org.bukkit.entity.Entity entity, @NotNull Runnable task, @Nullable Runnable retired, long delayTicks) Runs a task on the thread owning the entity's region (Folia) or the main thread (legacy), after a delay.
-
Method Details
-
runOnEntity
@NotNull @NotNull PlatformTask runOnEntity(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task, @Nullable @Nullable Runnable retired) Runs a task on the thread owning the entity's region (Folia) or the main thread (legacy).- Parameters:
entity- the entity whose region owns the tasktask- the work to runretired- run instead oftaskif the entity is removed before it fires (Folia only); ignored on legacy- Returns:
- a cancellable handle
-
runOnEntityLater
@NotNull @NotNull PlatformTask runOnEntityLater(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task, @Nullable @Nullable Runnable retired, long delayTicks) Runs a task on the thread owning the entity's region (Folia) or the main thread (legacy), after a delay.- Parameters:
entity- the entity whose region owns the tasktask- the work to runretired- run instead oftaskif the entity is removed before it fires (Folia only); ignored on legacydelayTicks- delay in ticks before the task fires; clamped to at least 1- Returns:
- a cancellable handle
-
runOnEntityAtFixedRate
@NotNull @NotNull PlatformTask runOnEntityAtFixedRate(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task, @Nullable @Nullable Runnable retired, long delayTicks, long periodTicks) Runs a task repeatedly on the thread owning the entity's region (Folia) or the main thread (legacy).- Parameters:
entity- the entity whose region owns the tasktask- the work to run each periodretired- run instead oftaskif the entity is removed before it fires (Folia only); ignored on legacydelayTicks- delay in ticks before the first execution; clamped to at least 1periodTicks- interval in ticks between subsequent executions; clamped to at least 1- Returns:
- a cancellable handle
-
runAtRegion
@NotNull @NotNull PlatformTask runAtRegion(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable task) Runs a task on the thread owning the given location's region (Folia) or the main thread (legacy).- Parameters:
location- the location whose region owns the tasktask- the work to run- Returns:
- a cancellable handle
-
runAtRegionLater
@NotNull @NotNull PlatformTask runAtRegionLater(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable task, long delayTicks) Runs a task on the thread owning the given location's region (Folia) or the main thread (legacy), after a delay.- Parameters:
location- the location whose region owns the tasktask- the work to rundelayTicks- delay in ticks before the task fires; clamped to at least 1- Returns:
- a cancellable handle
-
runGlobal
Runs a task on the global region thread (Folia) or the main thread (legacy).- Parameters:
task- the work to run- Returns:
- a cancellable handle
-
runGlobalLater
Runs a task on the global region thread (Folia) or the main thread (legacy), after a delay.- Parameters:
task- the work to rundelayTicks- delay in ticks before the task fires; clamped to at least 1- Returns:
- a cancellable handle
-
ownsRegion
boolean ownsRegion(@NotNull @NotNull org.bukkit.entity.Entity entity) - Parameters:
entity- the entity to check- Returns:
trueif the current thread owns the entity's region (Folia) or is the main thread (legacy) — i.e. it is safe to touch the entity now.
-
ownsRegion
boolean ownsRegion(@NotNull @NotNull org.bukkit.Location location) - Parameters:
location- the location to check- Returns:
trueif the current thread owns the given location's region (Folia) or is the main thread (legacy) — i.e. it is safe to touch that location now.
-