Add simpler API for using the scheduler. Adds BUKKIT-836
The new methods return the actual task that gets created from the scheduler. They are also named such that auto-complete puts the asynchronous methods after the normal ones. These two additions are simply semantic. Tasks now have a method to cancel themselves using their task id. This is provided as a convenience. A new class called SimpleRunnable was added. It is an abstract Runnable such that anonymous classes may subclass it. It provides six convenience methods for scheduling as appropriate. It also provides a cancel method for convenience. The functionality of SimpleRunnable only stores an integer representing the task id. A SimpleRunnable can only be scheduled once; attempting to reschedule results in IllegalStateException.
This commit is contained in:
@@ -28,4 +28,9 @@ public interface BukkitTask {
|
||||
* @return true if the task is run by main thread
|
||||
*/
|
||||
public boolean isSync();
|
||||
|
||||
/**
|
||||
* Will attempt to cancel this task
|
||||
*/
|
||||
public void cancel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user