mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-15 20:51:21 +01:00
Fixed Crash on disable if calling ProcessingQueue methods (#515)
This commit is contained in:
parent
b52782298e
commit
db81d34214
@ -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.Log;
|
||||
import com.djrapitops.plugin.settings.ColorScheme;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
/**
|
||||
@ -100,7 +101,10 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
||||
Log.info(Locale.get(Msg.DISABLED).toString());
|
||||
Benchmark.pluginDisabled(Plan.class);
|
||||
DebugLog.pluginDisabled(Plan.class);
|
||||
if (!reloading) {
|
||||
TaskCenter.cancelAllKnownTasks(Plan.class);
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,6 +23,5 @@ public class BukkitDBSystem extends DBSystem {
|
||||
|
||||
String dbType = Settings.DB_TYPE.toString().toLowerCase().trim();
|
||||
db = getActiveDatabaseByName(dbType);
|
||||
db.init();
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ import java.util.concurrent.BlockingQueue;
|
||||
*/
|
||||
public abstract class Queue<T> {
|
||||
|
||||
protected boolean run = true;
|
||||
protected final BlockingQueue<T> queue;
|
||||
protected Setup<T> setup;
|
||||
|
||||
@ -30,8 +31,10 @@ public abstract class Queue<T> {
|
||||
* @param object Object to add.
|
||||
*/
|
||||
public void add(T object) {
|
||||
if (run) {
|
||||
queue.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to stop the queue processing and get the unprocessed objects.
|
||||
@ -39,6 +42,7 @@ public abstract class Queue<T> {
|
||||
* @return List of unprocessed objects.
|
||||
*/
|
||||
public List<T> stopAndReturnLeftovers() {
|
||||
run = false;
|
||||
try {
|
||||
if (setup != null) {
|
||||
setup.stop();
|
||||
@ -54,6 +58,7 @@ public abstract class Queue<T> {
|
||||
* Stops all activity and clears the queue.
|
||||
*/
|
||||
public void stop() {
|
||||
run = false;
|
||||
if (setup != null) {
|
||||
setup.stop();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user