SteamWar/SpigotCore
Archiviert
13
0

CommandFramework3 #94

Manuell gemergt
Zeanon hat 71 Commits von CommandFramework3 nach master 2021-03-30 21:15:40 +02:00 zusammengeführt
Nur Änderungen aus Commit e9fbfcac70 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -199,28 +199,6 @@ class SWCommandUtils {
return arguments;
}
@SuppressWarnings("unchecked")
private static Function<String, Object> mapper(Parameter parameter) {
Class<?> clazz = parameter.getType();
if (parameter.isVarArgs()) {
clazz = clazz.getComponentType();
}
if (clazz.isEnum()) {
Class<Enum<?>> enumClass = (Class<Enum<?>>) clazz;
return s -> ENUM_MAPPER.apply(enumClass, s);
}
String name = clazz.getTypeName();
SWCommand.Mapper mapper = parameter.getAnnotation(SWCommand.Mapper.class);
if (mapper != null) {
name = mapper.mapper();
}
TypeMapper<?> typeMapper = MAPPER_FUNCTIONS.getOrDefault(name, ERROR_FUNCTION);
return typeMapper::map;
}
public static void addMapper(String name, TypeMapper<?> mapper) {
if (MAPPER_FUNCTIONS.containsKey(name)) return;
MAPPER_FUNCTIONS.put(name, mapper);