mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-31 17:23:42 +01:00 
			
		
		
		
	Clean queuemanager on disable
This commit is contained in:
		| @@ -2,7 +2,6 @@ package com.gmail.nossr50.database.queuemanager; | ||||
|  | ||||
| import java.util.concurrent.LinkedBlockingQueue; | ||||
|  | ||||
|  | ||||
| public class AsyncQueueManager implements Runnable { | ||||
|  | ||||
|     private LinkedBlockingQueue<Queueable> 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; }      | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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()) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 T00thpick1
					T00thpick1