Class Scheduling

java.lang.Object
dev.despical.pixelpainter.service.Scheduling

public final class Scheduling extends Object
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

    Constructors
    Constructor
    Description
    Scheduling(org.bukkit.plugin.Plugin plugin)
    Creates a scheduler facade for an enabled plugin.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    delayed(Runnable task, long ticks)
    Runs a task on the global region after a delay.
    void
    entity(org.bukkit.entity.Player player, Runnable task)
    Runs a task on the thread that owns a player, immediately when already there.
    boolean
    Reports whether the server runs Folia's regionized threading.
    void
    Runs a task on the global region as soon as possible.
    void
    region(org.bukkit.World world, int chunkX, int chunkZ, Runnable task)
    Runs a task on the thread that owns a chunk.
    io.papermc.paper.threadedregions.scheduler.ScheduledTask
    Starts a task that runs every tick on the global region.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public io.papermc.paper.threadedregions.scheduler.ScheduledTask timer(Runnable task)
      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

      public void global(Runnable task)
      Runs a task on the global region as soon as possible.
      Parameters:
      task - work that touches only plugin state
    • delayed

      public void delayed(Runnable task, long ticks)
      Runs a task on the global region after a delay.
      Parameters:
      task - work that touches only plugin state
      ticks - delay in server ticks, at least one
    • region

      public void region(org.bukkit.World world, int chunkX, int chunkZ, Runnable task)
      Runs a task on the thread that owns a chunk.
      Parameters:
      world - world containing the chunk
      chunkX - chunk X coordinate
      chunkZ - chunk Z coordinate
      task - work that may read and change blocks inside that chunk
    • entity

      public void entity(org.bukkit.entity.Player player, Runnable task)
      Runs a task on the thread that owns a player, immediately when already there.
      Parameters:
      player - player whose state the task reads or changes
      task - player-bound work; skipped when the player has left the server