diff --git a/src/main/java/net/minestom/server/event/EventNode.java b/src/main/java/net/minestom/server/event/EventNode.java index 63249e0e7..910c4953d 100644 --- a/src/main/java/net/minestom/server/event/EventNode.java +++ b/src/main/java/net/minestom/server/event/EventNode.java @@ -73,6 +73,7 @@ public class EventNode { protected final EventFilter filter; protected final BiPredicate predicate; protected final Class eventType; + private volatile int priority; private volatile EventNode parent; protected EventNode(@NotNull String name, @@ -124,9 +125,9 @@ public class EventNode { } // Process children if (entry.childCount > 0) { - for (EventNode child : children) { - child.call(event); - } + this.children.stream() + .sorted(Comparator.comparing(EventNode::getPriority)) + .forEach(child -> child.call(event)); } } @@ -141,6 +142,15 @@ public class EventNode { return name; } + public int getPriority() { + return priority; + } + + public EventNode setPriority(int priority) { + this.priority = priority; + return this; + } + public @Nullable EventNode getParent() { return parent; }