Class TaskScheduler

java.lang.Object
com.welcome234.pluginsystem.TaskScheduler
All Implemented Interfaces:
Runnable

public abstract class TaskScheduler extends Object implements Runnable
Task Schedulers are used to run tasks with the ticking of the server.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Cancels this task and will no longer be executed by the server
    int
    Gets the current ID number of this task
    Gets the plugin that runs this task
    boolean
    Gets whether this task is currently running and is still being executed by the server
    void
    runLater​(PluginJava plugin, int delay)
    Runs this task delayed after the specified tick count
    void
    runTimer​(PluginJava plugin, int delay, int period)
    Runs this task repeatedly with the specified tick interval

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Runnable

    run
  • Constructor Details

    • TaskScheduler

      public TaskScheduler()
  • Method Details

    • isRunning

      public boolean isRunning()
      Gets whether this task is currently running and is still being executed by the server
      Returns:
      Whether running
    • getID

      public int getID()
      Gets the current ID number of this task
      Returns:
      The task ID
      Throws:
      IllegalArgumentException - if this task is not running
    • getOwner

      public PluginJava getOwner()
      Gets the plugin that runs this task
      Returns:
      Plugin instance
      Throws:
      IllegalArgumentException - if this task is not running
    • cancel

      public void cancel()
      Cancels this task and will no longer be executed by the server
      Throws:
      IllegalArgumentException - if this task is not running
    • runLater

      public void runLater(PluginJava plugin, int delay)
      Runs this task delayed after the specified tick count
      Parameters:
      plugin - Plugin instance
      delay - Delay in ticks
      Throws:
      IllegalArgumentException - if plugin is null
      IllegalArgumentException - if the task is already started and running
      IllegalStateException - if the plugin is disabled or is not loaded
    • runTimer

      public void runTimer(PluginJava plugin, int delay, int period)
      Runs this task repeatedly with the specified tick interval
      Parameters:
      plugin - Plugin instance
      delay - Delay in ticks
      period - Interval in ticks
      Throws:
      IllegalArgumentException - if plugin is null
      IllegalArgumentException - if the task is already started and running
      IllegalStateException - if the plugin is disabled or is not loaded