Properly cleanup in the case of a reload - towards #100

This commit is contained in:
Luck
2016-12-23 11:28:42 +00:00
Unverified
parent f4f9612789
commit b35f3b4375
8 changed files with 163 additions and 20 deletions
@@ -39,7 +39,7 @@ import java.util.UUID;
public class AbstractListener {
private final LuckPermsPlugin plugin;
protected void onAsyncLogin(UUID u, String username) {
public void onAsyncLogin(UUID u, String username) {
final long startTime = System.currentTimeMillis();
final UuidCache cache = plugin.getUuidCache();
@@ -58,6 +58,9 @@ public class DebugHandler {
private final Map<Receiver, List<String>> listeners;
private final Queue<Data> queue;
@Setter
private boolean shutdown = false;
public DebugHandler(Executor executor, String pluginVersion) {
this.pluginVersion = "v" + pluginVersion;
listeners = new ConcurrentHashMap<>();
@@ -69,6 +72,10 @@ public class DebugHandler {
handleOutput(e.getChecked(), e.getNode(), e.getValue());
}
if (shutdown) {
return;
}
try {
Thread.sleep(200);
} catch (InterruptedException ignored) {}
@@ -24,6 +24,7 @@ package me.lucko.luckperms.common.utils;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import com.google.common.base.Splitter;
@@ -41,6 +42,9 @@ public class PermissionCache {
private final Node rootNode;
private final Queue<String> queue;
@Setter
private boolean shutdown = false;
public PermissionCache(Executor executor) {
rootNode = new Node();
queue = new ConcurrentLinkedQueue<>();
@@ -51,10 +55,13 @@ public class PermissionCache {
insert(e.toLowerCase());
}
if (shutdown) {
return;
}
try {
Thread.sleep(5000);
} catch (InterruptedException ignored) {
}
} catch (InterruptedException ignored) {}
}
});
}