Interface PluginScheduler


public interface PluginScheduler
Interface for scheduling tasks within a plugin environment.
  • Method Details

    • getMainThreadExecutor

      Executor getMainThreadExecutor()
      Gets the executor for running tasks on the main thread.
      Returns:
      the main thread executor
    • cancelAllTasks

      void cancelAllTasks()
      Cancels all scheduled tasks.
    • cancelTask

      void cancelTask(int taskId)
      Cancels a specific task by its ID.
      Parameters:
      taskId - the ID of the task to cancel
    • runAsync

      int runAsync(Runnable runnable)
      Runs a task asynchronously.
      Parameters:
      runnable - the task to run
      Returns:
      the ID of the scheduled task
    • runSync

      int runSync(Runnable runnable)
      Runs a task synchronously.
      Parameters:
      runnable - the task to run
      Returns:
      the ID of the scheduled task
    • runAtFixedRateAsync

      int runAtFixedRateAsync(Runnable runnable, long initialDelay, long intervalTicks, TimeUnit unit)
      Runs a task at a fixed rate asynchronously.
      Parameters:
      runnable - the task to run
      initialDelay - the delay before the first execution
      intervalTicks - the interval between executions
      unit - the time unit of the interval
      Returns:
      the ID of the scheduled task
    • runAtFixedRateSync

      int runAtFixedRateSync(Runnable runnable, long initialDelay, long intervalTicks, TimeUnit unit)
      Runs a task at a fixed rate synchronously.
      Parameters:
      runnable - the task to run
      initialDelay - the delay before the first execution
      intervalTicks - the interval between executions
      unit - the time unit of the interval
      Returns:
      the ID of the scheduled task
    • runDelayedAsync

      int runDelayedAsync(Runnable runnable, long delayTicks, TimeUnit unit)
      Runs a task after a delay asynchronously.
      Parameters:
      runnable - the task to run
      delayTicks - the delay before execution in ticks
      unit - the time unit of the delay
      Returns:
      the ID of the scheduled task
    • runDelayedSync

      int runDelayedSync(Runnable runnable, long delayTicks, TimeUnit unit)
      Runs a task after a delay synchronously.
      Parameters:
      runnable - the task to run
      delayTicks - the delay before execution in ticks
      unit - the time unit of the delay
      Returns:
      the ID of the scheduled task
    • ensureSync

      void ensureSync(Runnable runnable)
      Ensures a task runs synchronously
      Parameters:
      runnable - the task to run
    • getSync

      <T> CompletableFuture<T> getSync(Supplier<T> supplier)
      Gets a value ensuring the supplier is executed on the main thread
      Type Parameters:
      T - the type of the value
      Parameters:
      supplier - the supplier to get the value from
      Returns:
      a CompletableFuture that will complete with the value