Class ExecutorSpigot
java.lang.Object
nl.pim16aap2.animatedarchitecture.spigot.util.implementations.ExecutorSpigot
- All Implemented Interfaces:
IExecutor
Implementation of
IExecutor for the Spigot platform.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCancels a task.booleanisMainThread(long threadId) Checks if a thread is the main thread.intSchedules an action to be run asynchronously.voidrunAsyncLater(Runnable runnable, long delay) Schedules a repeatedRunnableto be run asynchronously.voidrunAsyncLater(TimerTask timerTask, long delay) Schedules a repeatedTimerTaskto be run asynchronously.intrunAsyncRepeated(Runnable runnable, long delay, long period) Schedules a repeatedRunnableto be run asynchronously.intrunAsyncRepeated(TimerTask timerTask, long delay, long period) Schedules a repeatedTimerTaskto be run asynchronously.intSchedules an action to be run on the main thread.voidrunSyncLater(Runnable runnable, long delay) Schedules a repeatedRunnableto be run on the main thread.voidrunSyncLater(TimerTask timerTask, long delay) Schedules a repeatedTimerTaskto be run on the main thread.intrunSyncRepeated(Runnable runnable, long delay, long period) Schedules a repeatedRunnableto be run on the main thread.intrunSyncRepeated(TimerTask timerTask, long delay, long period) Schedules a repeatedTimerTaskto be run on the main thread.voidscheduleOnMainThread(Runnable runnable) Schedules an action to be run on the main thread.<T> CompletableFuture<T> scheduleOnMainThread(Supplier<T> supplier) Schedules a task to be run on the main thread.<T> CompletableFuture<T> supplyAsync(Supplier<T> supplier) Schedules a task to be run on the main thread.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface nl.pim16aap2.animatedarchitecture.core.api.IExecutor
assertMainThread, assertMainThread, assertNotMainThread, assertNotMainThread, composeOnMainThread, isMainThread, runOnMainThread, runOnMainThread, runOnMainThreadWithResponse
-
Constructor Details
-
ExecutorSpigot
@Inject public ExecutorSpigot(org.bukkit.plugin.java.JavaPlugin plugin, @Named("mainThreadId") long mainThreadId)
-
-
Method Details
-
scheduleOnMainThread
Description copied from interface:IExecutorSchedules a task to be run on the main thread.- Specified by:
scheduleOnMainThreadin interfaceIExecutor- Parameters:
supplier- A function returning the value to be used to complete the returned IMainThreadExecutor.- Returns:
- The result of the action.
-
scheduleOnMainThread
Description copied from interface:IExecutorSchedules an action to be run on the main thread.- Specified by:
scheduleOnMainThreadin interfaceIExecutor
-
supplyAsync
Description copied from interface:IExecutorSchedules a task to be run on the main thread.- Specified by:
supplyAsyncin interfaceIExecutor- Parameters:
supplier- A function returning the value to be used to complete the returned IMainThreadExecutor.- Returns:
- The result of the action.
-
runAsync
Description copied from interface:IExecutorSchedules an action to be run asynchronously. -
runSync
Description copied from interface:IExecutorSchedules an action to be run on the main thread. -
runAsyncRepeated
Description copied from interface:IExecutorSchedules a repeatedTimerTaskto be run asynchronously.- Specified by:
runAsyncRepeatedin interfaceIExecutor- 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
Description copied from interface:IExecutorSchedules a repeatedRunnableto be run asynchronously.- Specified by:
runAsyncRepeatedin interfaceIExecutor- 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
Description copied from interface:IExecutorSchedules a repeatedTimerTaskto be run on the main thread.- Specified by:
runSyncRepeatedin interfaceIExecutor- 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
Description copied from interface:IExecutorSchedules a repeatedRunnableto be run on the main thread.- Specified by:
runSyncRepeatedin interfaceIExecutor- 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
Description copied from interface:IExecutorSchedules a repeatedTimerTaskto be run asynchronously.- Specified by:
runAsyncLaterin interfaceIExecutor- Parameters:
timerTask- The task to run.delay- The delay in milliseconds before the task is to be executed.
-
runAsyncLater
Description copied from interface:IExecutorSchedules a repeatedRunnableto be run asynchronously.- Specified by:
runAsyncLaterin interfaceIExecutor- Parameters:
runnable- The task to run.delay- The delay in milliseconds before the task is to be executed.
-
runSyncLater
Description copied from interface:IExecutorSchedules a repeatedTimerTaskto be run on the main thread.- Specified by:
runSyncLaterin interfaceIExecutor- Parameters:
timerTask- The task to run.delay- The delay in milliseconds before the task is to be executed.
-
runSyncLater
Description copied from interface:IExecutorSchedules a repeatedRunnableto be run on the main thread.- Specified by:
runSyncLaterin interfaceIExecutor- Parameters:
runnable- The task to run.delay- The delay in milliseconds before the task is to be executed.
-
cancel
Description copied from interface:IExecutorCancels a task. -
isMainThread
public boolean isMainThread(long threadId) Description copied from interface:IExecutorChecks if a thread is the main thread.- Specified by:
isMainThreadin interfaceIExecutor- Parameters:
threadId- The ID of the thread to compare.- Returns:
- True if the thread is the main thread.
-