From 696c03b8512ef185218bf49da298387d6c63797a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 16 Aug 2022 17:53:59 +0200 Subject: [PATCH] Add better int and long handling for StaticValue annotation --- src/de/steamwar/command/SWCommandUtils.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/command/SWCommandUtils.java b/src/de/steamwar/command/SWCommandUtils.java index 94a9c93..69e0b8c 100644 --- a/src/de/steamwar/command/SWCommandUtils.java +++ b/src/de/steamwar/command/SWCommandUtils.java @@ -145,18 +145,11 @@ public class SWCommandUtils { return index == -1 ? null : !falseValues.contains(index); }, (commandSender, s) -> tabCompletes); } - if ((parameter.getType() == int.class || parameter.getType() == Integer.class) && staticValue.value().length >= 2) { + if ((parameter.getType() == int.class || parameter.getType() == Integer.class || parameter.getType() == long.class || parameter.getType() == Long.class) && staticValue.value().length >= 2) { List tabCompletes = new ArrayList<>(Arrays.asList(staticValue.value())); return createMapper(s -> { - int index = tabCompletes.indexOf(s); - return index == -1 ? null : index; - }, (commandSender, s) -> tabCompletes); - } - if ((parameter.getType() == long.class || parameter.getType() == Long.class) && staticValue.value().length >= 2) { - List tabCompletes = new ArrayList<>(Arrays.asList(staticValue.value())); - return createMapper(s -> { - long index = tabCompletes.indexOf(s); - return index == -1 ? null : index; + Number index = tabCompletes.indexOf(s); + return index.longValue() == -1 ? null : index; }, (commandSender, s) -> tabCompletes); } }