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 d0186a43d1 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -40,17 +40,9 @@ public class SWCommandUtils {
static final Map<String, TypeMapper<?>> MAPPER_FUNCTIONS = new HashMap<>();
static final TypeMapper<?> ERROR_FUNCTION = new TypeMapper<Object>() {
@Override
public Object map(String s) {
throw new SecurityException();
}
@Override
public List<String> tabCompletes(String s) {
return Collections.emptyList();
}
};
static final TypeMapper<?> ERROR_FUNCTION = createMapper(s -> {
throw new SecurityException();
}, s -> Collections.emptyList());
static final BiFunction<Class<Enum<?>>, String, Enum<?>> ENUM_MAPPER = (enumClass, s) -> {
Enum<?>[] enums = enumClass.getEnumConstants();
@ -67,23 +59,13 @@ public class SWCommandUtils {
addMapper(int.class, Integer.class, createMapper(Integer::parseInt, numberCompleter(Integer::parseInt)));
MAPPER_FUNCTIONS.put(String.class.getTypeName(), createMapper(s -> s, Collections::singletonList));
MAPPER_FUNCTIONS.put(StringBuilder.class.getTypeName(), createMapper(StringBuilder::new, Collections::singletonList));
MAPPER_FUNCTIONS.put(Player.class.getTypeName(), createMapper(Bukkit::getPlayer, s -> {
return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
}));
MAPPER_FUNCTIONS.put(Player.class.getTypeName(), createMapper(Bukkit::getPlayer, s -> Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList())));
MAPPER_FUNCTIONS.put(GameMode.class.getTypeName(), createMapper(s -> {
s = s.toLowerCase();
if (s.equals("s") || s.equals("survival") || s.equals("0")) {
return GameMode.SURVIVAL;
}
if (s.equals("c") || s.equals("creative") || s.equals("1")) {
return GameMode.CREATIVE;
}
if (s.equals("sp") || s.equals("spectator") || s.equals("3")) {
return GameMode.SPECTATOR;
}
if (s.equals("a") || s.equals("adventure") || s.equals("2")) {
return GameMode.ADVENTURE;
}
if (s.equals("s") || s.equals("survival") || s.equals("0")) return GameMode.SURVIVAL;
if (s.equals("c") || s.equals("creative") || s.equals("1")) return GameMode.CREATIVE;
if (s.equals("sp") || s.equals("spectator") || s.equals("3")) return GameMode.SPECTATOR;
if (s.equals("a") || s.equals("adventure") || s.equals("2")) return GameMode.ADVENTURE;
throw new SecurityException();
}, s -> Arrays.asList("s", "survival", "0", "c", "creative", "1", "sp", "specator", "3", "a", "adventure", "2")));
}