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 Summary
ConstructorDescriptionIncrementalRunnable
(uSkyBlock plugin) IncrementalRunnable
(uSkyBlock plugin, Runnable onCompletion) IncrementalRunnable
(uSkyBlock plugin, Runnable onCompletion, int maxMs, int maxConsecutive, int yieldDelay) -
Method Summary
Methods inherited from class org.bukkit.scheduler.BukkitRunnable
getTaskId, isCancelled, runTask, runTaskAsynchronously, runTaskLater, runTaskLaterAsynchronously, runTaskTimer, runTaskTimerAsynchronously
-
Constructor Details
-
IncrementalRunnable
-
IncrementalRunnable
-
IncrementalRunnable
-
-
Method Details
-
stillTime
public boolean stillTime() -
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 classorg.bukkit.scheduler.BukkitRunnable
-
run
public final void run() -
getTicks
public int getTicks()
-