Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

bukkit runnable repeating scheduler

// self cancelling example
new BukkitRunnable() {
	int timer = 10;

	@Override
	public void run() {
		if (timer == 0) cancel();
        else Bukkit.broadcastMessage("Starting in: " + timer--);
	}

	@Override // this code can be in run(), its here as a possibility
	public synchronized void cancel() throws IllegalStateException {
        Bukkit.broadcastMessage("Action!");
		super.cancel();
	}
}.runTaskTimer(Main.main(), 0L, 20L); // repeat every second
 
PREVIOUS NEXT
Tagged: #bukkit #runnable #repeating #scheduler
ADD COMMENT
Topic
Name
5+3 =