diff --git a/src/main/java/com/gmail/nossr50/database/queuemanager/AsyncQueueManager.java b/src/main/java/com/gmail/nossr50/database/queuemanager/AsyncQueueManager.java index d24077b1d..e92e67718 100644 --- a/src/main/java/com/gmail/nossr50/database/queuemanager/AsyncQueueManager.java +++ b/src/main/java/com/gmail/nossr50/database/queuemanager/AsyncQueueManager.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.database.queuemanager; import java.util.concurrent.LinkedBlockingQueue; - public class AsyncQueueManager implements Runnable { private LinkedBlockingQueue queue; @@ -13,6 +12,7 @@ public class AsyncQueueManager implements Runnable { this.running = true; } + @Override public void run() { while(running) { @@ -23,19 +23,15 @@ public class AsyncQueueManager implements Runnable { } } } - - public void disable() { - running = false; - } public boolean queue(Queueable task) { return queue.offer(task); } - + public boolean contains(String player) { return queue.contains(new EqualString(player)); } - + private class EqualString { private String player; public EqualString(String player) { @@ -50,4 +46,16 @@ public class AsyncQueueManager implements Runnable { } } + public void disable() { + running = false; + // Throw one more Queueable into queue to unblock take() + queue.add(new EndThread()); + } + + private class EndThread implements Queueable { + @Override + public void run() { } + @Override + public String getPlayer() { return null; } + } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index b594942c8..89be61427 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -176,6 +176,10 @@ public class mcMMO extends JavaPlugin { catch (NullPointerException e) {} getServer().getScheduler().cancelTasks(this); // This removes our tasks + if (Config.getInstance().getUseMySQL()) { + queueManager.disable(); + queueManager = null; + } HandlerList.unregisterAll(this); // Cancel event registrations if (Config.getInstance().getBackupsEnabled()) {