From 0d573557b89f8b14eb6d37268ef3c6fb17348141 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 8 Dec 2021 19:50:31 +0100 Subject: [PATCH] Hotfix SWCommand.StaticValue --- SpigotCore_Main/src/de/steamwar/command/SWCommand.java | 2 +- SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index e2a8f01..1783303 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -332,6 +332,6 @@ public abstract class SWCommand { @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.PARAMETER}) protected @interface StaticValue { - String value(); + String[] value() default {}; } } diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java b/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java index 98ddcf6..0635e6b 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java @@ -167,6 +167,11 @@ public class SWCommandUtils { return createMapper((s) -> value.equals(s) ? value : null, s -> Collections.singletonList(value)); } + public static TypeMapper createMapper(String[] values) { + List strings = Arrays.asList(values); + return createMapper((s) -> strings.contains(s) ? s : null, s -> strings); + } + public static TypeMapper createMapper(Function mapper, Function> tabCompleter) { return createMapper(mapper, (commandSender, s) -> tabCompleter.apply(s)); }