Class IncrementalRunnable

java.lang.Object
org.bukkit.scheduler.BukkitRunnable
us.talabrek.ultimateskyblock.async.IncrementalRunnable
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ChunkSnapShotTask, SetBiomeTask, WorldEditClear, WorldEditClearFlatlandTask

public abstract class IncrementalRunnable extends org.bukkit.scheduler.BukkitRunnable
Convenience template class for executing heavy tasks on the main thread.

Usage

     new IncrementalRunnable() {
         boolean execute() {
             while (!isDone()) {
                 // Do something incrementially synchronously
                 if (!tick()) {
                     break;
                 }
             }
             return isDone();
         }
     }
 
  • Constructor Details

    • IncrementalRunnable

      public IncrementalRunnable(uSkyBlock plugin)
    • IncrementalRunnable

      public IncrementalRunnable(uSkyBlock plugin, Runnable onCompletion)
    • IncrementalRunnable

      public IncrementalRunnable(uSkyBlock plugin, Runnable onCompletion, int maxMs, int maxConsecutive, int yieldDelay)
  • Method Details

    • stillTime

      public boolean stillTime()
    • getPlugin

      public uSkyBlock getPlugin()
    • getTimeElapsed

      public long getTimeElapsed()
      Returns the number of ms the task has been active.
      Returns:
      the number of ms the task has been active.
    • getTimeUsed

      public double getTimeUsed()
      Returns the number of ms the task has been actively executing.
      Returns:
      the number of ms the task has been actively executing.
    • cancel

      public void cancel()
      Overrides:
      cancel in class org.bukkit.scheduler.BukkitRunnable
    • run

      public final void run()
    • getTicks

      public int getTicks()