Package com.enhancedechest.scheduler
Class Scheduler
java.lang.Object
com.enhancedechest.scheduler.Scheduler
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidCancels every task this plugin has scheduled through the async and global-region schedulers.booleanTrue if the current thread is the global bookkeeping thread (main on Paper, global region on Folia).voidRuns once, off the region/main thread, as soon as possible.voidrunAtEntity(org.bukkit.entity.Entity entity, Consumer<io.papermc.paper.threadedregions.scheduler.ScheduledTask> task) Runs once on the thread that ownsentity(its region on Folia; main thread on Paper).voidrunAtEntityLater(org.bukkit.entity.Entity entity, Runnable task, long delay, TimeUnit unit) Runs once on the entity's own thread afterdelay.voidrunAtLocation(org.bukkit.Location location, Consumer<io.papermc.paper.threadedregions.scheduler.ScheduledTask> task) Runs once on the thread that ownslocation's region (main thread on Paper).voidrunLaterAsync(Runnable task, long delay, TimeUnit unit) Runs once, off-thread, afterdelay.voidrunNextTick(Consumer<io.papermc.paper.threadedregions.scheduler.ScheduledTask> task) Runs once on the global bookkeeping thread, next tick.io.papermc.paper.threadedregions.scheduler.ScheduledTaskrunTimerAsync(Runnable task, long delay, long period, TimeUnit unit) Repeating off-thread timer; cancel it via the returnedScheduledTask.
-
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
Runs once, off the region/main thread, as soon as possible. -
runLaterAsync
Runs once, off-thread, afterdelay. -
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 returnedScheduledTask. -
runNextTick
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 ownsentity(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 afterdelay. 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 ownslocation's region (main thread on Paper). -
cancelAllTasks
public void cancelAllTasks()Cancels every task this plugin has scheduled through the async and global-region schedulers.
-