From a221d6fd07848b807dd82a3c7f3fe1a3a16ba063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Sun, 10 Nov 2019 12:10:38 +0100 Subject: [PATCH] Run tasks synchronously on Bukkit when the plugin is disabled. Previously, the tasks would fail to run, as the scheduler prevents disabled plugins from running tasks. This would cause problems on server shutdown, especially when the SQLManager attempts to perform database queries. This fixes #2446. --- .../plotsquared/bukkit/util/BukkitTaskManager.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitTaskManager.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitTaskManager.java index 56448ff34..0d00f7741 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitTaskManager.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitTaskManager.java @@ -24,8 +24,12 @@ public class BukkitTaskManager extends TaskManager { } @Override public void taskAsync(Runnable runnable) { - this.bukkitMain.getServer().getScheduler().runTaskAsynchronously(this.bukkitMain, runnable) - .getTaskId(); + if (this.bukkitMain.isEnabled()) { + this.bukkitMain.getServer().getScheduler() + .runTaskAsynchronously(this.bukkitMain, runnable).getTaskId(); + } else { + runnable.run(); + } } @Override public void task(Runnable runnable) {