mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 17:37:42 +01:00
Add EventNode#setPriority
This commit is contained in:
parent
cf1e5222ca
commit
f47159d131
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user