Class BukkitPlatformScheduler

java.lang.Object
tech.guilhermekaua.spigotboot.core.spigot.scheduler.BukkitPlatformScheduler
All Implemented Interfaces:
PlatformScheduler

public final class BukkitPlatformScheduler extends Object implements PlatformScheduler
Legacy PlatformScheduler: every variant maps to BukkitScheduler and runs on the single main thread. retired callbacks have no legacy equivalent and are ignored. Selected on Spigot / Paper builds that lack the Folia scheduler API.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BukkitPlatformScheduler(@NotNull org.bukkit.plugin.Plugin plugin)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    ownsRegion(@NotNull org.bukkit.entity.Entity entity)
     
    boolean
    ownsRegion(@NotNull org.bukkit.Location location)
     
    @NotNull PlatformTask
    runAtRegion(@NotNull org.bukkit.Location location, @NotNull Runnable task)
    Runs a task on the thread owning the given location's region (Folia) or the main thread (legacy).
    @NotNull PlatformTask
    runAtRegionLater(@NotNull org.bukkit.Location location, @NotNull Runnable task, long delayTicks)
    Runs a task on the thread owning the given location's region (Folia) or the main thread (legacy), after a delay.
    @NotNull PlatformTask
    runGlobal(@NotNull Runnable task)
    Runs a task on the global region thread (Folia) or the main thread (legacy).
    @NotNull PlatformTask
    runGlobalLater(@NotNull Runnable task, long delayTicks)
    Runs a task on the global region thread (Folia) or the main thread (legacy), after a delay.
    @NotNull PlatformTask
    runOnEntity(@NotNull org.bukkit.entity.Entity entity, @NotNull Runnable task, @Nullable Runnable retired)
    Runs a task on the thread owning the entity's region (Folia) or the main thread (legacy).
    @NotNull PlatformTask
    runOnEntityAtFixedRate(@NotNull org.bukkit.entity.Entity entity, @NotNull Runnable task, @Nullable Runnable retired, long delayTicks, long periodTicks)
    Runs a task repeatedly on the thread owning the entity's region (Folia) or the main thread (legacy).
    @NotNull PlatformTask
    runOnEntityLater(@NotNull org.bukkit.entity.Entity entity, @NotNull Runnable task, @Nullable Runnable retired, long delayTicks)
    Runs a task on the thread owning the entity's region (Folia) or the main thread (legacy), after a delay.

    Methods inherited from class java.lang.Object

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

    • BukkitPlatformScheduler

      public BukkitPlatformScheduler(@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
  • Method Details

    • runOnEntity

      @NotNull public @NotNull PlatformTask runOnEntity(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task, @Nullable @Nullable Runnable retired)
      Description copied from interface: PlatformScheduler
      Runs a task on the thread owning the entity's region (Folia) or the main thread (legacy).
      Specified by:
      runOnEntity in interface PlatformScheduler
      Parameters:
      entity - the entity whose region owns the task
      task - the work to run
      retired - run instead of task if the entity is removed before it fires (Folia only); ignored on legacy
      Returns:
      a cancellable handle
    • runOnEntityLater

      @NotNull public @NotNull PlatformTask runOnEntityLater(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task, @Nullable @Nullable Runnable retired, long delayTicks)
      Description copied from interface: PlatformScheduler
      Runs a task on the thread owning the entity's region (Folia) or the main thread (legacy), after a delay.
      Specified by:
      runOnEntityLater in interface PlatformScheduler
      Parameters:
      entity - the entity whose region owns the task
      task - the work to run
      retired - run instead of task if the entity is removed before it fires (Folia only); ignored on legacy
      delayTicks - delay in ticks before the task fires; clamped to at least 1
      Returns:
      a cancellable handle
    • runOnEntityAtFixedRate

      @NotNull public @NotNull PlatformTask runOnEntityAtFixedRate(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task, @Nullable @Nullable Runnable retired, long delayTicks, long periodTicks)
      Description copied from interface: PlatformScheduler
      Runs a task repeatedly on the thread owning the entity's region (Folia) or the main thread (legacy).
      Specified by:
      runOnEntityAtFixedRate in interface PlatformScheduler
      Parameters:
      entity - the entity whose region owns the task
      task - the work to run each period
      retired - run instead of task if the entity is removed before it fires (Folia only); ignored on legacy
      delayTicks - delay in ticks before the first execution; clamped to at least 1
      periodTicks - interval in ticks between subsequent executions; clamped to at least 1
      Returns:
      a cancellable handle
    • runAtRegion

      @NotNull public @NotNull PlatformTask runAtRegion(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable task)
      Description copied from interface: PlatformScheduler
      Runs a task on the thread owning the given location's region (Folia) or the main thread (legacy).
      Specified by:
      runAtRegion in interface PlatformScheduler
      Parameters:
      location - the location whose region owns the task
      task - the work to run
      Returns:
      a cancellable handle
    • runAtRegionLater

      @NotNull public @NotNull PlatformTask runAtRegionLater(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable task, long delayTicks)
      Description copied from interface: PlatformScheduler
      Runs a task on the thread owning the given location's region (Folia) or the main thread (legacy), after a delay.
      Specified by:
      runAtRegionLater in interface PlatformScheduler
      Parameters:
      location - the location whose region owns the task
      task - the work to run
      delayTicks - delay in ticks before the task fires; clamped to at least 1
      Returns:
      a cancellable handle
    • runGlobal

      @NotNull public @NotNull PlatformTask runGlobal(@NotNull @NotNull Runnable task)
      Description copied from interface: PlatformScheduler
      Runs a task on the global region thread (Folia) or the main thread (legacy).
      Specified by:
      runGlobal in interface PlatformScheduler
      Parameters:
      task - the work to run
      Returns:
      a cancellable handle
    • runGlobalLater

      @NotNull public @NotNull PlatformTask runGlobalLater(@NotNull @NotNull Runnable task, long delayTicks)
      Description copied from interface: PlatformScheduler
      Runs a task on the global region thread (Folia) or the main thread (legacy), after a delay.
      Specified by:
      runGlobalLater in interface PlatformScheduler
      Parameters:
      task - the work to run
      delayTicks - delay in ticks before the task fires; clamped to at least 1
      Returns:
      a cancellable handle
    • ownsRegion

      public boolean ownsRegion(@NotNull @NotNull org.bukkit.entity.Entity entity)
      Specified by:
      ownsRegion in interface PlatformScheduler
      Parameters:
      entity - the entity to check
      Returns:
      true if the current thread owns the entity's region (Folia) or is the main thread (legacy) — i.e. it is safe to touch the entity now.
    • ownsRegion

      public boolean ownsRegion(@NotNull @NotNull org.bukkit.Location location)
      Specified by:
      ownsRegion in interface PlatformScheduler
      Parameters:
      location - the location to check
      Returns:
      true if the current thread owns the given location's region (Folia) or is the main thread (legacy) — i.e. it is safe to touch that location now.