public interface BukkitScheduler
Modifier and Type | Method and Description |
---|---|
<T> @NotNull Future<T> |
callSyncMethod(@NotNull Plugin plugin,
@NotNull Callable<T> task)
Calls a method on the main thread and returns a Future object.
|
void |
cancelTask(int taskId)
Removes task from scheduler.
|
void |
cancelTasks(@NotNull Plugin plugin)
Removes all tasks associated with a particular plugin from the
scheduler.
|
@NotNull List<BukkitWorker> |
getActiveWorkers()
Returns a list of all active workers.
|
Executor |
getMainThreadExecutor(@NotNull Plugin plugin)
Returns an executor that will run tasks on the next server tick.
|
@NotNull List<BukkitTask> |
getPendingTasks()
Returns a list of all pending tasks.
|
boolean |
isCurrentlyRunning(int taskId)
Check if the task currently running.
|
boolean |
isQueued(int taskId)
Check if the task queued to be run later.
|
@NotNull BukkitTask |
runTask(@NotNull Plugin plugin,
@NotNull BukkitRunnable task)
Deprecated.
|
void |
runTask(@NotNull Plugin plugin,
@NotNull Consumer<BukkitTask> task)
Returns a task that will run on the next server tick.
|
@NotNull BukkitTask |
runTask(@NotNull Plugin plugin,
@NotNull Runnable task)
Returns a task that will run on the next server tick.
|
@NotNull BukkitTask |
runTaskAsynchronously(@NotNull Plugin plugin,
@NotNull BukkitRunnable task)
Deprecated.
|
void |
runTaskAsynchronously(@NotNull Plugin plugin,
@NotNull Consumer<BukkitTask> task)
Asynchronous tasks should never access any API in Bukkit.
|
@NotNull BukkitTask |
runTaskAsynchronously(@NotNull Plugin plugin,
@NotNull Runnable task)
Asynchronous tasks should never access any API in Bukkit.
|
@NotNull BukkitTask |
runTaskLater(@NotNull Plugin plugin,
@NotNull BukkitRunnable task,
long delay)
Deprecated.
|
void |
runTaskLater(@NotNull Plugin plugin,
@NotNull Consumer<BukkitTask> task,
long delay)
Returns a task that will run after the specified number of server
ticks.
|
@NotNull BukkitTask |
runTaskLater(@NotNull Plugin plugin,
@NotNull Runnable task,
long delay)
Returns a task that will run after the specified number of server
ticks.
|
@NotNull BukkitTask |
runTaskLaterAsynchronously(@NotNull Plugin plugin,
@NotNull BukkitRunnable task,
long delay)
Deprecated.
|
void |
runTaskLaterAsynchronously(@NotNull Plugin plugin,
@NotNull Consumer<BukkitTask> task,
long delay)
Asynchronous tasks should never access any API in Bukkit.
|
@NotNull BukkitTask |
runTaskLaterAsynchronously(@NotNull Plugin plugin,
@NotNull Runnable task,
long delay)
Asynchronous tasks should never access any API in Bukkit.
|
@NotNull BukkitTask |
runTaskTimer(@NotNull Plugin plugin,
@NotNull BukkitRunnable task,
long delay,
long period)
Deprecated.
|
void |
runTaskTimer(@NotNull Plugin plugin,
@NotNull Consumer<BukkitTask> task,
long delay,
long period)
Returns a task that will repeatedly run until cancelled, starting after
the specified number of server ticks.
|
@NotNull BukkitTask |
runTaskTimer(@NotNull Plugin plugin,
@NotNull Runnable task,
long delay,
long period)
Returns a task that will repeatedly run until cancelled, starting after
the specified number of server ticks.
|
@NotNull BukkitTask |
runTaskTimerAsynchronously(@NotNull Plugin plugin,
@NotNull BukkitRunnable task,
long delay,
long period)
Deprecated.
|
void |
runTaskTimerAsynchronously(@NotNull Plugin plugin,
@NotNull Consumer<BukkitTask> task,
long delay,
long period)
Asynchronous tasks should never access any API in Bukkit.
|
@NotNull BukkitTask |
runTaskTimerAsynchronously(@NotNull Plugin plugin,
@NotNull Runnable task,
long delay,
long period)
Asynchronous tasks should never access any API in Bukkit.
|
int |
scheduleAsyncDelayedTask(@NotNull Plugin plugin,
@NotNull Runnable task)
Deprecated.
This name is misleading, as it does not schedule "a sync"
task, but rather, "an async" task
|
int |
scheduleAsyncDelayedTask(@NotNull Plugin plugin,
@NotNull Runnable task,
long delay)
Deprecated.
This name is misleading, as it does not schedule "a sync"
task, but rather, "an async" task
|
int |
scheduleAsyncRepeatingTask(@NotNull Plugin plugin,
@NotNull Runnable task,
long delay,
long period)
Deprecated.
This name is misleading, as it does not schedule "a sync"
task, but rather, "an async" task
|
int |
scheduleSyncDelayedTask(@NotNull Plugin plugin,
@NotNull BukkitRunnable task)
Deprecated.
|
int |
scheduleSyncDelayedTask(@NotNull Plugin plugin,
@NotNull BukkitRunnable task,
long delay)
Deprecated.
|
int |
scheduleSyncDelayedTask(@NotNull Plugin plugin,
@NotNull Runnable task)
Schedules a once off task to occur as soon as possible.
|
int |
scheduleSyncDelayedTask(@NotNull Plugin plugin,
@NotNull Runnable task,
long delay)
Schedules a once off task to occur after a delay.
|
int |
scheduleSyncRepeatingTask(@NotNull Plugin plugin,
@NotNull BukkitRunnable task,
long delay,
long period)
Deprecated.
|
int |
scheduleSyncRepeatingTask(@NotNull Plugin plugin,
@NotNull Runnable task,
long delay,
long period)
Schedules a repeating task.
|
int scheduleSyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay)
This task will be executed by the main server thread.
plugin
- Plugin that owns the tasktask
- Task to be executeddelay
- Delay in server ticks before executing task@Deprecated int scheduleSyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay)
BukkitRunnable.runTaskLater(Plugin, long)
plugin
- Plugin that owns the tasktask
- Task to be executeddelay
- Delay in server ticks before executing taskint scheduleSyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task)
This task will be executed by the main server thread.
plugin
- Plugin that owns the tasktask
- Task to be executed@Deprecated int scheduleSyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task)
BukkitRunnable.runTask(Plugin)
plugin
- Plugin that owns the tasktask
- Task to be executedint scheduleSyncRepeatingTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period)
This task will be executed by the main server thread.
plugin
- Plugin that owns the tasktask
- Task to be executeddelay
- Delay in server ticks before executing first repeatperiod
- Period in server ticks of the task@Deprecated int scheduleSyncRepeatingTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay, long period)
BukkitRunnable.runTaskTimer(Plugin, long, long)
plugin
- Plugin that owns the tasktask
- Task to be executeddelay
- Delay in server ticks before executing first repeatperiod
- Period in server ticks of the task@Deprecated int scheduleAsyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay)
Schedules a once off task to occur after a delay. This task will be executed by a thread managed by the scheduler.
plugin
- Plugin that owns the tasktask
- Task to be executeddelay
- Delay in server ticks before executing task@Deprecated int scheduleAsyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task)
Schedules a once off task to occur as soon as possible. This task will be executed by a thread managed by the scheduler.
plugin
- Plugin that owns the tasktask
- Task to be executed@Deprecated int scheduleAsyncRepeatingTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period)
Schedules a repeating task. This task will be executed by a thread managed by the scheduler.
plugin
- Plugin that owns the tasktask
- Task to be executeddelay
- Delay in server ticks before executing first repeatperiod
- Period in server ticks of the task@NotNull <T> @NotNull Future<T> callSyncMethod(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Callable<T> task)
T
- The callable's return typeplugin
- Plugin that owns the tasktask
- Task to be executedvoid cancelTask(int taskId)
taskId
- Id number of task to be removedvoid cancelTasks(@NotNull @NotNull Plugin plugin)
plugin
- Owner of tasks to be removedboolean isCurrentlyRunning(int taskId)
A repeating task might not be running currently, but will be running in the future. A task that has finished, and does not repeat, will not be running ever again.
Explicitly, a task is running if there exists a thread for it, and that thread is alive.
taskId
- The task to check.
boolean isQueued(int taskId)
If a repeating task is currently running, it might not be queued now but could be in the future. A task that is not queued, and not running, will not be queued again.
taskId
- The task to check.
@NotNull @NotNull List<BukkitWorker> getActiveWorkers()
This list contains asynch tasks that are being executed by separate threads.
@NotNull @NotNull List<BukkitTask> getPendingTasks()
@NotNull @NotNull BukkitTask runTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task) throws IllegalArgumentException
plugin
- the reference to the plugin scheduling tasktask
- the task to be runIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is nullvoid runTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task) throws IllegalArgumentException
plugin
- the reference to the plugin scheduling tasktask
- the task to be runIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null@Deprecated @NotNull @NotNull BukkitTask runTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task) throws IllegalArgumentException
BukkitRunnable.runTask(Plugin)
plugin
- the reference to the plugin scheduling tasktask
- the task to be runIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null@NotNull @NotNull BukkitTask runTaskAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task) throws IllegalArgumentException
Returns a task that will run asynchronously.
plugin
- the reference to the plugin scheduling tasktask
- the task to be runIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is nullvoid runTaskAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task) throws IllegalArgumentException
Returns a task that will run asynchronously.
plugin
- the reference to the plugin scheduling tasktask
- the task to be runIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null@Deprecated @NotNull @NotNull BukkitTask runTaskAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task) throws IllegalArgumentException
BukkitRunnable.runTaskAsynchronously(Plugin)
plugin
- the reference to the plugin scheduling tasktask
- the task to be runIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null@NotNull @NotNull BukkitTask runTaskLater(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay) throws IllegalArgumentException
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the taskIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is nullvoid runTaskLater(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task, long delay) throws IllegalArgumentException
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the taskIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null@Deprecated @NotNull @NotNull BukkitTask runTaskLater(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay) throws IllegalArgumentException
BukkitRunnable.runTaskLater(Plugin, long)
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the taskIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null@NotNull @NotNull BukkitTask runTaskLaterAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay) throws IllegalArgumentException
Returns a task that will run asynchronously after the specified number of server ticks.
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the taskIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is nullvoid runTaskLaterAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task, long delay) throws IllegalArgumentException
Returns a task that will run asynchronously after the specified number of server ticks.
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the taskIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null@Deprecated @NotNull @NotNull BukkitTask runTaskLaterAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay) throws IllegalArgumentException
BukkitRunnable.runTaskLaterAsynchronously(Plugin, long)
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the taskIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null@NotNull @NotNull BukkitTask runTaskTimer(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period) throws IllegalArgumentException
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the taskperiod
- the ticks to wait between runsIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is nullvoid runTaskTimer(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task, long delay, long period) throws IllegalArgumentException
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the taskperiod
- the ticks to wait between runsIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null@Deprecated @NotNull @NotNull BukkitTask runTaskTimer(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay, long period) throws IllegalArgumentException
BukkitRunnable.runTaskTimer(Plugin, long, long)
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the taskperiod
- the ticks to wait between runsIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null@NotNull @NotNull BukkitTask runTaskTimerAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period) throws IllegalArgumentException
Returns a task that will repeatedly run asynchronously until cancelled, starting after the specified number of server ticks.
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the task for the first
timeperiod
- the ticks to wait between runsIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is nullvoid runTaskTimerAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task, long delay, long period) throws IllegalArgumentException
Returns a task that will repeatedly run asynchronously until cancelled, starting after the specified number of server ticks.
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the task for the first
timeperiod
- the ticks to wait between runsIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null@Deprecated @NotNull @NotNull BukkitTask runTaskTimerAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay, long period) throws IllegalArgumentException
BukkitRunnable.runTaskTimerAsynchronously(Plugin, long, long)
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the task for the first
timeperiod
- the ticks to wait between runsIllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is nullCopyright © 2021. All rights reserved.