Fix enum mapper

Dieser Commit ist enthalten in:
yoyosource 2022-05-30 14:32:38 +02:00 committet von Lixfel
Ursprung 6d29507973
Commit f619797824

Datei anzeigen

@ -218,12 +218,12 @@ public class SWCommandUtils {
public static <T extends AbstractTypeMapper<K, Enum<?>>, K> T createEnumMapper(Class<Enum<?>> enumClass) { public static <T extends AbstractTypeMapper<K, Enum<?>>, K> T createEnumMapper(Class<Enum<?>> enumClass) {
Map<String, Enum<?>> enumMap = new HashMap<>(); Map<String, Enum<?>> enumMap = new HashMap<>();
for (Enum<?> e : enumClass.getEnumConstants()) { for (Enum<?> e : enumClass.getEnumConstants()) {
enumMap.put(e.name(), e); enumMap.put(e.name().toLowerCase(), e);
} }
return (T) new AbstractTypeMapper<Object, Enum<?>>() { return (T) new AbstractTypeMapper<Object, Enum<?>>() {
@Override @Override
public Enum<?> map(Object commandSender, String[] previousArguments, String s) { public Enum<?> map(Object commandSender, String[] previousArguments, String s) {
return enumMap.get(s); return enumMap.get(s.toLowerCase());
} }
@Override @Override