diff --git a/src/main/java/net/minestom/server/event/EventNodeImpl.java b/src/main/java/net/minestom/server/event/EventNodeImpl.java index f9e77546b..ebd882c15 100644 --- a/src/main/java/net/minestom/server/event/EventNodeImpl.java +++ b/src/main/java/net/minestom/server/event/EventNodeImpl.java @@ -273,7 +273,7 @@ class EventNodeImpl implements EventNode { @Override public void call(@NotNull E event) { - if (!updated) update(); + update(); final Consumer[] listeners = this.listeners; if (listeners.length == 0) return; for (Consumer listener : listeners) { @@ -283,12 +283,14 @@ class EventNodeImpl implements EventNode { @Override public boolean hasListener() { - if (!updated) update(); + update(); return listeners.length > 0; } void update() { + if (updated) return; synchronized (GLOBAL_CHILD_LOCK) { + if (updated) return; this.listenersCache.clear(); recursiveUpdate(node); this.listeners = listenersCache.toArray(Consumer[]::new); @@ -338,7 +340,7 @@ class EventNodeImpl implements EventNode { final Object handler = filter.castHandler(event); final Handle handle = handlers.get(handler); if (handle != null) { // Run the listeners of the mapped node - if (!handle.updated) handle.update(); + handle.update(); for (Consumer listener : handle.listeners) { listener.accept(event); }