diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java b/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java index ebbcfaf..3c3f9b1 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java @@ -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() { - @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 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() { - @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 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) {