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.
This commit is contained in:
Alexander Söderberg 2019-11-10 12:10:38 +01:00
parent 37280779b0
commit a221d6fd07

View File

@ -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) {