mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 21:17:32 +00:00
Accounted for arrays in expression parsing
This commit is contained in:
1 parent
2ffe95dc0f
commit
1dbeaf2c84
1 file changed
+22
@@ -1657,6 +1657,11 @@ public class ScriptDocument {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Invalid expressions starting with brackets
|
||||
if (expr.startsWith("[") || expr.startsWith("]")) {
|
||||
return null; // Invalid syntax
|
||||
}
|
||||
|
||||
// String literals
|
||||
if (expr.startsWith("\"") && expr.endsWith("\"")) {
|
||||
return resolveType("String");
|
||||
@@ -1809,6 +1814,23 @@ public class ScriptDocument {
|
||||
}
|
||||
}
|
||||
|
||||
// Check if followed by array brackets (array access)
|
||||
// Skip array accesses like [0] or [i] - treat them as part of the current segment
|
||||
while (i < expr.length() && Character.isWhitespace(expr.charAt(i))) {
|
||||
i++;
|
||||
}
|
||||
if (i < expr.length() && expr.charAt(i) == '[') {
|
||||
// Skip to the matching closing bracket
|
||||
int depth = 1;
|
||||
i++;
|
||||
while (i < expr.length() && depth > 0) {
|
||||
char c = expr.charAt(i);
|
||||
if (c == '[') depth++;
|
||||
else if (c == ']') depth--;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
segments.add(new ChainSegment(name, start, i, isMethodCall));
|
||||
|
||||
// Skip whitespace
|
||||
|
||||
Reference in new issue
Block a user