public abstract class Task extends Object implements Runnable
一个任务可以被Nukkit服务器立即,延时,循环或延时循环执行。参见:ServerScheduler
A task can be executed by Nukkit server with a/an express, delay, repeat or delay&repeat.
See:ServerScheduler
对于插件开发者,为确保自己任务能够在安全的情况下执行(比如:在插件被禁用时不执行),
建议让任务继承PluginTask类而不是这个类。
For plugin developers: To make sure your task will only be executed in the case of safety
(such as: prevent this task from running if its owner plugin is disabled),
it's suggested to use PluginTask instead of extend this class.
| Constructor and Description |
|---|
Task() |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel() |
TaskHandler |
getHandler() |
int |
getTaskId() |
void |
onCancel() |
abstract void |
onRun(int currentTick)
这个任务被执行时,会调用的过程。
What will be called when the task is executed. |
void |
run() |
void |
setHandler(TaskHandler taskHandler) |
public final TaskHandler getHandler()
public final int getTaskId()
public final void setHandler(TaskHandler taskHandler)
public abstract void onRun(int currentTick)
currentTick - 服务器从开始运行到现在所经过的tick数,20ticks = 1秒,1tick = 0.05秒。public void onCancel()
public void cancel()
Copyright © 2020. All rights reserved.