mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-17 05:31:23 +01:00
Cleanup
This commit is contained in:
parent
0ad763a813
commit
cfbd655027
@ -29,7 +29,7 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
|
|||||||
private volatile int priority;
|
private volatile int priority;
|
||||||
private volatile EventNodeImpl<? super T> parent;
|
private volatile EventNodeImpl<? super T> parent;
|
||||||
|
|
||||||
protected EventNodeImpl(@NotNull String name,
|
EventNodeImpl(@NotNull String name,
|
||||||
@NotNull EventFilter<T, ?> filter,
|
@NotNull EventFilter<T, ?> filter,
|
||||||
@Nullable BiPredicate<T, Object> predicate) {
|
@Nullable BiPredicate<T, Object> predicate) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -313,8 +313,8 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
|
|||||||
private void recursiveUpdate(EventNodeImpl<E> targetNode) {
|
private void recursiveUpdate(EventNodeImpl<E> targetNode) {
|
||||||
// Standalone listeners
|
// Standalone listeners
|
||||||
forTargetEvents(eventType, type -> {
|
forTargetEvents(eventType, type -> {
|
||||||
ListenerEntry<E> entry = targetNode.listenerMap.get(type);
|
final ListenerEntry<E> entry = targetNode.listenerMap.get(type);
|
||||||
if (entry != null) appendEntries(listeners, entry, targetNode);
|
if (entry != null) appendEntries(entry, targetNode);
|
||||||
});
|
});
|
||||||
// Mapped nodes
|
// Mapped nodes
|
||||||
handleMappedNode(targetNode);
|
handleMappedNode(targetNode);
|
||||||
@ -356,27 +356,27 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static <E extends Event> void appendEntries(List<Consumer<E>> handleListeners, ListenerEntry<E> entry, EventNodeImpl<E> targetNode) {
|
private void appendEntries(ListenerEntry<E> entry, EventNodeImpl<E> targetNode) {
|
||||||
final var filter = targetNode.filter;
|
final var filter = targetNode.filter;
|
||||||
final var predicate = targetNode.predicate;
|
final var predicate = targetNode.predicate;
|
||||||
// Normal listeners
|
// Normal listeners
|
||||||
for (var listener : entry.listeners) {
|
for (var listener : entry.listeners) {
|
||||||
if (predicate != null) {
|
if (predicate != null) {
|
||||||
// Ensure that the event is valid before running
|
// Ensure that the event is valid before running
|
||||||
handleListeners.add(e -> {
|
this.listeners.add(e -> {
|
||||||
final var value = filter.getHandler(e);
|
final var value = filter.getHandler(e);
|
||||||
if (!predicate.test(e, value)) return;
|
if (!predicate.test(e, value)) return;
|
||||||
callListener(targetNode, listener, e);
|
callListener(targetNode, listener, e);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// No predicate, run directly
|
// No predicate, run directly
|
||||||
handleListeners.add(e -> callListener(targetNode, listener, e));
|
this.listeners.add(e -> callListener(targetNode, listener, e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Bindings
|
// Bindings
|
||||||
final var bindingConsumers = entry.bindingConsumers;
|
final var bindingConsumers = entry.bindingConsumers;
|
||||||
if (!bindingConsumers.isEmpty()) { // Ensure no array clone
|
if (!bindingConsumers.isEmpty()) { // Ensure no array clone
|
||||||
handleListeners.addAll(bindingConsumers);
|
this.listeners.addAll(bindingConsumers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user