Interface SchedulerAdapter

All Known Implementing Classes:
FoliaScheduler, SpigotScheduler

public interface SchedulerAdapter
An abstraction layer for scheduling tasks across different Minecraft server implementations, such as Folia and Spigot.

Allows seamless compatibility by abstracting scheduling methods.

  • Method Details

    • runEntityTask

      SchedulerTask runEntityTask(Entity entity, Runnable runnable)
      Executes a task specifically linked to an entity immediately. On Spigot, this defaults to the global thread.
    • runEntityTaskLater

      SchedulerTask runEntityTaskLater(Entity entity, Runnable runnable, long delayTicks)
      Executes a task specifically linked to an entity after a delay. On Spigot, this defaults to the global thread.
      Parameters:
      delayTicks - Delay before execution, measured in ticks.
    • runEntityTaskTimer

      SchedulerTask runEntityTaskTimer(Entity entity, Runnable runnable, long delayTicks, long periodTicks)
      Executes a repeating task specifically linked to an entity. On Spigot, this defaults to the global thread.
      Parameters:
      delayTicks - Initial delay before the first execution (in ticks).
      periodTicks - Period between each subsequent execution (in ticks).
    • runRegionTask

      SchedulerTask runRegionTask(Location location, Runnable runnable)
      Executes a task associated with a specific region or chunk. On Spigot, this defaults to the global thread.
    • runRegionTask

      SchedulerTask runRegionTask(World world, int chunkX, int chunkZ, Runnable runnable)
      Executes a task associated with a specific region or chunk. On Spigot, this defaults to the global thread.
    • runRegionTaskLater

      SchedulerTask runRegionTaskLater(Location location, Runnable runnable, long delayTicks)
      Executes a task associated with a specific region or chunk after a delay. On Spigot, this defaults to the global thread.
      Parameters:
      delayTicks - Delay before execution, measured in ticks.
    • runRegionTaskLater

      SchedulerTask runRegionTaskLater(World world, int chunkX, int chunkZ, Runnable runnable, long delayTicks)
      Executes a task associated with a specific region or chunk after a delay. On Spigot, this defaults to the global thread.
      Parameters:
      delayTicks - Delay before execution, measured in ticks.
    • runRegionTaskTimer

      SchedulerTask runRegionTaskTimer(Location location, Runnable runnable, long delayTicks, long periodTicks)
      Executes a repeating task associated with a specific region or chunk. On Spigot, this defaults to the global thread.
      Parameters:
      delayTicks - Initial delay before the first execution (in ticks).
      periodTicks - Period between each subsequent execution (in ticks).
    • runRegionTaskTimer

      SchedulerTask runRegionTaskTimer(World world, int chunkX, int chunkZ, Runnable runnable, long delayTicks, long periodTicks)
      Executes a repeating task associated with a specific region or chunk. On Spigot, this defaults to the global thread.
      Parameters:
      delayTicks - Initial delay before the first execution (in ticks).
      periodTicks - Period between each subsequent execution (in ticks).
    • runTask

      SchedulerTask runTask(Runnable runnable)
      Executes a task on the global server thread.
    • runTaskAsynchronously

      SchedulerTask runTaskAsynchronously(Runnable runnable)
      Executes a task asynchronously immediately, off the main server thread.
    • runTaskLater

      SchedulerTask runTaskLater(Runnable runnable, long delayTicks)
      Executes a task on the global server thread after a specified delay.
      Parameters:
      delayTicks - Delay before execution, measured in server ticks (1 tick = 50ms).
    • runTaskLaterAsynchronously

      SchedulerTask runTaskLaterAsynchronously(Runnable runnable, long delayTicks)
      Executes an asynchronous task after a specified delay.
      Parameters:
      delayTicks - Delay before execution, measured in ticks.
    • runTaskTimer

      SchedulerTask runTaskTimer(Runnable runnable, long delayTicks, long periodTicks)
      Executes a repeating task on the global server thread.
      Parameters:
      delayTicks - Initial delay before the first execution (in ticks).
      periodTicks - Period between each subsequent execution (in ticks).
    • runTaskTimerAsynchronously

      SchedulerTask runTaskTimerAsynchronously(Runnable runnable, long delayTicks, long periodTicks)
      Executes an asynchronous repeating task.
      Parameters:
      delayTicks - Initial delay before the first execution (in ticks).
      periodTicks - Period between each subsequent execution (in ticks).
    • isOnOwnerThread

      boolean isOnOwnerThread(Entity entity)
      Returns true if the current thread is the correct owner thread for safely accessing the target.

      Spigot: true if running on the main server thread.

      Folia: true if the current thread owns the target's region (isOwnedByCurrentRegion).

      Parameters:
      entity - the target entity
      Returns:
      true if the current thread is the owner thread for the entity; false otherwise
    • isOnOwnerThread

      boolean isOnOwnerThread(Location location)
      Returns true if the current thread is the correct owner thread for safely accessing the target.

      Spigot: true if running on the main server thread.

      Folia: true if the current thread owns the target's region (isOwnedByCurrentRegion).

      Parameters:
      location - the target location
      Returns:
      true if the current thread is the owner thread for the location; false otherwise
    • isOnOwnerThread

      boolean isOnOwnerThread(World world, int chunkX, int chunkZ)
      Returns true if the current thread is the correct owner thread for safely accessing the target.

      Spigot: true if running on the main server thread.

      Folia: true if the current thread owns the target's region (isOwnedByCurrentRegion).

      Parameters:
      world - the target world
      chunkX - the target chunk X coordinate
      chunkZ - the target chunk Z coordinate
      Returns:
      true if the current thread is the owner thread for the chunk; false otherwise
    • isOnOwnerThread

      boolean isOnOwnerThread(Block block)
      Returns true if the current thread is the correct owner thread for safely accessing the target.

      Spigot: true if running on the main server thread.

      Folia: true if the current thread owns the target's region (isOwnedByCurrentRegion).

      Parameters:
      block - the target block
      Returns:
      true if the current thread is the owner thread for the block; false otherwise