Optimize timerTaskList iterating

This commit is contained in:
sandtechnology committed 2021-08-11 02:42:22 +08:00
1 parent fd3aaecaf2
commit 064822b31e
1 file changed
+6 -4
@@ -636,12 +636,14 @@ public class QuickShop extends JavaPlugin {
if (logWatcher != null) {
logWatcher.close();
}
for (BukkitTask bukkitTask : timerTaskList) {
if (!bukkitTask.isCancelled()) {
bukkitTask.cancel();
Iterator<BukkitTask> taskIterator = timerTaskList.iterator();
while (taskIterator.hasNext()) {
BukkitTask task = taskIterator.next();
if (!task.isCancelled()) {
task.cancel();
}
taskIterator.remove();
}
timerTaskList.clear();
if (calendarWatcher != null) {
calendarWatcher.stop();
}