From bc40b24a2432221ac3ee2fe46d98d472b66102ba Mon Sep 17 00:00:00 2001
From: Efnilite <35348263+Efnilite@users.noreply.github.com>
Date: Thu, 28 Nov 2024 11:03:31 +0100
Subject: [PATCH] add missing methods to Node
---
src/main/java/ch/njol/skript/config/Node.java | 82 +++++++++++++++++--
1 file changed, 74 insertions(+), 8 deletions(-)
diff --git a/src/main/java/ch/njol/skript/config/Node.java b/src/main/java/ch/njol/skript/config/Node.java
index dd388e7dfa9..55ff5b9d674 100644
--- a/src/main/java/ch/njol/skript/config/Node.java
+++ b/src/main/java/ch/njol/skript/config/Node.java
@@ -18,18 +18,16 @@
*/
package ch.njol.skript.config;
-import java.io.PrintWriter;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import ch.njol.skript.SkriptConfig;
-import org.jetbrains.annotations.Nullable;
-
import ch.njol.skript.Skript;
import ch.njol.skript.log.SkriptLogger;
import ch.njol.util.NonNullPair;
import ch.njol.util.StringUtils;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.PrintWriter;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
* @author Peter Güttinger
@@ -427,4 +425,72 @@ public boolean debug() {
return debug;
}
+ /**
+ * @return The index of this node relative to the other children of this node's parent,
+ * or -1 if this node does not have a parent. The index includes counted void nodes.
+ */
+ int getIndex() {
+ if (parent == null)
+ return -1;
+
+ int index = 0;
+ for (Iterator
+ * Getting the path of node {@code z} in the following example would
+ * return an array with {@code w.x, y, z}.
+ *
+ * w.x:
+ * y:
+ * z: true # this node
+ *