mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Don't bother adding checks to the listener queue if no listeners are registered
This commit is contained in:
parent
05f906a759
commit
8d86eed0a7
@ -39,6 +39,7 @@ public class DebugHandler implements Runnable {
|
|||||||
|
|
||||||
private final Map<UUID, DebugListener> listeners;
|
private final Map<UUID, DebugListener> listeners;
|
||||||
private final Queue<CheckData> queue;
|
private final Queue<CheckData> queue;
|
||||||
|
private boolean listening = false;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private boolean shutdown = false;
|
private boolean shutdown = false;
|
||||||
@ -52,16 +53,25 @@ public class DebugHandler implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void offer(String checked, String node, Tristate value) {
|
public void offer(String checked, String node, Tristate value) {
|
||||||
|
if (!listening) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
queue.offer(new CheckData(checked, node, value));
|
queue.offer(new CheckData(checked, node, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(Sender sender, String filter, boolean notify) {
|
public void register(Sender sender, String filter, boolean notify) {
|
||||||
|
listening = true;
|
||||||
listeners.put(sender.getUuid(), new DebugListener(pluginVersion, sender, filter, notify));
|
listeners.put(sender.getUuid(), new DebugListener(pluginVersion, sender, filter, notify));
|
||||||
}
|
}
|
||||||
|
|
||||||
public DebugListener unregister(UUID uuid) {
|
public DebugListener unregister(UUID uuid) {
|
||||||
flush();
|
flush();
|
||||||
return listeners.remove(uuid);
|
DebugListener ret = listeners.remove(uuid);
|
||||||
|
if (listeners.isEmpty()) {
|
||||||
|
listening = false;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user