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

Datei anzeigen

@ -88,46 +88,25 @@ class SWCommandUtils {
}));
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(), new TypeMapper<Player>() {
@Override
public Player map(String s) {
return Bukkit.getPlayer(s);
MAPPER_FUNCTIONS.put(Player.class.getTypeName(), createMapper(Bukkit::getPlayer, s -> {
return 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;
}
@Override
public List<String> tabCompletes(String s) {
return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
if (s.equals("c") || s.equals("creative") || s.equals("1")) {
return GameMode.CREATIVE;
}
});
MAPPER_FUNCTIONS.put(GameMode.class.getTypeName(), new TypeMapper<GameMode>() {
@Override
public GameMode map(String s) {
switch (s.toLowerCase()) {
case "s":
case "survival":
case "0":
return GameMode.SURVIVAL;
case "c":
case "creative":
case "1":
return GameMode.CREATIVE;
case "sp":
case "spectator":
case "3":
return GameMode.SPECTATOR;
case "a":
case "adventure":
case "2":
return GameMode.ADVENTURE;
}
throw new SecurityException();
if (s.equals("sp") || s.equals("spectator") || s.equals("3")) {
return GameMode.SPECTATOR;
}
@Override
public List<String> tabCompletes(String s) {
return Arrays.asList("s", "survival", "0", "c", "creative", "1", "sp", "specator", "3", "a", "adventure", "2");
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")));
}
private static void addMapper(Class<?> clazz, Class<?> alternativeClazz, TypeMapper<?> mapper) {