Spigot repeating task

Spigot repeating task

Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
    @Override
    public void run() {
        Bukkit.broadcastMessage("Your Message Here");
    }
}, 5L, 40L); //5 Tick initial delay, 40 Tick (2 Second) between repeats

Spigot cancel repeating task

int taskID;
public void startCountdown(){
	taskID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this,new Countdown(),40L,40L);
}
public void stopCountdown(){
	Bukkit.getServer().getScheduler().cancelTask(taskID);
}
// 20L = 1 Second
// 40L = 2 Second
Content Protection by DMCA.com
Please Share