From f1ddedfb44bec2a44a9fe1a9131d59b649ccaef3 Mon Sep 17 00:00:00 2001 From: TheMode Date: Fri, 4 Jun 2021 00:30:48 +0200 Subject: [PATCH] Add EventNode#getParent --- src/main/java/net/minestom/server/event/EventNode.java | 5 +++++ 1 file changed, 5 insertions(+) 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); }