Package cn.nukkit.scheduler
Class Task
java.lang.Object
cn.nukkit.scheduler.Task
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
ActorSpawnTask
,BlockActorSpawnTask
,LootSpawnTask
,PluginTask
,TileSyncTask
表达一个任务的类。
A class that describes a task.
A class that describes a task.
一个任务可以被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.
- Since:
- Nukkit 1.0 | Nukkit API 1.0.0
- Author:
- MagicDroidX(code) @ Nukkit Project, 粉鞋大妈(javadoc) @ Nukkit Project
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
final TaskHandler
final int
void
onCancel()
abstract void
onRun
(int currentTick) 这个任务被执行时,会调用的过程。
What will be called when the task is executed.final void
run()
final void
setHandler
(TaskHandler taskHandler)
-
Constructor Details
-
Task
public Task()
-
-
Method Details
-
getHandler
-
getTaskId
public final int getTaskId() -
setHandler
-
onRun
public abstract void onRun(int currentTick) 这个任务被执行时,会调用的过程。
What will be called when the task is executed.- Parameters:
currentTick
- 服务器从开始运行到现在所经过的tick数,20ticks = 1秒,1tick = 0.05秒。
The elapsed tick count from the server is started. 20ticks = 1second, 1tick = 0.05second.- Since:
- Nukkit 1.0 | Nukkit API 1.0.0
-
run
public final void run() -
onCancel
public void onCancel() -
cancel
public void cancel()
-