Interface SchedulerAdapter
public interface SchedulerAdapter
Runtime-agnostic scheduling facade.
Transparently targets the classic BukkitScheduler on Paper/Spigot/Purpur, or the
regionised GlobalRegionScheduler/RegionScheduler/EntityScheduler on
Folia, whichever the server is actually running. Every module in YouNeedMe (and every expansion)
MUST go through this instead of touching Bukkit.getScheduler() or an
entity/location-bound Folia scheduler directly - that is the one rule that keeps this plugin
Folia-safe.
Handles returned by the run* methods can always be cancelled through SchedulerAdapter.ScheduledTask.cancel() regardless of which backend is actually running underneath.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA handle to a task scheduled through this adapter. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the server this adapter is bound to is running Folia's regionised threading.Runs a task off the main/region thread entirely, for blocking I/O (storage, HTTP).runAsyncDelayed(Runnable task, long delayTicks) Runs a task off-thread afterdelayTicksworth of wall-clock time.runAsyncTimer(Runnable task, long delayTicks, long periodTicks) Runs a repeating task off-thread.runAtLocation(org.bukkit.Location location, Runnable task) Runs a task on the region that ownslocation(e.g.runAtLocationDelayed(org.bukkit.Location location, Runnable task, long delayTicks) Runs a task on the region that ownslocationafterdelayTicks.runAtLocationTimer(org.bukkit.Location location, Runnable task, long delayTicks, long periodTicks) Runs a repeating task pinned to the region that ownslocation.runForEntity(org.bukkit.entity.Entity entity, Consumer<org.bukkit.entity.Entity> task, Runnable retired, long delayTicks) Runs a task on the region that currently ownsentity, on the region thread, with the liveEntityhanded back through the callback.Runs a task with no location affinity (config reloads, global broadcasts, shutdown).runGlobalDelayed(Runnable task, long delayTicks) Runs a task with no location affinity afterdelayTicks.runGlobalTimer(Runnable task, long delayTicks, long periodTicks) Runs a repeating task with no location affinity.<T> CompletableFuture<T> supplyAsync(Supplier<T> supplier) Convenience wrapper: runssupplierasynchronously and completes the returned future with its result (or exception), for call sites that want to compose withCompletableFutureinstead of callbacks.
-
Method Details
-
isRegionised
boolean isRegionised()Whether the server this adapter is bound to is running Folia's regionised threading. -
runGlobal
Runs a task with no location affinity (config reloads, global broadcasts, shutdown). -
runGlobalDelayed
Runs a task with no location affinity afterdelayTicks. -
runGlobalTimer
Runs a repeating task with no location affinity. -
runAtLocation
Runs a task on the region that ownslocation(e.g. a block/particle effect). -
runAtLocationDelayed
SchedulerAdapter.ScheduledTask runAtLocationDelayed(org.bukkit.Location location, Runnable task, long delayTicks) Runs a task on the region that ownslocationafterdelayTicks. -
runAtLocationTimer
SchedulerAdapter.ScheduledTask runAtLocationTimer(org.bukkit.Location location, Runnable task, long delayTicks, long periodTicks) Runs a repeating task pinned to the region that ownslocation. -
runForEntity
SchedulerAdapter.ScheduledTask runForEntity(org.bukkit.entity.Entity entity, Consumer<org.bukkit.entity.Entity> task, Runnable retired, long delayTicks) Runs a task on the region that currently ownsentity, on the region thread, with the liveEntityhanded back through the callback. On Folia this is the ONLY safe way to act on an entity from an async context; on Paper/Spigot it degrades to a normal scheduled task.- Parameters:
retired- invoked instead oftaskif the entity is removed/invalid by the time the task would run (e.g. the player logged off) - never silently dropped
-
runAsync
Runs a task off the main/region thread entirely, for blocking I/O (storage, HTTP). -
runAsyncDelayed
Runs a task off-thread afterdelayTicksworth of wall-clock time. -
runAsyncTimer
Runs a repeating task off-thread. -
supplyAsync
Convenience wrapper: runssupplierasynchronously and completes the returned future with its result (or exception), for call sites that want to compose withCompletableFutureinstead of callbacks.
-