Package cn.nukkit.scheduler
Class PluginTask<T extends Plugin>
java.lang.Object
cn.nukkit.scheduler.Task
cn.nukkit.scheduler.PluginTask<T>
- Type Parameters:
T
- 这个任务所属的插件。
The plugin that owns this task.
- All Implemented Interfaces:
Runnable
插件创建的任务。
Task that created by a plugin.
An example for plugin create a task:
Task that created by a plugin.
对于插件作者,通过继承这个类创建的任务,可以在插件被禁用时不被执行。
For plugin developers: Tasks that extend this class, won't be executed when the plugin is disabled.
另外,继承这个类的任务可以通过getOwner()
来获得这个任务所属的插件。
Otherwise, tasks that extend this class can use getOwner()
to get its owner.
An example for plugin create a task:
public class ExampleTask extends PluginTask<ExamplePlugin>{
public ExampleTask(ExamplePlugin plugin){
super(plugin);
}
@Override
public void onRun(int currentTick){
getOwner().getLogger().info("Task is executed in tick "+currentTick);
}
}
如果要让Nukkit能够延时或循环执行这个任务,请使用ServerScheduler
。
If you want Nukkit to execute this task with delay or repeat, use ServerScheduler
.
- Since:
- Nukkit 1.0 | Nukkit API 1.0.0
- Author:
- MagicDroidX(code) @ Nukkit Project, 粉鞋大妈(javadoc) @ Nukkit Project
-
Field Summary
-
Constructor Summary
-
Method Summary
Methods inherited from class cn.nukkit.scheduler.Task
cancel, getHandler, getTaskId, onCancel, onRun, run, setHandler
-
Field Details
-
owner
-
-
Constructor Details
-
PluginTask
构造一个插件拥有的任务的方法。
Constructs a plugin-owned task.- Parameters:
owner
- 这个任务的所有者插件。
The plugin object that owns this task.- Since:
- Nukkit 1.0 | Nukkit API 1.0.0
-
-
Method Details
-
getOwner
返回这个任务的所有者插件。
Returns the owner of this task.- Returns:
- 这个任务的所有者插件。
The plugin that owns this task. - Since:
- Nukkit 1.0 | Nukkit API 1.0.0
-