Interface BukkitScheduler
-
Method Summary
Modifier and TypeMethodDescriptioncallSyncMethod
(@NotNull Plugin plugin, @NotNull Callable<T> task) Deprecated.Calls a method on the main thread and returns a Future object.void
cancelTask
(int taskId) Deprecated.Removes task from scheduler.void
cancelTasks
(@NotNull Plugin plugin) Deprecated.Removes all tasks associated with a particular plugin from the scheduler.Deprecated.Returns a list of all active workers.getMainThreadExecutor
(@NotNull Plugin plugin) Deprecated.Returns an executor that will run tasks on the next server tick.Deprecated.Returns a list of all pending tasks.boolean
isCurrentlyRunning
(int taskId) Deprecated.Check if the task currently running.boolean
isQueued
(int taskId) Deprecated.Check if the task queued to be run later.Deprecated.Returns a task that will run on the next server tick.void
Deprecated.Returns a task that will run on the next server tick.runTask
(@NotNull Plugin plugin, @NotNull BukkitRunnable task) Deprecated.runTaskAsynchronously
(@NotNull Plugin plugin, @NotNull Runnable task) Deprecated.Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.void
runTaskAsynchronously
(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task) Deprecated.Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.runTaskAsynchronously
(@NotNull Plugin plugin, @NotNull BukkitRunnable task) Deprecated.runTaskLater
(@NotNull Plugin plugin, @NotNull Runnable task, long delay) Deprecated.Returns a task that will run after the specified number of server ticks.void
runTaskLater
(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task, long delay) Deprecated.Returns a task that will run after the specified number of server ticks.runTaskLater
(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay) Deprecated.runTaskLaterAsynchronously
(@NotNull Plugin plugin, @NotNull Runnable task, long delay) Deprecated.Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.void
runTaskLaterAsynchronously
(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task, long delay) Deprecated.Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.runTaskLaterAsynchronously
(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay) Deprecated.runTaskTimer
(@NotNull Plugin plugin, @NotNull Runnable task, long delay, long period) Deprecated.Returns a task that will repeatedly run until cancelled, starting after the specified number of server ticks.void
runTaskTimer
(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task, long delay, long period) Deprecated.Returns a task that will repeatedly run until cancelled, starting after the specified number of server ticks.runTaskTimer
(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay, long period) Deprecated.runTaskTimerAsynchronously
(@NotNull Plugin plugin, @NotNull Runnable task, long delay, long period) Deprecated.Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.void
runTaskTimerAsynchronously
(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task, long delay, long period) Deprecated.Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.runTaskTimerAsynchronously
(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay, long period) Deprecated.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" taskint
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" taskint
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" taskint
scheduleSyncDelayedTask
(@NotNull Plugin plugin, @NotNull Runnable task) Deprecated.Schedules a once off task to occur as soon as possible.int
scheduleSyncDelayedTask
(@NotNull Plugin plugin, @NotNull Runnable task, long delay) Deprecated.Schedules a once off task to occur after a delay.int
scheduleSyncDelayedTask
(@NotNull Plugin plugin, @NotNull BukkitRunnable task) Deprecated.int
scheduleSyncDelayedTask
(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay) Deprecated.int
scheduleSyncRepeatingTask
(@NotNull Plugin plugin, @NotNull Runnable task, long delay, long period) Deprecated.Schedules a repeating task.int
scheduleSyncRepeatingTask
(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay, long period) Deprecated.
-
Method Details
-
scheduleSyncDelayedTask
int scheduleSyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay) Deprecated.Schedules a once off task to occur after a delay.This task will be executed by the main server thread.
- Parameters:
plugin
- Plugin that owns the tasktask
- Task to be executeddelay
- Delay in server ticks before executing task- Returns:
- Task id number (-1 if scheduling failed)
-
scheduleSyncDelayedTask
@Deprecated int scheduleSyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay) Deprecated.- Parameters:
plugin
- Plugin that owns the tasktask
- Task to be executeddelay
- Delay in server ticks before executing task- Returns:
- Task id number (-1 if scheduling failed)
-
scheduleSyncDelayedTask
Deprecated.Schedules a once off task to occur as soon as possible.This task will be executed by the main server thread.
- Parameters:
plugin
- Plugin that owns the tasktask
- Task to be executed- Returns:
- Task id number (-1 if scheduling failed)
-
scheduleSyncDelayedTask
@Deprecated int scheduleSyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task) Deprecated.- Parameters:
plugin
- Plugin that owns the tasktask
- Task to be executed- Returns:
- Task id number (-1 if scheduling failed)
-
scheduleSyncRepeatingTask
int scheduleSyncRepeatingTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period) Deprecated.Schedules a repeating task.This task will be executed by the main server thread.
- Parameters:
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- Returns:
- Task id number (-1 if scheduling failed)
-
scheduleSyncRepeatingTask
@Deprecated int scheduleSyncRepeatingTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay, long period) Deprecated.- Parameters:
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- Returns:
- Task id number (-1 if scheduling failed)
-
scheduleAsyncDelayedTask
@Deprecated int scheduleAsyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay) Deprecated.This name is misleading, as it does not schedule "a sync" task, but rather, "an async" taskAsynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.Schedules a once off task to occur after a delay. This task will be executed by a thread managed by the scheduler.
- Parameters:
plugin
- Plugin that owns the tasktask
- Task to be executeddelay
- Delay in server ticks before executing task- Returns:
- Task id number (-1 if scheduling failed)
-
scheduleAsyncDelayedTask
@Deprecated int scheduleAsyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task) Deprecated.This name is misleading, as it does not schedule "a sync" task, but rather, "an async" taskAsynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.Schedules a once off task to occur as soon as possible. This task will be executed by a thread managed by the scheduler.
- Parameters:
plugin
- Plugin that owns the tasktask
- Task to be executed- Returns:
- Task id number (-1 if scheduling failed)
-
scheduleAsyncRepeatingTask
@Deprecated int scheduleAsyncRepeatingTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period) Deprecated.This name is misleading, as it does not schedule "a sync" task, but rather, "an async" taskAsynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.Schedules a repeating task. This task will be executed by a thread managed by the scheduler.
- Parameters:
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- Returns:
- Task id number (-1 if scheduling failed)
-
callSyncMethod
@NotNull <T> @NotNull Future<T> callSyncMethod(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Callable<T> task) Deprecated.Calls a method on the main thread and returns a Future object. This task will be executed by the main server thread.- Note: The Future.get() methods must NOT be called from the main thread.
- Note2: There is at least an average of 10ms latency until the isDone() method returns true.
- Type Parameters:
T
- The callable's return type- Parameters:
plugin
- Plugin that owns the tasktask
- Task to be executed- Returns:
- Future Future object related to the task
-
cancelTask
void cancelTask(int taskId) Deprecated.Removes task from scheduler.- Parameters:
taskId
- Id number of task to be removed
-
cancelTasks
Deprecated.Removes all tasks associated with a particular plugin from the scheduler.- Parameters:
plugin
- Owner of tasks to be removed
-
isCurrentlyRunning
boolean isCurrentlyRunning(int taskId) Deprecated.Check if the task currently running.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.
- Parameters:
taskId
- The task to check.- Returns:
- If the task is currently running.
-
isQueued
boolean isQueued(int taskId) Deprecated.Check if the task queued to be run later.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.
- Parameters:
taskId
- The task to check.- Returns:
- If the task is queued to be run.
-
getActiveWorkers
Deprecated.Returns a list of all active workers.This list contains asynch tasks that are being executed by separate threads.
- Returns:
- Active workers
-
getPendingTasks
Deprecated.Returns a list of all pending tasks. The ordering of the tasks is not related to their order of execution.- Returns:
- Active workers
-
runTask
@NotNull @NotNull BukkitTask runTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task) throws IllegalArgumentException Deprecated.Returns a task that will run on the next server tick.- Parameters:
plugin
- the reference to the plugin scheduling tasktask
- the task to be run- Returns:
- a BukkitTask that contains the id number
- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTask
void runTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task) throws IllegalArgumentException Deprecated.Returns a task that will run on the next server tick.- Parameters:
plugin
- the reference to the plugin scheduling tasktask
- the task to be run- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTask
@Deprecated @NotNull @NotNull BukkitTask runTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task) throws IllegalArgumentException Deprecated.- Parameters:
plugin
- the reference to the plugin scheduling tasktask
- the task to be run- Returns:
- a BukkitTask that contains the id number
- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskAsynchronously
@NotNull @NotNull BukkitTask runTaskAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task) throws IllegalArgumentException Deprecated.Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.Returns a task that will run asynchronously.
- Parameters:
plugin
- the reference to the plugin scheduling tasktask
- the task to be run- Returns:
- a BukkitTask that contains the id number
- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskAsynchronously
void runTaskAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task) throws IllegalArgumentException Deprecated.Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.Returns a task that will run asynchronously.
- Parameters:
plugin
- the reference to the plugin scheduling tasktask
- the task to be run- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskAsynchronously
@Deprecated @NotNull @NotNull BukkitTask runTaskAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task) throws IllegalArgumentException Deprecated.- Parameters:
plugin
- the reference to the plugin scheduling tasktask
- the task to be run- Returns:
- a BukkitTask that contains the id number
- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskLater
@NotNull @NotNull BukkitTask runTaskLater(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay) throws IllegalArgumentException Deprecated.Returns a task that will run after the specified number of server ticks.- Parameters:
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the task- Returns:
- a BukkitTask that contains the id number
- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskLater
void runTaskLater(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task, long delay) throws IllegalArgumentException Deprecated.Returns a task that will run after the specified number of server ticks.- Parameters:
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the task- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskLater
@Deprecated @NotNull @NotNull BukkitTask runTaskLater(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay) throws IllegalArgumentException Deprecated.- Parameters:
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the task- Returns:
- a BukkitTask that contains the id number
- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskLaterAsynchronously
@NotNull @NotNull BukkitTask runTaskLaterAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay) throws IllegalArgumentException Deprecated.Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.Returns a task that will run asynchronously after the specified number of server ticks.
- Parameters:
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the task- Returns:
- a BukkitTask that contains the id number
- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskLaterAsynchronously
void runTaskLaterAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task, long delay) throws IllegalArgumentException Deprecated.Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.Returns a task that will run asynchronously after the specified number of server ticks.
- Parameters:
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the task- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskLaterAsynchronously
@Deprecated @NotNull @NotNull BukkitTask runTaskLaterAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay) throws IllegalArgumentException Deprecated.- Parameters:
plugin
- the reference to the plugin scheduling tasktask
- the task to be rundelay
- the ticks to wait before running the task- Returns:
- a BukkitTask that contains the id number
- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskTimer
@NotNull @NotNull BukkitTask runTaskTimer(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period) throws IllegalArgumentException Deprecated.Returns a task that will repeatedly run until cancelled, starting after the specified number of server ticks.- Parameters:
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 runs- Returns:
- a BukkitTask that contains the id number
- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskTimer
void runTaskTimer(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task, long delay, long period) throws IllegalArgumentException Deprecated.Returns a task that will repeatedly run until cancelled, starting after the specified number of server ticks.- Parameters:
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 runs- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskTimer
@Deprecated @NotNull @NotNull BukkitTask runTaskTimer(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay, long period) throws IllegalArgumentException Deprecated.- Parameters:
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 runs- Returns:
- a BukkitTask that contains the id number
- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskTimerAsynchronously
@NotNull @NotNull BukkitTask runTaskTimerAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period) throws IllegalArgumentException Deprecated.Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.Returns a task that will repeatedly run asynchronously until cancelled, starting after the specified number of server ticks.
- Parameters:
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 runs- Returns:
- a BukkitTask that contains the id number
- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskTimerAsynchronously
void runTaskTimerAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task, long delay, long period) throws IllegalArgumentException Deprecated.Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.Returns a task that will repeatedly run asynchronously until cancelled, starting after the specified number of server ticks.
- Parameters:
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 runs- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
runTaskTimerAsynchronously
@Deprecated @NotNull @NotNull BukkitTask runTaskTimerAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay, long period) throws IllegalArgumentException Deprecated.- Parameters:
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 runs- Returns:
- a BukkitTask that contains the id number
- Throws:
IllegalArgumentException
- if plugin is nullIllegalArgumentException
- if task is null
-
getMainThreadExecutor
Deprecated.Returns an executor that will run tasks on the next server tick.- Parameters:
plugin
- the reference to the plugin scheduling tasks- Returns:
- an executor associated with the given plugin
-
RegionScheduler
,AsyncScheduler
,EntityScheduler
, orGlobalRegionScheduler