Package me.totalfreedom.service
Class FreedomExecutor
java.lang.Object
me.totalfreedom.service.FreedomExecutor
This is a holder class for
Executor objects that are used to delegate runnable tasks to the Bukkit Scheduler.
This class is here for both convenience purposes, and also for the sake of providing easy access to executors for
CompletableFuture invocations.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasynchronousDelayedExecutor(org.bukkit.plugin.java.JavaPlugin plugin, long delay) Creates a newExecutorthat is capable of executing a runnable one singular time, asynchronously.asynchronousPeriodicExecutor(org.bukkit.plugin.java.JavaPlugin plugin, long delay, long period) Creates a newExecutortthat is capable of executing a runnable on a periodic basis, asynchronously.asynchronousSingleExecutor(org.bukkit.plugin.java.JavaPlugin plugin) Creates a newExecutorthat is capable of executing a runnable one singular time, asynchronously.delayedExecutor(org.bukkit.plugin.java.JavaPlugin plugin, long delay) Creates a newExecutorthat is capable of executing a runnable one singular time, synchronously.getAsync()Gets the asynchronous executor instance.getSync()Gets the synchronous executor instance.periodicExecutor(org.bukkit.plugin.java.JavaPlugin plugin, long initialDelay, long period) Creates a newExecutortthat is capable of executing a runnable on a periodic basis, synchronously.singleExecutor(org.bukkit.plugin.java.JavaPlugin plugin) Creates a newExecutorthat is capable of executing a runnable one singular time, synchronously.
-
Constructor Details
-
FreedomExecutor
public FreedomExecutor()Creates a newFreedomExecutorinstance.
-
-
Method Details
-
singleExecutor
Creates a newExecutorthat is capable of executing a runnable one singular time, synchronously.- Parameters:
plugin- The plugin to run the task for.- Returns:
- A new
Executorinstance.
-
delayedExecutor
Creates a newExecutorthat is capable of executing a runnable one singular time, synchronously. This Executor will wait for the supplied delay before executing the runnable.- Parameters:
plugin- The plugin to run the task for.delay- The delay to wait before executing the runnable.- Returns:
- A new
Executorinstance.
-
periodicExecutor
public Executor periodicExecutor(org.bukkit.plugin.java.JavaPlugin plugin, long initialDelay, long period) Creates a newExecutortthat is capable of executing a runnable on a periodic basis, synchronously. This executor can also be supplied a delay to indicate it should wait the specified amount of time before executing the runnable for the first time.- Parameters:
plugin- The plugin to run the task for.initialDelay- The delay to wait before executing the runnable for the first time.period- The period to wait between each execution of the runnable.- Returns:
- A new
Executorinstance.
-
asynchronousSingleExecutor
Creates a newExecutorthat is capable of executing a runnable one singular time, asynchronously.- Parameters:
plugin- The plugin to run the task for.- Returns:
- A new
Executorinstance.
-
asynchronousDelayedExecutor
Creates a newExecutorthat is capable of executing a runnable one singular time, asynchronously. This Executor will wait for the supplied delay before executing the runnable.- Parameters:
plugin- The plugin to run the task for.delay- The delay to wait before executing the runnable.- Returns:
- A new
Executorinstance.
-
asynchronousPeriodicExecutor
public Executor asynchronousPeriodicExecutor(org.bukkit.plugin.java.JavaPlugin plugin, long delay, long period) Creates a newExecutortthat is capable of executing a runnable on a periodic basis, asynchronously. This executor can also be supplied a delay to indicate it should wait the specified amount of time before executing the runnable for the first time.- Parameters:
plugin- The plugin to run the task for.delay- The delay to wait before executing the runnable for the first time.period- The period to wait between each execution of the runnable.- Returns:
- A new
Executorinstance.
-
getSync
Gets the synchronous executor instance. This is a convenience forCompletableFutureinvocations, when defining a custom executor for theCompletableFuture.- Returns:
- The synchronous executor instance.
-
getAsync
Gets the asynchronous executor instance. This is a convenience forCompletableFutureinvocations, when defining a custom executor for theCompletableFuture.- Returns:
- The asynchronous executor instance.
-