java.lang.Object
nl.pim16aap2.animatedarchitecture.spigot.util.implementations.ExecutorSpigot
All Implemented Interfaces:
IExecutor

@Singleton public final class ExecutorSpigot extends Object implements IExecutor
Implementation of IExecutor for the Spigot platform.
  • Constructor Details

    • ExecutorSpigot

      @Inject public ExecutorSpigot(org.bukkit.plugin.java.JavaPlugin plugin, @Named("mainThreadId") long mainThreadId)
  • Method Details

    • scheduleOnMainThread

      public <T> CompletableFuture<T> scheduleOnMainThread(Supplier<T> supplier)
      Description copied from interface: IExecutor
      Schedules a task to be run on the main thread.
      Specified by:
      scheduleOnMainThread in interface IExecutor
      Parameters:
      supplier - A function returning the value to be used to complete the returned IMainThreadExecutor.
      Returns:
      The result of the action.
    • scheduleOnMainThread

      public void scheduleOnMainThread(Runnable runnable)
      Description copied from interface: IExecutor
      Schedules an action to be run on the main thread.
      Specified by:
      scheduleOnMainThread in interface IExecutor
    • supplyAsync

      public <T> CompletableFuture<T> supplyAsync(Supplier<T> supplier)
      Description copied from interface: IExecutor
      Schedules a task to be run on the main thread.
      Specified by:
      supplyAsync in interface IExecutor
      Parameters:
      supplier - A function returning the value to be used to complete the returned IMainThreadExecutor.
      Returns:
      The result of the action.
    • runAsync

      public int runAsync(Runnable runnable)
      Description copied from interface: IExecutor
      Schedules an action to be run asynchronously.
      Specified by:
      runAsync in interface IExecutor
      Parameters:
      runnable - The action to run.
      Returns:
      The ID of the task.
    • runSync

      public int runSync(Runnable runnable)
      Description copied from interface: IExecutor
      Schedules an action to be run on the main thread.
      Specified by:
      runSync in interface IExecutor
      Parameters:
      runnable - The action to run.
      Returns:
      The ID of the task.
    • runAsyncRepeated

      public int runAsyncRepeated(TimerTask timerTask, long delay, long period)
      Description copied from interface: IExecutor
      Schedules a repeated TimerTask to be run asynchronously.
      Specified by:
      runAsyncRepeated in interface IExecutor
      Parameters:
      timerTask - The task to run.
      delay - The delay in milliseconds before the task is to be executed.
      period - The time in milliseconds between successive task executions.
      Returns:
      The ID of the task.
    • runAsyncRepeated

      public int runAsyncRepeated(Runnable runnable, long delay, long period)
      Description copied from interface: IExecutor
      Schedules a repeated Runnable to be run asynchronously.
      Specified by:
      runAsyncRepeated in interface IExecutor
      Parameters:
      runnable - The task to run.
      delay - The delay in milliseconds before the task is to be executed.
      period - The time in milliseconds between successive task executions.
      Returns:
      The ID of the task.
    • runSyncRepeated

      public int runSyncRepeated(TimerTask timerTask, long delay, long period)
      Description copied from interface: IExecutor
      Schedules a repeated TimerTask to be run on the main thread.
      Specified by:
      runSyncRepeated in interface IExecutor
      Parameters:
      timerTask - The task to run.
      delay - The delay in milliseconds before the task is to be executed.
      period - The time in milliseconds between successive task executions.
      Returns:
      The ID of the task.
    • runSyncRepeated

      public int runSyncRepeated(Runnable runnable, long delay, long period)
      Description copied from interface: IExecutor
      Schedules a repeated Runnable to be run on the main thread.
      Specified by:
      runSyncRepeated in interface IExecutor
      Parameters:
      runnable - The task to run.
      delay - The delay in milliseconds before the task is to be executed.
      period - The time in milliseconds between successive task executions.
      Returns:
      The ID of the task.
    • runAsyncLater

      public void runAsyncLater(TimerTask timerTask, long delay)
      Description copied from interface: IExecutor
      Schedules a repeated TimerTask to be run asynchronously.
      Specified by:
      runAsyncLater in interface IExecutor
      Parameters:
      timerTask - The task to run.
      delay - The delay in milliseconds before the task is to be executed.
    • runAsyncLater

      public void runAsyncLater(Runnable runnable, long delay)
      Description copied from interface: IExecutor
      Schedules a repeated Runnable to be run asynchronously.
      Specified by:
      runAsyncLater in interface IExecutor
      Parameters:
      runnable - The task to run.
      delay - The delay in milliseconds before the task is to be executed.
    • runSyncLater

      public void runSyncLater(TimerTask timerTask, long delay)
      Description copied from interface: IExecutor
      Schedules a repeated TimerTask to be run on the main thread.
      Specified by:
      runSyncLater in interface IExecutor
      Parameters:
      timerTask - The task to run.
      delay - The delay in milliseconds before the task is to be executed.
    • runSyncLater

      public void runSyncLater(Runnable runnable, long delay)
      Description copied from interface: IExecutor
      Schedules a repeated Runnable to be run on the main thread.
      Specified by:
      runSyncLater in interface IExecutor
      Parameters:
      runnable - The task to run.
      delay - The delay in milliseconds before the task is to be executed.
    • cancel

      public void cancel(TimerTask timerTask, int taskID)
      Description copied from interface: IExecutor
      Cancels a task.
      Specified by:
      cancel in interface IExecutor
      Parameters:
      timerTask - The task that is to be cancelled.
      taskID - The ID assigned to the task.
    • isMainThread

      public boolean isMainThread(long threadId)
      Description copied from interface: IExecutor
      Checks if a thread is the main thread.
      Specified by:
      isMainThread in interface IExecutor
      Parameters:
      threadId - The ID of the thread to compare.
      Returns:
      True if the thread is the main thread.