diff --git a/src/main/java/net/minestom/server/event/EventNode.java b/src/main/java/net/minestom/server/event/EventNode.java index 5aac8f499..63249e0e7 100644 --- a/src/main/java/net/minestom/server/event/EventNode.java +++ b/src/main/java/net/minestom/server/event/EventNode.java @@ -114,7 +114,7 @@ public class EventNode { } final var listeners = entry.listeners; - if (listeners != null && !listeners.isEmpty()) { + if (!listeners.isEmpty()) { for (EventListener listener : listeners) { final EventListener.Result result = listener.run(event); if (result == EventListener.Result.EXPIRED) { @@ -241,6 +241,9 @@ public class EventNode { private void increaseChildListenerCount(Class eventClass, int count) { var entry = listenerMap.computeIfAbsent(eventClass, aClass -> new ListenerEntry<>()); ListenerEntry.addAndGet(entry, count); + if (parent != null) { + parent.increaseChildListenerCount(eventClass, count); + } } private void decreaseChildListenerCount(Class eventClass, int count) { @@ -251,6 +254,9 @@ public class EventNode { } else if (result < 0) { throw new IllegalStateException("Something wrong happened, listener count: " + result); } + if (parent != null) { + parent.decreaseChildListenerCount(eventClass, count); + } } private static class ListenerEntry {