diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java b/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java index d2fbc45..0a9cb84 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java @@ -40,17 +40,9 @@ public class SWCommandUtils { static final Map> MAPPER_FUNCTIONS = new HashMap<>(); - static final TypeMapper ERROR_FUNCTION = new TypeMapper() { - @Override - public Object map(String s) { - throw new SecurityException(); - } - - @Override - public List tabCompletes(String s) { - return Collections.emptyList(); - } - }; + static final TypeMapper ERROR_FUNCTION = createMapper(s -> { + throw new SecurityException(); + }, s -> Collections.emptyList()); static final BiFunction>, 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"))); }