Fixed Crash on disable if calling ProcessingQueue methods (#515)

This commit is contained in:
Rsl1122 2018-01-30 13:35:53 +02:00
parent b52782298e
commit db81d34214
3 changed files with 11 additions and 3 deletions

View File

@ -34,6 +34,7 @@ import com.djrapitops.plugin.api.systems.TaskCenter;
import com.djrapitops.plugin.api.utility.log.DebugLog; import com.djrapitops.plugin.api.utility.log.DebugLog;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
/** /**
@ -100,7 +101,10 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
Log.info(Locale.get(Msg.DISABLED).toString()); Log.info(Locale.get(Msg.DISABLED).toString());
Benchmark.pluginDisabled(Plan.class); Benchmark.pluginDisabled(Plan.class);
DebugLog.pluginDisabled(Plan.class); DebugLog.pluginDisabled(Plan.class);
TaskCenter.cancelAllKnownTasks(Plan.class); if (!reloading) {
TaskCenter.cancelAllKnownTasks(Plan.class);
Bukkit.getScheduler().cancelTasks(this);
}
} }
@Override @Override

View File

@ -23,6 +23,5 @@ public class BukkitDBSystem extends DBSystem {
String dbType = Settings.DB_TYPE.toString().toLowerCase().trim(); String dbType = Settings.DB_TYPE.toString().toLowerCase().trim();
db = getActiveDatabaseByName(dbType); db = getActiveDatabaseByName(dbType);
db.init();
} }
} }

View File

@ -12,6 +12,7 @@ import java.util.concurrent.BlockingQueue;
*/ */
public abstract class Queue<T> { public abstract class Queue<T> {
protected boolean run = true;
protected final BlockingQueue<T> queue; protected final BlockingQueue<T> queue;
protected Setup<T> setup; protected Setup<T> setup;
@ -30,7 +31,9 @@ public abstract class Queue<T> {
* @param object Object to add. * @param object Object to add.
*/ */
public void add(T object) { public void add(T object) {
queue.add(object); if (run) {
queue.add(object);
}
} }
/** /**
@ -39,6 +42,7 @@ public abstract class Queue<T> {
* @return List of unprocessed objects. * @return List of unprocessed objects.
*/ */
public List<T> stopAndReturnLeftovers() { public List<T> stopAndReturnLeftovers() {
run = false;
try { try {
if (setup != null) { if (setup != null) {
setup.stop(); setup.stop();
@ -54,6 +58,7 @@ public abstract class Queue<T> {
* Stops all activity and clears the queue. * Stops all activity and clears the queue.
*/ */
public void stop() { public void stop() {
run = false;
if (setup != null) { if (setup != null) {
setup.stop(); setup.stop();
} }