mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 22:47:49 +01:00
Fix node child removal
This commit is contained in:
parent
dc59f3fd23
commit
7740c45982
@ -127,7 +127,7 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
|
|||||||
Check.stateCondition(Objects.equals(parent, child), "Cannot have a child as parent");
|
Check.stateCondition(Objects.equals(parent, child), "Cannot have a child as parent");
|
||||||
if (!children.add((EventNodeImpl<T>) childImpl)) return this; // Couldn't add the child (already present?)
|
if (!children.add((EventNodeImpl<T>) childImpl)) return this; // Couldn't add the child (already present?)
|
||||||
childImpl.parent = this;
|
childImpl.parent = this;
|
||||||
childImpl.propagateEvents(this); // Propagate after setting the parent
|
childImpl.propagateEvents(this);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -138,8 +138,8 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
|
|||||||
final var childImpl = (EventNodeImpl<? extends T>) child;
|
final var childImpl = (EventNodeImpl<? extends T>) child;
|
||||||
final boolean result = this.children.remove(childImpl);
|
final boolean result = this.children.remove(childImpl);
|
||||||
if (!result) return this; // Child not found
|
if (!result) return this; // Child not found
|
||||||
childImpl.propagateEvents(parent); // Propagate before removing the parent
|
|
||||||
childImpl.parent = null;
|
childImpl.parent = null;
|
||||||
|
childImpl.propagateEvents(this);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -173,10 +173,10 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
|
|||||||
final var nodeImpl = (EventNodeImpl<? extends T>) node;
|
final var nodeImpl = (EventNodeImpl<? extends T>) node;
|
||||||
Check.stateCondition(nodeImpl.parent != null, "Node already has a parent");
|
Check.stateCondition(nodeImpl.parent != null, "Node already has a parent");
|
||||||
Check.stateCondition(Objects.equals(parent, nodeImpl), "Cannot map to self");
|
Check.stateCondition(Objects.equals(parent, nodeImpl), "Cannot map to self");
|
||||||
var previous = this.mappedNodeCache.put(value, (EventNodeImpl<T>) nodeImpl);
|
EventNodeImpl<T> previous = this.mappedNodeCache.put(value, (EventNodeImpl<T>) nodeImpl);
|
||||||
if (previous != null) previous.parent = null;
|
if (previous != null) previous.parent = null;
|
||||||
nodeImpl.parent = this;
|
nodeImpl.parent = this;
|
||||||
nodeImpl.propagateEvents(this); // Propagate after setting the parent
|
nodeImpl.propagateEvents(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,8 +186,8 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
|
|||||||
final var mappedNode = this.mappedNodeCache.remove(value);
|
final var mappedNode = this.mappedNodeCache.remove(value);
|
||||||
if (mappedNode == null) return false; // Mapped node not found
|
if (mappedNode == null) return false; // Mapped node not found
|
||||||
final var childImpl = (EventNodeImpl<? extends T>) mappedNode;
|
final var childImpl = (EventNodeImpl<? extends T>) mappedNode;
|
||||||
childImpl.propagateEvents(parent); // Propagate before removing the parent
|
|
||||||
childImpl.parent = null;
|
childImpl.parent = null;
|
||||||
|
childImpl.propagateEvents(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user