mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
Add EventNode#getParent
This commit is contained in:
parent
94e315e3b2
commit
f1ddedfb44
@ -123,6 +123,7 @@ public class EventNode<T extends Event> {
|
|||||||
|
|
||||||
public EventNode<T> addChild(@NotNull EventNode<? extends T> child) {
|
public EventNode<T> addChild(@NotNull EventNode<? extends T> child) {
|
||||||
synchronized (GLOBAL_CHILD_LOCK) {
|
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");
|
Check.stateCondition(Objects.equals(parent, child), "Cannot have a child as parent");
|
||||||
final boolean result = this.children.add((EventNode<T>) child);
|
final boolean result = this.children.add((EventNode<T>) child);
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -209,6 +210,10 @@ public class EventNode<T extends Event> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable EventNode<? super T> getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
public @NotNull Set<@NotNull EventNode<T>> getChildren() {
|
public @NotNull Set<@NotNull EventNode<T>> getChildren() {
|
||||||
return Collections.unmodifiableSet(children);
|
return Collections.unmodifiableSet(children);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user