Class DelayedSingleTask

java.lang.Object
com.comphenix.protocol.injector.DelayedSingleTask

public class DelayedSingleTask extends Object
Represents a single delayed task.
Author:
Kristian
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected org.bukkit.plugin.Plugin
     
    protected org.bukkit.scheduler.BukkitScheduler
     
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DelayedSingleTask​(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 Type
    Method
    Description
    boolean
    Cancel a future task from being executed.
    void
    Stop the current task and all future tasks scheduled by this instance.
    protected void
     
    org.bukkit.plugin.Plugin
    Retrieve the plugin this task belongs to.
    int
    Retrieve the raw task ID.
    boolean
    Whether or not a future task is scheduled to be executed.
    boolean
    schedule​(long ticksDelay, Runnable task)
    Schedule a single task for execution.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public boolean schedule(long ticksDelay, Runnable task)
      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

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable