Class FoliaPlatformScheduler
java.lang.Object
tech.guilhermekaua.spigotboot.core.spigot.scheduler.FoliaPlatformScheduler
- All Implemented Interfaces:
PlatformScheduler
Folia / modern-Paper
PlatformScheduler. Region/entity/global tasks land on the owning
region thread. The scheduler accessors on Bukkit/Entity are invoked reflectively
(so the 1.8.8 animal-sniffer net over org.bukkit.* stays intact); the scheduler
interfaces themselves are used with normal typed calls. Instantiated only when the Folia
scheduler API is present (see PlatformSchedulers).-
Constructor Summary
Constructors -
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.
-
Constructor Details
-
FoliaPlatformScheduler
public FoliaPlatformScheduler(@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
-
-
Method Details
-
runOnEntity
@NotNull public @NotNull PlatformTask runOnEntity(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task, @Nullable @Nullable Runnable retired) Description copied from interface:PlatformSchedulerRuns a task on the thread owning the entity's region (Folia) or the main thread (legacy).- Specified by:
runOnEntityin interfacePlatformScheduler- 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 public @NotNull PlatformTask runOnEntityLater(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task, @Nullable @Nullable Runnable retired, long delayTicks) Description copied from interface:PlatformSchedulerRuns a task on the thread owning the entity's region (Folia) or the main thread (legacy), after a delay.- Specified by:
runOnEntityLaterin interfacePlatformScheduler- 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 public @NotNull PlatformTask runOnEntityAtFixedRate(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task, @Nullable @Nullable Runnable retired, long delayTicks, long periodTicks) Description copied from interface:PlatformSchedulerRuns a task repeatedly on the thread owning the entity's region (Folia) or the main thread (legacy).- Specified by:
runOnEntityAtFixedRatein interfacePlatformScheduler- 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 public @NotNull PlatformTask runAtRegion(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable task) Description copied from interface:PlatformSchedulerRuns a task on the thread owning the given location's region (Folia) or the main thread (legacy).- Specified by:
runAtRegionin interfacePlatformScheduler- Parameters:
location- the location whose region owns the tasktask- the work to run- Returns:
- a cancellable handle
-
runAtRegionLater
@NotNull public @NotNull PlatformTask runAtRegionLater(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable task, long delayTicks) Description copied from interface:PlatformSchedulerRuns a task on the thread owning the given location's region (Folia) or the main thread (legacy), after a delay.- Specified by:
runAtRegionLaterin interfacePlatformScheduler- 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
Description copied from interface:PlatformSchedulerRuns a task on the global region thread (Folia) or the main thread (legacy).- Specified by:
runGlobalin interfacePlatformScheduler- Parameters:
task- the work to run- Returns:
- a cancellable handle
-
runGlobalLater
@NotNull public @NotNull PlatformTask runGlobalLater(@NotNull @NotNull Runnable task, long delayTicks) Description copied from interface:PlatformSchedulerRuns a task on the global region thread (Folia) or the main thread (legacy), after a delay.- Specified by:
runGlobalLaterin interfacePlatformScheduler- Parameters:
task- the work to rundelayTicks- delay in ticks before the task fires; clamped to at least 1- Returns:
- a cancellable handle
-
ownsRegion
public boolean ownsRegion(@NotNull @NotNull org.bukkit.entity.Entity entity) - Specified by:
ownsRegionin interfacePlatformScheduler- 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
public boolean ownsRegion(@NotNull @NotNull org.bukkit.Location location) - Specified by:
ownsRegionin interfacePlatformScheduler- 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.
-