Scheduling API

This page should explain the scheduling API of QuarterBukkit which drastically improves Bukkit's scheduling API.


The ScheduleTask is a simple abstract class implements Runnable. It can be used for running, stopping and otherwise managing a Scheduler Task. Here's an example:

new ScheduleTask(plugin) {

    public void run() {

        // Your code here
}.run(true, 0, 100);

What this does is simple: You define a new ScheduleTask for the plugin plugin. Then you can run your ScheduleTask. There are two methods:

public ScheduleTask run(boolean sync, long delay)
public ScheduleTask run(boolean sync, long delay, long period)

The sync-argument controls whether the ScheduleTask should run in the Bukkit main thread (could interrupt the game) or in an other thread (could cause Bukkit API problems). The delay and the period must be given in milliseconds, not in ticks. You can convert milliseconds to ticks and ticks to milliseconds using the Math Utilities.

You can also cancel a task by using cancel() and check whether a task is running by using isRunning(). Furthermore, you can add a task to a ScheduleTask collection (maybe to a ScheduleGroup) by using:

public ScheduleTask add(Collection<ScheduleTask> collection)


The ScheduleGroup extends ArrayList<ScheduleTask> and adds the new method cancel() to cancel all running ScheduleTask.

You can add a ScheduleTask directly to a ScheduleGroup by using this method in ScheduleTask:

public ScheduleTask add(Collection<ScheduleTask> collection)