From 215db51837887528e306fcc86f280eb5e20af84e Mon Sep 17 00:00:00 2001 From: jojo Date: Wed, 30 Dec 2020 22:14:27 +0100 Subject: [PATCH] Rename ArgumentUtils.ofEnum Remove Argument.BOOLEAN --- .../src/de/steamwar/command/Argument.java | 1 - .../de/steamwar/command/ArgumentUtils.java | 21 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/command/Argument.java b/SpigotCore_Main/src/de/steamwar/command/Argument.java index 9d1676f..c04e9e2 100644 --- a/SpigotCore_Main/src/de/steamwar/command/Argument.java +++ b/SpigotCore_Main/src/de/steamwar/command/Argument.java @@ -45,7 +45,6 @@ public class Argument { numbers.add(Float.class); } - public static final Argument BOOLEAN = new Argument<>(Boolean::parseBoolean, bool -> true, "true", "false"); public static final Argument INT = new Argument<>(Integer::parseInt, integer -> true); public static final Argument DOUBLE = new Argument<>(Double::parseDouble, d -> true); public static final Argument STRING = new Argument<>(s -> s, string -> true); diff --git a/SpigotCore_Main/src/de/steamwar/command/ArgumentUtils.java b/SpigotCore_Main/src/de/steamwar/command/ArgumentUtils.java index 92b4aa6..e1e51b6 100644 --- a/SpigotCore_Main/src/de/steamwar/command/ArgumentUtils.java +++ b/SpigotCore_Main/src/de/steamwar/command/ArgumentUtils.java @@ -21,6 +21,7 @@ package de.steamwar.command; import java.util.Arrays; +import java.util.Collection; import java.util.Objects; import java.util.function.BiPredicate; import java.util.function.Predicate; @@ -52,17 +53,6 @@ public class ArgumentUtils { return new Argument<>(s -> s, string -> contains(commands, string, String::equals), s -> supply(s, tabCompletes, commands)); } - public static > Argument enumValue(Class enumClass) { - T[] enumValues = enumClass.getEnumConstants(); - String[] strings = Arrays.stream(enumValues).map(Enum::name).toArray(String[]::new); - return new Argument<>((s, sender) -> { - for (T enumValue : enumValues) { - if (enumValue.name().startsWith(s)) return enumValue; - } - return null; - }, Objects::nonNull, s -> strings); - } - public static Argument ofIgnoreCase(String... arguments) { return new Argument<>(s -> s, string -> contains(arguments, string, String::equals), arguments); } @@ -81,4 +71,13 @@ public class ArgumentUtils { return new Argument<>(Double::parseDouble, predicate, tabCompletes(Arrays.stream(tabValues).boxed(), predicate)); } + public static > Argument ofEnum(Class enumClass) { + T[] enumValues = enumClass.getEnumConstants(); + String[] strings = Arrays.stream(enumValues).map(Enum::name).toArray(String[]::new); + return new Argument<>((s, sender) -> { + for (T enumValue : enumValues) if (enumValue.name().startsWith(s)) return enumValue; + return null; + }, Objects::nonNull, s -> strings); + } + }