mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Add some comments
This commit is contained in:
parent
7dfa477500
commit
429d12c7e3
@ -319,22 +319,25 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
|
|||||||
});
|
});
|
||||||
// Mapped nodes
|
// Mapped nodes
|
||||||
{
|
{
|
||||||
Set<EventFilter<E, ?>> filters = new HashSet<>();
|
final var mappedNodeCache = targetNode.mappedNodeCache;
|
||||||
for (var mappedEntry : targetNode.mappedNodeCache.entrySet()) {
|
Set<EventFilter<E, ?>> filters = new HashSet<>(mappedNodeCache.size());
|
||||||
|
// Retrieve all filters used to retrieve potential handlers
|
||||||
|
for (var mappedEntry : mappedNodeCache.entrySet()) {
|
||||||
var mappedNode = mappedEntry.getValue();
|
var mappedNode = mappedEntry.getValue();
|
||||||
if (!mappedNode.eventType.isAssignableFrom(handleType)) continue;
|
if (!mappedNode.eventType.isAssignableFrom(handleType)) continue;
|
||||||
forTargetEvents(handleType, type -> {
|
forTargetEvents(handleType, type -> {
|
||||||
final boolean hasEvent = mappedNode.listenerMap.containsKey(type);
|
if (!mappedNode.listenerMap.containsKey(type)) return; // No normal listener to this handle type
|
||||||
if (!hasEvent) return;
|
|
||||||
filters.add(mappedNode.filter);
|
filters.add(mappedNode.filter);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// If at least one mapped node listen to this handle type,
|
||||||
|
// loop through them and forward to mapped node if there is a match
|
||||||
if (!filters.isEmpty()) {
|
if (!filters.isEmpty()) {
|
||||||
this.listeners.add(event -> {
|
this.listeners.add(event -> {
|
||||||
for (var filter : filters) {
|
for (var filter : filters) {
|
||||||
final var handler = filter.castHandler(event);
|
final Object handler = filter.castHandler(event);
|
||||||
final var map = targetNode.mappedNodeCache.get(handler);
|
final EventNode<E> mappedNode = mappedNodeCache.get(handler);
|
||||||
if (map != null) map.call(event);
|
if (mappedNode != null) mappedNode.call(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user