From 8d86eed0a79d6ba264276585467e54cb516920a2 Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 15 Feb 2017 19:39:24 +0000 Subject: [PATCH] Don't bother adding checks to the listener queue if no listeners are registered --- .../lucko/luckperms/common/debug/DebugHandler.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/debug/DebugHandler.java b/common/src/main/java/me/lucko/luckperms/common/debug/DebugHandler.java index 384621b41..744682344 100644 --- a/common/src/main/java/me/lucko/luckperms/common/debug/DebugHandler.java +++ b/common/src/main/java/me/lucko/luckperms/common/debug/DebugHandler.java @@ -39,6 +39,7 @@ public class DebugHandler implements Runnable { private final Map listeners; private final Queue queue; + private boolean listening = false; @Setter private boolean shutdown = false; @@ -52,16 +53,25 @@ public class DebugHandler implements Runnable { } public void offer(String checked, String node, Tristate value) { + if (!listening) { + return; + } + queue.offer(new CheckData(checked, node, value)); } public void register(Sender sender, String filter, boolean notify) { + listening = true; listeners.put(sender.getUuid(), new DebugListener(pluginVersion, sender, filter, notify)); } public DebugListener unregister(UUID uuid) { flush(); - return listeners.remove(uuid); + DebugListener ret = listeners.remove(uuid); + if (listeners.isEmpty()) { + listening = false; + } + return ret; } @Override