Package com.comphenix.protocol.injector
Class DelayedSingleTask
java.lang.Object
com.comphenix.protocol.injector.DelayedSingleTask
Represents a single delayed task.
- Author:
- Kristian
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDelayedSingleTask(org.bukkit.plugin.Plugin plugin)Create a single task scheduler.DelayedSingleTask(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitScheduler scheduler)Create a single task scheduler. -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel()Cancel a future task from being executed.voidclose()Stop the current task and all future tasks scheduled by this instance.protected voidfinalize()org.bukkit.plugin.PluginRetrieve the plugin this task belongs to.intRetrieve the raw task ID.booleanWhether or not a future task is scheduled to be executed.booleanSchedule a single task for execution.
-
Field Details
-
taskID
protected int taskID -
plugin
protected org.bukkit.plugin.Plugin plugin -
scheduler
protected org.bukkit.scheduler.BukkitScheduler scheduler -
closed
protected boolean closed
-
-
Constructor Details
-
DelayedSingleTask
public DelayedSingleTask(org.bukkit.plugin.Plugin plugin)Create a single task scheduler.- Parameters:
plugin- - owner plugin.
-
DelayedSingleTask
public DelayedSingleTask(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitScheduler scheduler)Create a single task scheduler.- Parameters:
plugin- - owner plugin.scheduler- - specialized scheduler.
-
-
Method Details
-
schedule
Schedule a single task for execution.Any previously scheduled task will be automatically cancelled.
Note that a tick delay of zero will execute the task immediately.
- Parameters:
ticksDelay- - number of ticks before the task is executed.task- - the task to schedule.- Returns:
- TRUE if the task was successfully scheduled or executed, FALSE otherwise.
-
isRunning
public boolean isRunning()Whether or not a future task is scheduled to be executed.- Returns:
- TRUE if a current task has been scheduled for execution, FALSE otherwise.
-
cancel
public boolean cancel()Cancel a future task from being executed.- Returns:
- TRUE if a task was cancelled, FALSE otherwise.
-
getTaskID
public int getTaskID()Retrieve the raw task ID.- Returns:
- Raw task ID, or negative one if no task has been scheduled.
-
getPlugin
public org.bukkit.plugin.Plugin getPlugin()Retrieve the plugin this task belongs to.- Returns:
- The plugin scheduling the current taks.
-
close
public void close()Stop the current task and all future tasks scheduled by this instance. -
finalize
-