|
1 | 1 | package org.skriptlang.skript.common.function; |
2 | 2 |
|
| 3 | +import ch.njol.skript.classes.ClassInfo; |
3 | 4 | import ch.njol.skript.lang.function.FunctionEvent; |
4 | 5 | import ch.njol.skript.lang.function.Signature; |
| 6 | +import ch.njol.skript.localization.Noun; |
| 7 | +import ch.njol.skript.registrations.Classes; |
5 | 8 | import com.google.common.base.Preconditions; |
6 | 9 | import org.jetbrains.annotations.NotNull; |
7 | 10 | import org.jetbrains.annotations.Nullable; |
@@ -305,6 +308,33 @@ record DefaultParameter<T>(String name, Class<T> type, Set<Modifier> modifiers) |
305 | 308 | this(name, type, Set.of(modifiers)); |
306 | 309 | } |
307 | 310 |
|
| 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 | + } |
308 | 338 | } |
309 | 339 |
|
310 | 340 | } |
0 commit comments