mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-23 16:41:35 +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 EventFilter<T, ?> filter;
|
||||||
protected final BiPredicate<T, Object> predicate;
|
protected final BiPredicate<T, Object> predicate;
|
||||||
protected final Class<T> eventType;
|
protected final Class<T> eventType;
|
||||||
|
private volatile int priority;
|
||||||
private volatile EventNode<? super T> parent;
|
private volatile EventNode<? super T> parent;
|
||||||
|
|
||||||
protected EventNode(@NotNull String name,
|
protected EventNode(@NotNull String name,
|
||||||
@ -124,9 +125,9 @@ public class EventNode<T extends Event> {
|
|||||||
}
|
}
|
||||||
// Process children
|
// Process children
|
||||||
if (entry.childCount > 0) {
|
if (entry.childCount > 0) {
|
||||||
for (EventNode<T> child : children) {
|
this.children.stream()
|
||||||
child.call(event);
|
.sorted(Comparator.comparing(EventNode::getPriority))
|
||||||
}
|
.forEach(child -> child.call(event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,6 +142,15 @@ public class EventNode<T extends Event> {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventNode<T> setPriority(int priority) {
|
||||||
|
this.priority = priority;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable EventNode<? super T> getParent() {
|
public @Nullable EventNode<? super T> getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user