Class Scheduling
java.lang.Object
dev.despical.pixelpainter.service.Scheduling
Schedules plugin work through the region-aware Paper schedulers.
The global, region and entity schedulers exist on Paper and on Folia. On Paper they all run on the single server thread, so the same code path serves both platforms. On Folia each task runs on the thread that owns the target location or player, which is the only thread allowed to read or change that state.
Use the global scheduler for plugin state that is not tied to a location, a region scheduler for block access and an entity hop for player-bound actions. Instances are stateless after construction and safe to share between threads.
-
Constructor Summary
ConstructorsConstructorDescriptionScheduling(org.bukkit.plugin.Plugin plugin) Creates a scheduler facade for an enabled plugin. -
Method Summary
Modifier and TypeMethodDescriptionvoidRuns a task on the global region after a delay.voidRuns a task on the thread that owns a player, immediately when already there.booleanfolia()Reports whether the server runs Folia's regionized threading.voidRuns a task on the global region as soon as possible.voidRuns a task on the thread that owns a chunk.io.papermc.paper.threadedregions.scheduler.ScheduledTaskStarts a task that runs every tick on the global region.
-
Constructor Details
-
Scheduling
public Scheduling(org.bukkit.plugin.Plugin plugin) Creates a scheduler facade for an enabled plugin.- Parameters:
plugin- owner of every scheduled task
-
-
Method Details
-
folia
public boolean folia()Reports whether the server runs Folia's regionized threading.- Returns:
- whether regions tick on separate threads
-
timer
Starts a task that runs every tick on the global region.- Parameters:
task- work that touches only plugin state- Returns:
- handle used to cancel the repeating task
-
global
Runs a task on the global region as soon as possible.- Parameters:
task- work that touches only plugin state
-
delayed
Runs a task on the global region after a delay.- Parameters:
task- work that touches only plugin stateticks- delay in server ticks, at least one
-
region
Runs a task on the thread that owns a chunk.- Parameters:
world- world containing the chunkchunkX- chunk X coordinatechunkZ- chunk Z coordinatetask- work that may read and change blocks inside that chunk
-
entity
Runs a task on the thread that owns a player, immediately when already there.- Parameters:
player- player whose state the task reads or changestask- player-bound work; skipped when the player has left the server
-