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.

  • 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

      SchedulerAdapter.ScheduledTask runGlobalDelayed(Runnable task, long delayTicks)
      Runs a task with no location affinity after delayTicks.
    • runGlobalTimer

      SchedulerAdapter.ScheduledTask runGlobalTimer(Runnable task, long delayTicks, long periodTicks)
      Runs a repeating task with no location affinity.
    • runAtLocation

      SchedulerAdapter.ScheduledTask runAtLocation(org.bukkit.Location location, Runnable task)
      Runs a task on the region that owns location (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 owns location after delayTicks.
    • runAtLocationTimer

      SchedulerAdapter.ScheduledTask runAtLocationTimer(org.bukkit.Location location, Runnable task, long delayTicks, long periodTicks)
      Runs a repeating task pinned to the region that owns location.
    • 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 owns entity, on the region thread, with the live Entity handed 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 of task if 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

      SchedulerAdapter.ScheduledTask runAsyncDelayed(Runnable task, long delayTicks)
      Runs a task off-thread after delayTicks worth of wall-clock time.
    • runAsyncTimer

      SchedulerAdapter.ScheduledTask runAsyncTimer(Runnable task, long delayTicks, long periodTicks)
      Runs a repeating task off-thread.
    • supplyAsync

      <T> CompletableFuture<T> supplyAsync(Supplier<T> supplier)
      Convenience wrapper: runs supplier asynchronously and completes the returned future with its result (or exception), for call sites that want to compose with CompletableFuture instead of callbacks.