Skip to content

Commit 9b6791f

Browse files
authored
Merge branch 'dev/feature' into feature/renameparticle
2 parents da90d2f + 1fa2327 commit 9b6791f

3 files changed

Lines changed: 39 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/main/java/org/skriptlang/skript/common/function/DefaultFunctionImpl.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.skriptlang.skript.common.function;
22

3+
import ch.njol.skript.classes.ClassInfo;
34
import ch.njol.skript.lang.function.FunctionEvent;
45
import ch.njol.skript.lang.function.Signature;
6+
import ch.njol.skript.localization.Noun;
7+
import ch.njol.skript.registrations.Classes;
58
import com.google.common.base.Preconditions;
69
import org.jetbrains.annotations.NotNull;
710
import org.jetbrains.annotations.Nullable;
@@ -305,6 +308,33 @@ record DefaultParameter<T>(String name, Class<T> type, Set<Modifier> modifiers)
305308
this(name, type, Set.of(modifiers));
306309
}
307310

311+
@Override
312+
public @NotNull String toString() {
313+
StringJoiner joiner = new StringJoiner(" ");
314+
315+
joiner.add("%s:".formatted(name));
316+
317+
if (hasModifier(Modifier.OPTIONAL)) {
318+
joiner.add("optional");
319+
}
320+
321+
Noun exact = Classes.getSuperClassInfo(type).getName();
322+
if (type.isArray()) {
323+
joiner.add(exact.getPlural());
324+
} else {
325+
joiner.add(exact.getSingular());
326+
}
327+
328+
if (hasModifier(Modifier.RANGED)) {
329+
RangedModifier<?> range = getModifier(RangedModifier.class);
330+
joiner.add("between")
331+
.add(range.getMin().toString())
332+
.add("and")
333+
.add(range.getMax().toString());
334+
}
335+
336+
return joiner.toString();
337+
}
308338
}
309339

310340
}

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)