Class PluginTask<T>
java.lang.Object
org.cloudburstmc.server.scheduler.Task
org.cloudburstmc.server.scheduler.PluginTask<T>
- All Implemented Interfaces:
Runnable
Represents a task created by a plugin.
For plugin developers: Tasks that extend this class, won't be executed when the plugin is disabled.
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);
}
}
If you want Cloudburst to execute this task with delay or repeat, use ServerScheduler.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.cloudburstmc.api.plugin.PluginContainergetOwner()Returns the owner of this task.Methods inherited from class org.cloudburstmc.server.scheduler.Task
cancel, getHandler, getTaskId, onCancel, onRun, run, setHandler
-
Field Details
-
owner
-
container
protected final org.cloudburstmc.api.plugin.PluginContainer container
-
-
Constructor Details
-
PluginTask
Constructs a plugin-owned task.- Parameters:
owner- The plugin object that owns this task.
-
-
Method Details
-
getOwner
Returns the owner of this task.- Returns:
- The plugin object that owns this task.
-
getContainer
@Nonnull public org.cloudburstmc.api.plugin.PluginContainer getContainer()
-