public interface BukkitScheduler
限定符和类型 | 方法和说明 |
---|---|
<T> java.util.concurrent.Future<T> |
callSyncMethod(Plugin plugin,
java.util.concurrent.Callable<T> task)
调用主线程的一个方法并返回Future对象.这个任务将被服务器主线程执行.
|
void |
cancelAllTasks()
取消执行所有在执行器中的任务.
|
void |
cancelTask(int taskId)
从执行器中取消执行一个任务.
|
void |
cancelTasks(Plugin plugin)
取消执行特定的插件所请求的所有任务.
|
java.util.List<BukkitWorker> |
getActiveWorkers()
返回所有激活的worker.
|
java.util.List<BukkitTask> |
getPendingTasks()
返回所有挂起(就绪/阻塞等)的任务.任务的顺序与它们的执行顺序无关.
|
boolean |
isCurrentlyRunning(int taskId)
检测任务是否正在运行.
|
boolean |
isQueued(int taskId)
检测这个任务是否正在排队等待执行.
|
BukkitTask |
runTask(Plugin plugin,
BukkitRunnable task)
已过时。
|
BukkitTask |
runTask(Plugin plugin,
java.lang.Runnable task)
返回下一个tick服务器将运行的任务.
|
BukkitTask |
runTaskAsynchronously(Plugin plugin,
BukkitRunnable task)
|
BukkitTask |
runTaskAsynchronously(Plugin plugin,
java.lang.Runnable task)
异步任务不应访问Bukkit里的任何API.应着重保证异步任务的线程安全.
|
BukkitTask |
runTaskLater(Plugin plugin,
BukkitRunnable task,
long delay)
|
BukkitTask |
runTaskLater(Plugin plugin,
java.lang.Runnable task,
long delay)
返回指定tick过后运行的任务(即延迟执行).
|
BukkitTask |
runTaskLaterAsynchronously(Plugin plugin,
BukkitRunnable task,
long delay)
|
BukkitTask |
runTaskLaterAsynchronously(Plugin plugin,
java.lang.Runnable task,
long delay)
异步任务不应访问Bukkit里的任何API.应着重保证异步任务的线程安全.
|
BukkitTask |
runTaskTimer(Plugin plugin,
BukkitRunnable task,
long delay,
long period)
|
BukkitTask |
runTaskTimer(Plugin plugin,
java.lang.Runnable task,
long delay,
long period)
返回一个任务.此任务将在指定tick数值后运行.任务将重复运行直至取消.
|
BukkitTask |
runTaskTimerAsynchronously(Plugin plugin,
BukkitRunnable task,
long delay,
long period)
|
BukkitTask |
runTaskTimerAsynchronously(Plugin plugin,
java.lang.Runnable task,
long delay,
long period)
异步任务不应访问Bukkit里的任何API.应着重保证异步任务的线程安全.
|
int |
scheduleAsyncDelayedTask(Plugin plugin,
java.lang.Runnable task)
已过时。
这个名称具有误导性.因为它没有执行“同步”任务.而是“异步”任务
|
int |
scheduleAsyncDelayedTask(Plugin plugin,
java.lang.Runnable task,
long delay)
已过时。
这个名称具有误导性.因为它没有执行“同步”任务.而是“异步”任务
|
int |
scheduleAsyncRepeatingTask(Plugin plugin,
java.lang.Runnable task,
long delay,
long period)
已过时。
这个名称具有误导性.因为它没有执行“同步”任务.而是“异步”任务
|
int |
scheduleSyncDelayedTask(Plugin plugin,
BukkitRunnable task)
已过时。
|
int |
scheduleSyncDelayedTask(Plugin plugin,
BukkitRunnable task,
long delay)
|
int |
scheduleSyncDelayedTask(Plugin plugin,
java.lang.Runnable task)
在下一tick执行一次任务.
|
int |
scheduleSyncDelayedTask(Plugin plugin,
java.lang.Runnable task,
long delay)
在指定延迟后执行一次任务.
|
int |
scheduleSyncRepeatingTask(Plugin plugin,
BukkitRunnable task,
long delay,
long period)
|
int |
scheduleSyncRepeatingTask(Plugin plugin,
java.lang.Runnable task,
long delay,
long period)
在指定延迟后开始以指定间隔重复执行任务.
|
int scheduleSyncDelayedTask(Plugin plugin, java.lang.Runnable task, long delay)
这个任务将由服务器主线程执行(同步).
原文:Schedules a once off task to occur after a delay.
This task will be executed by the main server thread.
plugin
- 创建这个任务的插件(拥有者)task
- 要执行的任务delay
- 服务器执行任务之前的延迟/tick@Deprecated int scheduleSyncDelayedTask(Plugin plugin, BukkitRunnable task, long delay)
plugin
- 创建这个任务的插件(拥有者)task
- 要执行的任务delay
- 服务器执行任务之前的延迟/tickint scheduleSyncDelayedTask(Plugin plugin, java.lang.Runnable task)
.这个任务将由服务器主线程执行(同步).
原文:Schedules a once off task to occur as soon as possible.
This task will be executed by the main server thread.
plugin
- 创建这个任务的插件(拥有者)task
- 要执行的任务@Deprecated int scheduleSyncDelayedTask(Plugin plugin, BukkitRunnable task)
BukkitRunnable.runTask(Plugin)
这个任务将由服务器主线程执行(同步).
原文:Schedules a once off task to occur as soon as possible.
This task will be executed by the main server thread.
plugin
- 创建这个任务的插件(拥有者)task
- 要执行的任务int scheduleSyncRepeatingTask(Plugin plugin, java.lang.Runnable task, long delay, long period)
这个任务将由服务器主线程执行(同步).
原文:Schedules a repeating task.
This task will be executed by the main server thread.
plugin
- 创建这个任务的插件(拥有者)task
- 要执行的任务delay
- 开始第一次重复执行之前的延迟/tickperiod
- 任务执行的时间@Deprecated int scheduleSyncRepeatingTask(Plugin plugin, BukkitRunnable task, long delay, long period)
plugin
- 创建这个任务的插件(拥有者)task
- 要执行的任务delay
- 开始第一次重复执行之前的延迟/tickperiod
- 任务执行的时间@Deprecated int scheduleAsyncDelayedTask(Plugin plugin, java.lang.Runnable task, long delay)
在指定延迟后执行一次任务.此任务将通过由执行器所管理的线程执行.
原文:Asynchronous 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.
plugin
- 创建这个任务的插件(拥有者)task
- 要执行的任务delay
- 服务器执行任务之前的延迟/tick@Deprecated int scheduleAsyncDelayedTask(Plugin plugin, java.lang.Runnable task)
执行一次任务.此任务将通过由执行器所管理的线程执行.
原文:Asynchronous 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.
plugin
- 创建这个任务的插件(拥有者)task
- 要执行的任务@Deprecated int scheduleAsyncRepeatingTask(Plugin plugin, java.lang.Runnable task, long delay, long period)
执行一次重复执行的任务.此任务将通过由执行器所管理的线程执行.
原文:Asynchronous 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.
plugin
- 创建这个任务的插件(拥有者)task
- 要执行的任务delay
- 开始第一次重复执行之前的延迟/tickperiod
- 每次任务执行之间的间隔<T> java.util.concurrent.Future<T> callSyncMethod(Plugin plugin, java.util.concurrent.Callable<T> task)
原文:Calls a method on the main thread and returns a Future object. This task will be executed by the main server thread.
T
- callable的返回类型plugin
- 创建这个任务的插件(拥有者)task
- 要执行的任务void cancelTask(int taskId)
原文:Removes task from scheduler.
taskId
- 要移除的任务的idvoid cancelTasks(Plugin plugin)
原文:Removes all tasks associated with a particular plugin from the scheduler.
plugin
- 要取消所有任务的插件void cancelAllTasks()
原文:Removes all tasks from the scheduler.
boolean isCurrentlyRunning(int taskId)
一个重复执行的任务可能不是正在运行的.但将在之后运行.一个已完成并且不重复执行的任务将不再运行.
直白地说就是,一个存在的线程在执行一个任务,并这个线程没有死亡.
原文: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.
taskId
- 要检测的任务的id
boolean isQueued(int taskId)
如果一个重复执行的任务正在运行,它现在可能不会被排队,但是可能会在之后发生.一个任务如果不在队列、不在运行.那么将不再排队.
原文: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.
taskId
- 要检测的任务id
java.util.List<BukkitWorker> getActiveWorkers()
这个列表包含了独立线程执行的异步任务.
原文:Returns a list of all active workers.
This list contains asynch tasks that are being executed by separate threads.
java.util.List<BukkitTask> getPendingTasks()
原文:Returns a list of all pending tasks. The ordering of the tasks is not related to their order of execution.
BukkitTask runTask(Plugin plugin, java.lang.Runnable task) throws java.lang.IllegalArgumentException
原文:Returns a task that will run on the next server tick.
plugin
- 执行任务的插件task
- 要运行的任务java.lang.IllegalArgumentException
- 如果插件为nulljava.lang.IllegalArgumentException
- 如果任务为null@Deprecated BukkitTask runTask(Plugin plugin, BukkitRunnable task) throws java.lang.IllegalArgumentException
BukkitRunnable.runTask(Plugin)
plugin
- 执行任务的插件task
- 要运行的任务java.lang.IllegalArgumentException
- 如果插件为nulljava.lang.IllegalArgumentException
- 如果任务为nullBukkitTask runTaskAsynchronously(Plugin plugin, java.lang.Runnable task) throws java.lang.IllegalArgumentException
返回异步执行的任务.
原文: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.
plugin
- 执行任务的插件task
- 要运行的任务java.lang.IllegalArgumentException
- 如果插件为nulljava.lang.IllegalArgumentException
- 如果任务为null@Deprecated BukkitTask runTaskAsynchronously(Plugin plugin, BukkitRunnable task) throws java.lang.IllegalArgumentException
plugin
- 执行任务的插件task
- 要运行的任务java.lang.IllegalArgumentException
- 如果插件为nulljava.lang.IllegalArgumentException
- 如果任务为nullBukkitTask runTaskLater(Plugin plugin, java.lang.Runnable task, long delay) throws java.lang.IllegalArgumentException
原文:Returns a task that will run after the specified number of server ticks.
plugin
- 执行任务的插件task
- 要运行的任务delay
- 服务器执行任务之前的延迟/tickjava.lang.IllegalArgumentException
- 如果插件为nulljava.lang.IllegalArgumentException
- 如果任务为null@Deprecated BukkitTask runTaskLater(Plugin plugin, BukkitRunnable task, long delay) throws java.lang.IllegalArgumentException
plugin
- 执行任务的插件task
- 要运行的任务delay
- 服务器执行任务之前的延迟/tickjava.lang.IllegalArgumentException
- 如果插件为nulljava.lang.IllegalArgumentException
- 如果任务为nullBukkitTask runTaskLaterAsynchronously(Plugin plugin, java.lang.Runnable task, long delay) throws java.lang.IllegalArgumentException
返回指定tick过后运行的异步任务(即延迟执行).
原文: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.
plugin
- 执行任务的插件task
- 要运行的任务delay
- 服务器执行任务之前的延迟/tickjava.lang.IllegalArgumentException
- 如果插件为nulljava.lang.IllegalArgumentException
- 如果任务为null@Deprecated BukkitTask runTaskLaterAsynchronously(Plugin plugin, BukkitRunnable task, long delay) throws java.lang.IllegalArgumentException
plugin
- 执行任务的插件task
- 要运行的任务delay
- 服务器执行任务之前的延迟/tickjava.lang.IllegalArgumentException
- 如果插件为nulljava.lang.IllegalArgumentException
- 如果任务为nullBukkitTask runTaskTimer(Plugin plugin, java.lang.Runnable task, long delay, long period) throws java.lang.IllegalArgumentException
原文:Returns a task that will repeatedly run until cancelled, starting after the specified number of server ticks.
plugin
- 执行任务的插件task
- 要运行的任务delay
- 服务器执行任务之前的延迟/tickperiod
- 重复执行任务之间的时间间隔java.lang.IllegalArgumentException
- 如果插件为nulljava.lang.IllegalArgumentException
- 如果任务为null@Deprecated BukkitTask runTaskTimer(Plugin plugin, BukkitRunnable task, long delay, long period) throws java.lang.IllegalArgumentException
plugin
- 执行任务的插件task
- 要运行的任务delay
- 服务器执行任务之前的延迟/tickperiod
- 重复执行任务之间的时间间隔java.lang.IllegalArgumentException
- 如果插件为nulljava.lang.IllegalArgumentException
- 如果任务为nullBukkitTask runTaskTimerAsynchronously(Plugin plugin, java.lang.Runnable task, long delay, long period) throws java.lang.IllegalArgumentException
返回一个异步任务.此任务将在指定tick数值后运行.任务将重复运行直至取消.
原文: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.
plugin
- 执行任务的插件task
- 要运行的任务delay
- 在任务首次执行前等待的时间period
- 重复执行任务之间的时间间隔java.lang.IllegalArgumentException
- 如果插件为nulljava.lang.IllegalArgumentException
- 如果任务为null@Deprecated BukkitTask runTaskTimerAsynchronously(Plugin plugin, BukkitRunnable task, long delay, long period) throws java.lang.IllegalArgumentException
plugin
- 执行任务的插件task
- 要运行的任务delay
- 在任务首次执行前等待的时间period
- 重复执行任务之间的时间间隔java.lang.IllegalArgumentException
- 如果插件为nulljava.lang.IllegalArgumentException
- 如果任务为null