Dieser Commit ist enthalten in:
Ursprung
f488c90fd0
Commit
07e87b0c0e
@ -192,19 +192,19 @@ public class SWCommandUtils {
|
||||
GUARD_FUNCTIONS.putIfAbsent(name, guardChecker);
|
||||
}
|
||||
|
||||
public static <K> AbstractTypeMapper<K, String> createMapper(String... values) {
|
||||
public static <T extends AbstractTypeMapper<K, String>, K> T createMapper(String... values) {
|
||||
List<String> strings = Arrays.asList(values);
|
||||
return createMapper((s) -> strings.contains(s) ? s : null, s -> strings);
|
||||
}
|
||||
|
||||
public static <T, K> AbstractTypeMapper<K, T> createMapper(Function<String, T> mapper, Function<String, List<String>> tabCompleter) {
|
||||
public static <T extends AbstractTypeMapper<K, V>, K, V> T createMapper(Function<String, V> mapper, Function<String, List<String>> tabCompleter) {
|
||||
return createMapper(mapper, (commandSender, s) -> tabCompleter.apply(s));
|
||||
}
|
||||
|
||||
public static <T, K> AbstractTypeMapper<K, T> createMapper(Function<String, T> mapper, BiFunction<K, String, List<String>> tabCompleter) {
|
||||
return new AbstractTypeMapper<K, T>() {
|
||||
public static <T extends AbstractTypeMapper<K, V>, K, V> T createMapper(Function<String, V> mapper, BiFunction<K, String, List<String>> tabCompleter) {
|
||||
return (T) new AbstractTypeMapper<K, V>() {
|
||||
@Override
|
||||
public T map(K commandSender, String[] previousArguments, String s) {
|
||||
public V map(K commandSender, String[] previousArguments, String s) {
|
||||
return mapper.apply(s);
|
||||
}
|
||||
|
||||
@ -215,12 +215,12 @@ public class SWCommandUtils {
|
||||
};
|
||||
}
|
||||
|
||||
public static AbstractTypeMapper<?, Enum<?>> createEnumMapper(Class<Enum<?>> enumClass) {
|
||||
public static <T extends AbstractTypeMapper<K, Enum<?>>, K> T createEnumMapper(Class<Enum<?>> enumClass) {
|
||||
Map<String, Enum<?>> enumMap = new HashMap<>();
|
||||
for (Enum<?> e : enumClass.getEnumConstants()) {
|
||||
enumMap.put(e.name(), e);
|
||||
}
|
||||
return new AbstractTypeMapper<Object, Enum<?>>() {
|
||||
return (T) new AbstractTypeMapper<Object, Enum<?>>() {
|
||||
@Override
|
||||
public Enum<?> map(Object commandSender, String[] previousArguments, String s) {
|
||||
return enumMap.get(s);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren