Class SchedulerManager

java.lang.Object
dev.cwhead.GravesX.manager.SchedulerManager

public final class SchedulerManager extends Object
Fire-and-forget scheduler wrapper around GlobalScheduler.
  • Constructor Details

    • SchedulerManager

      public SchedulerManager(@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
      Creates a scheduler manager for the given plugin.
      Parameters:
      plugin - owning plugin
  • Method Details

    • getScheduler

      @NotNull public @NotNull me.croabeast.scheduler.GlobalScheduler getScheduler()
      Returns the backing GlobalScheduler.
      Returns:
      scheduler instance
    • getPlugin

      @NotNull public @NotNull org.bukkit.plugin.Plugin getPlugin()
      Returns the owning Plugin.
      Returns:
      plugin instance
    • returnable

      @NotNull public @NotNull SchedulerManager.Returnable returnable()
      Returns the handle-returning API.
      Returns:
      returnable helper
    • isGlobalThread

      public boolean isGlobalThread()
      Checks if the current thread is the global scheduler thread for this runtime.
      Returns:
      true if on global thread, otherwise false
    • isTickThread

      public boolean isTickThread()
      Checks if the current thread is the tick/primary thread.
      Returns:
      true if on tick thread, otherwise false
    • isEntityThread

      public boolean isEntityThread(@NotNull @NotNull org.bukkit.entity.Entity entity)
      Checks if the current thread owns the specified entity's region.
      Parameters:
      entity - entity to check
      Returns:
      true if the current thread owns the entity region, otherwise false
    • isRegionThread

      public boolean isRegionThread(@NotNull @NotNull org.bukkit.Location location)
      Checks if the current thread owns the region containing the specified location.
      Parameters:
      location - location to check (world must be non-null)
      Returns:
      true if the current thread owns the region, otherwise false
    • callSyncMethod

      @NotNull public <T> @NotNull Future<T> callSyncMethod(@NotNull @NotNull Callable<T> task)
      Calls a task on the global/main thread and returns a Future.
      Type Parameters:
      T - result type
      Parameters:
      task - callable to execute
      Returns:
      future result
    • runTask

      public void runTask(@NotNull @NotNull Runnable runnable)
      Schedules a task for the next tick (global/main).
      Parameters:
      runnable - task to run
    • runTask

      @Deprecated public void runTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable runnable)
      Deprecated.
      Schedules a task for the next tick (legacy signature).
      Parameters:
      plugin - plugin (legacy parameter)
      runnable - task to run
    • runTaskLater

      public void runTaskLater(@NotNull @NotNull Runnable runnable, long delay)
      Schedules a delayed task (global/main).
      Parameters:
      runnable - task to run
      delay - delay in ticks
    • runTaskLater

      @Deprecated public void runTaskLater(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable runnable, long delay)
      Schedules a delayed task (legacy signature).
      Parameters:
      plugin - plugin (legacy parameter)
      runnable - task to run
      delay - delay in ticks
    • runTaskTimer

      public void runTaskTimer(@NotNull @NotNull Runnable runnable, long delay, long period)
      Schedules a repeating task (global/main).
      Parameters:
      runnable - task to run
      delay - initial delay in ticks
      period - period in ticks
    • runTaskTimer

      @Deprecated public void runTaskTimer(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable runnable, long delay, long period)
      Schedules a repeating task (legacy signature).
      Parameters:
      plugin - plugin (legacy parameter)
      runnable - task to run
      delay - initial delay in ticks
      period - period in ticks
    • runTask

      public void runTask(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable runnable)
      Schedules a task on the region that owns the provided location.
      Parameters:
      location - location context
      runnable - task to run
    • runTaskLater

      public void runTaskLater(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable runnable, long delay)
      Schedules a delayed task on the region that owns the provided location.
      Parameters:
      location - location context
      runnable - task to run
      delay - delay in ticks
    • runTaskTimer

      public void runTaskTimer(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable runnable, long delay, long period)
      Schedules a repeating task on the region that owns the provided location.
      Parameters:
      location - location context
      runnable - task to run
      delay - initial delay in ticks
      period - period in ticks
    • runTask

      public void runTask(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable runnable)
      Schedules a task on the region that owns the provided entity.
      Parameters:
      entity - entity context
      runnable - task to run
    • runTaskLater

      public void runTaskLater(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable runnable, long delay)
      Schedules a delayed task on the region that owns the provided entity.
      Parameters:
      entity - entity context
      runnable - task to run
      delay - delay in ticks
    • runTaskTimer

      public void runTaskTimer(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable runnable, long delay, long period)
      Schedules a repeating task on the region that owns the provided entity.
      Parameters:
      entity - entity context
      runnable - task to run
      delay - initial delay in ticks
      period - period in ticks
    • runTaskAsynchronously

      public void runTaskAsynchronously(@NotNull @NotNull Runnable runnable)
      Schedules an async task immediately.
      Parameters:
      runnable - task to run
    • runTaskAsynchronously

      @Deprecated public void runTaskAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable runnable)
      Schedules an async task immediately (legacy signature).
      Parameters:
      plugin - plugin (legacy parameter)
      runnable - task to run
    • runTaskLaterAsynchronously

      public void runTaskLaterAsynchronously(@NotNull @NotNull Runnable runnable, long delay)
      Schedules an async task after a delay.
      Parameters:
      runnable - task to run
      delay - delay in ticks
    • runTaskLaterAsynchronously

      @Deprecated public void runTaskLaterAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable runnable, long delay)
      Schedules an async task after a delay (legacy signature).
      Parameters:
      plugin - plugin (legacy parameter)
      runnable - task to run
      delay - delay in ticks
    • runTaskTimerAsynchronously

      public void runTaskTimerAsynchronously(@NotNull @NotNull Runnable runnable, long delay, long period)
      Schedules a repeating async task.
      Parameters:
      runnable - task to run
      delay - initial delay in ticks
      period - period in ticks
    • runTaskTimerAsynchronously

      @Deprecated public void runTaskTimerAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable runnable, long delay, long period)
      Schedules a repeating async task (legacy signature).
      Parameters:
      plugin - plugin (legacy parameter)
      runnable - task to run
      delay - initial delay in ticks
      period - period in ticks
    • scheduleSyncDelayedTask

      @Deprecated public void scheduleSyncDelayedTask(@NotNull @NotNull Runnable runnable)
      Deprecated.
      Legacy alias for runTask(Runnable).
      Parameters:
      runnable - task to run
    • scheduleSyncDelayedTask

      @Deprecated public void scheduleSyncDelayedTask(@NotNull @NotNull Runnable runnable, long delay)
      Parameters:
      runnable - task to run
      delay - delay in ticks
    • scheduleSyncRepeatingTask

      @Deprecated public void scheduleSyncRepeatingTask(@NotNull @NotNull Runnable runnable, long delay, long period)
      Parameters:
      runnable - task to run
      delay - initial delay in ticks
      period - period in ticks
    • execute

      public void execute(@NotNull @NotNull Runnable runnable)
      Executes a task on the global/main thread.
      Parameters:
      runnable - task to run
    • execute

      public void execute(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable runnable)
      Executes a task on the region that owns the provided location.
      Parameters:
      location - location context
      runnable - task to run
    • execute

      public void execute(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable runnable)
      Executes a task on the region that owns the provided entity.
      Parameters:
      entity - entity context
      runnable - task to run
    • cancel

      public void cancel(@Nullable @Nullable me.croabeast.scheduler.GlobalTask task)
      Cancels a task handle if present.
      Parameters:
      task - task handle (nullable)
    • cancel

      public void cancel(int taskId)
      Cancels a task by id.
      Parameters:
      taskId - task id
    • cancelAll

      public void cancelAll()
      Cancels all tasks scheduled by the owning plugin.
    • cancelAll

      public void cancelAll(@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
      Cancels all tasks scheduled by the specified plugin.
      Parameters:
      plugin - target plugin