SteamWar/SpigotCore
Archiviert
13
0

Hotfix SWCommand.StaticValue
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2021-12-08 19:50:31 +01:00
Ursprung 66c50bf6e6
Commit 0d573557b8
2 geänderte Dateien mit 6 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -332,6 +332,6 @@ public abstract class SWCommand {
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER})
protected @interface StaticValue {
String value();
String[] value() default {};
}
}

Datei anzeigen

@ -167,6 +167,11 @@ public class SWCommandUtils {
return createMapper((s) -> value.equals(s) ? value : null, s -> Collections.singletonList(value));
}
public static TypeMapper<String> createMapper(String[] values) {
List<String> strings = Arrays.asList(values);
return createMapper((s) -> strings.contains(s) ? s : null, s -> strings);
}
public static <T> TypeMapper<T> createMapper(Function<String, T> mapper, Function<String, List<String>> tabCompleter) {
return createMapper(mapper, (commandSender, s) -> tabCompleter.apply(s));
}