How to stop re-scheduling tasks in Bukit
I am writing a minigame for Minecraft and have a graphics problem. I don't know how to stop the schedule. Please tell me how can I stop this cycle / Timer / Schedule from starting:
public void WarteTimer() {
count = Bukkit.getScheduler().scheduleSyncRepeatingTask(
(Plugin) this,
new Runnable() {
@Override
public void run() {
if (countdown > 0) {
Bukkit.broadcastMessage("ยง6Countdown : " +countdown);
countdown--;
} else {
Game();
//Bukkit.getScheduler().cancelTask(count);
//countdown = 5;
}
}
},
0L,
20L);
}
+3
source to share
1 answer
To stop the scheduler in bukkit, you have to get the scheduler id and call the Bukkit scheduler cancel method.
I see that you have already set count
equal to the scheduler. I am assuming that count
is an integer.
To stop the scheduler, just put:
Bukkit.getScheduler().cancelTask(taskID);
In your case, you would use:
Bukkit.getScheduler().cancelTask(count);
You can run this line where ever and it will stop your scheduler.
+3
source to share