diff --git a/src/main/java/net/minestom/server/event/EventNode.java b/src/main/java/net/minestom/server/event/EventNode.java index 18c4390bf..f5c052ec3 100644 --- a/src/main/java/net/minestom/server/event/EventNode.java +++ b/src/main/java/net/minestom/server/event/EventNode.java @@ -123,6 +123,7 @@ public class EventNode { public EventNode addChild(@NotNull EventNode child) { synchronized (GLOBAL_CHILD_LOCK) { + Check.stateCondition(child.parent != null, "Node already has a parent"); Check.stateCondition(Objects.equals(parent, child), "Cannot have a child as parent"); final boolean result = this.children.add((EventNode) child); if (result) { @@ -209,6 +210,10 @@ public class EventNode { return this; } + public @Nullable EventNode getParent() { + return parent; + } + public @NotNull Set<@NotNull EventNode> getChildren() { return Collections.unmodifiableSet(children); }