Add EventNode#setPriority

This commit is contained in:
TheMode 2021-06-08 13:47:10 +02:00
parent cf1e5222ca
commit f47159d131

View File

@ -73,6 +73,7 @@ public class EventNode<T extends Event> {
protected final EventFilter<T, ?> filter;
protected final BiPredicate<T, Object> predicate;
protected final Class<T> eventType;
private volatile int priority;
private volatile EventNode<? super T> parent;
protected EventNode(@NotNull String name,
@ -124,9 +125,9 @@ public class EventNode<T extends Event> {
}
// Process children
if (entry.childCount > 0) {
for (EventNode<T> 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<T extends Event> {
return name;
}
public int getPriority() {
return priority;
}
public EventNode<T> setPriority(int priority) {
this.priority = priority;
return this;
}
public @Nullable EventNode<? super T> getParent() {
return parent;
}