Class Scheduler

java.lang.Object
com.enhancedechest.scheduler.Scheduler

public final class Scheduler extends Object
Task scheduler built directly on Paper's own region-aware scheduler API (io.papermc.paper.threadedregions.scheduler.*). Paper implements that API safely on both a plain Paper server (as the main thread) and on Folia (as the entity/region-owning thread), so no platform branching is needed here for dispatch — only isFolia() exists, for the one genuine behavioral difference in ChestSessionManager (single-viewer vs concurrent-edit per chest).
  • Constructor Summary

    Constructors
    Constructor
    Description
    Scheduler(org.bukkit.plugin.Plugin plugin)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Cancels every task this plugin has scheduled through the async and global-region schedulers.
    boolean
    True if the current thread is the global bookkeeping thread (main on Paper, global region on Folia).
    void
    runAsync(Consumer<io.papermc.paper.threadedregions.scheduler.ScheduledTask> task)
    Runs once, off the region/main thread, as soon as possible.
    void
    runAtEntity(org.bukkit.entity.Entity entity, Consumer<io.papermc.paper.threadedregions.scheduler.ScheduledTask> task)
    Runs once on the thread that owns entity (its region on Folia; main thread on Paper).
    void
    runAtEntityLater(org.bukkit.entity.Entity entity, Runnable task, long delay, TimeUnit unit)
    Runs once on the entity's own thread after delay.
    void
    runAtLocation(org.bukkit.Location location, Consumer<io.papermc.paper.threadedregions.scheduler.ScheduledTask> task)
    Runs once on the thread that owns location's region (main thread on Paper).
    void
    runLaterAsync(Runnable task, long delay, TimeUnit unit)
    Runs once, off-thread, after delay.
    void
    runNextTick(Consumer<io.papermc.paper.threadedregions.scheduler.ScheduledTask> task)
    Runs once on the global bookkeeping thread, next tick.
    io.papermc.paper.threadedregions.scheduler.ScheduledTask
    runTimerAsync(Runnable task, long delay, long period, TimeUnit unit)
    Repeating off-thread timer; cancel it via the returned ScheduledTask.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Scheduler

      public Scheduler(org.bukkit.plugin.Plugin plugin)
  • Method Details

    • isGlobalTickThread

      public boolean isGlobalTickThread()
      True if the current thread is the global bookkeeping thread (main on Paper, global region on Folia).
    • runAsync

      public void runAsync(Consumer<io.papermc.paper.threadedregions.scheduler.ScheduledTask> task)
      Runs once, off the region/main thread, as soon as possible.
    • runLaterAsync

      public void runLaterAsync(Runnable task, long delay, TimeUnit unit)
      Runs once, off-thread, after delay.
    • runTimerAsync

      public io.papermc.paper.threadedregions.scheduler.ScheduledTask runTimerAsync(Runnable task, long delay, long period, TimeUnit unit)
      Repeating off-thread timer; cancel it via the returned ScheduledTask.
    • runNextTick

      public void runNextTick(Consumer<io.papermc.paper.threadedregions.scheduler.ScheduledTask> task)
      Runs once on the global bookkeeping thread, next tick.
    • runAtEntity

      public void runAtEntity(org.bukkit.entity.Entity entity, Consumer<io.papermc.paper.threadedregions.scheduler.ScheduledTask> task)
      Runs once on the thread that owns entity (its region on Folia; main thread on Paper). A no-op if the entity is no longer valid.
    • runAtEntityLater

      public void runAtEntityLater(org.bukkit.entity.Entity entity, Runnable task, long delay, TimeUnit unit)
      Runs once on the entity's own thread after delay. A no-op if the entity is no longer valid.
    • runAtLocation

      public void runAtLocation(org.bukkit.Location location, Consumer<io.papermc.paper.threadedregions.scheduler.ScheduledTask> task)
      Runs once on the thread that owns location's region (main thread on Paper).
    • cancelAllTasks

      public void cancelAllTasks()
      Cancels every task this plugin has scheduled through the async and global-region schedulers.