Skip to content

Commit 1fa2327

Browse files
Fix duplicate indices in ExprIndices (SkriptLang#8343)
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
1 parent 42c22df commit 1fa2327

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/main/java/ch/njol/skript/expressions/ExprIndices.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
9191
if (separator != -1)
9292
keys[i] = keys[i].substring(0, keys[i].indexOf(Variable.SEPARATOR));
9393
}
94-
return keys;
94+
return Arrays.stream(keys).distinct().toArray(String[]::new);
9595
}
9696

9797
@Override

src/test/skript/tests/syntaxes/expressions/ExprIndices.sk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
test "indices":
2+
set {_list::a} to 1
3+
set {_list::b} to 2
4+
set {_list::c::e} to 3
5+
set {_list::c::f} to 4
6+
assert size of indices of {_list::*} is 3
7+
assert indices of {_list::*} is "a", "b" and "c"
8+
19
test "sorted indices":
210
assert indices of {single-var} is set to fail with "Should not be able to acquire indices of anything other than a list"
311
assert indices of wooden hoe is set to fail with "Should not be able to acquire indices of anything other than a list"

0 commit comments

Comments
 (0)