diff --git a/src/de/steamwar/command/AbstractGuardChecker.java b/src/de/steamwar/command/AbstractGuardChecker.java
index 8d1a269..f5f2597 100644
--- a/src/de/steamwar/command/AbstractGuardChecker.java
+++ b/src/de/steamwar/command/AbstractGuardChecker.java
@@ -1,3 +1,22 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2020 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
package de.steamwar.command;
@FunctionalInterface
diff --git a/src/de/steamwar/command/AbstractSWCommand.java b/src/de/steamwar/command/AbstractSWCommand.java
index da80f23..fd371df 100644
--- a/src/de/steamwar/command/AbstractSWCommand.java
+++ b/src/de/steamwar/command/AbstractSWCommand.java
@@ -1,3 +1,22 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2020 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
package de.steamwar.command;
import java.lang.annotation.*;
diff --git a/src/de/steamwar/command/AbstractTypeMapper.java b/src/de/steamwar/command/AbstractTypeMapper.java
index e5735fe..744b726 100644
--- a/src/de/steamwar/command/AbstractTypeMapper.java
+++ b/src/de/steamwar/command/AbstractTypeMapper.java
@@ -1,6 +1,25 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2020 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
package de.steamwar.command;
-import java.util.List;
+import java.util.Collection;
public interface AbstractTypeMapper {
/**
@@ -8,5 +27,5 @@ public interface AbstractTypeMapper {
*/
T map(K sender, String[] previousArguments, String s);
- List tabCompletes(K sender, String[] previousArguments, String s);
+ Collection tabCompletes(K sender, String[] previousArguments, String s);
}
diff --git a/src/de/steamwar/command/CommandPart.java b/src/de/steamwar/command/CommandPart.java
index 6a8ff4b..0688caf 100644
--- a/src/de/steamwar/command/CommandPart.java
+++ b/src/de/steamwar/command/CommandPart.java
@@ -1,3 +1,22 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2020 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
package de.steamwar.command;
import lombok.AllArgsConstructor;
@@ -5,6 +24,7 @@ import lombok.Setter;
import java.lang.reflect.Array;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
class CommandPart {
@@ -133,12 +153,12 @@ class CommandPart {
public void generateTabComplete(List current, T sender, String[] args, int startIndex) {
if (varArgType != null) {
for (int i = startIndex; i < args.length - 1; i++) {
- CheckArgumentResult validArgument = checkArgument(null, sender, args, i);
+ CheckArgumentResult validArgument = checkArgument(GuardCheckType.TAB_COMPLETE, sender, args, i);
if (!validArgument.success) {
return;
}
}
- List strings = typeMapper.tabCompletes(sender, Arrays.copyOf(args, args.length - 1), args[args.length - 1]);
+ Collection strings = typeMapper.tabCompletes(sender, Arrays.copyOf(args, args.length - 1), args[args.length - 1]);
if (strings != null) {
current.addAll(strings);
}
@@ -157,7 +177,7 @@ class CommandPart {
return;
}
- List strings = typeMapper.tabCompletes(sender, Arrays.copyOf(args, startIndex), args[startIndex]);
+ Collection strings = typeMapper.tabCompletes(sender, Arrays.copyOf(args, startIndex), args[startIndex]);
if (strings != null) {
current.addAll(strings);
}
diff --git a/src/de/steamwar/command/SWCommandUtils.java b/src/de/steamwar/command/SWCommandUtils.java
index 4a6088a..067bc35 100644
--- a/src/de/steamwar/command/SWCommandUtils.java
+++ b/src/de/steamwar/command/SWCommandUtils.java
@@ -1,3 +1,22 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2020 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
package de.steamwar.command;
import lombok.Getter;
@@ -9,7 +28,6 @@ import java.lang.reflect.Parameter;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;
-import java.util.stream.Collectors;
@UtilityClass
public class SWCommandUtils {
@@ -198,20 +216,19 @@ public class SWCommandUtils {
}
public static AbstractTypeMapper, Enum>> createEnumMapper(Class> enumClass) {
- Enum>[] enums = enumClass.getEnumConstants();
- List strings = Arrays.stream(enums).map(Enum::name).map(String::toLowerCase).collect(Collectors.toList());
+ Map> enumMap = new HashMap<>();
+ for (Enum> e : enumClass.getEnumConstants()) {
+ enumMap.put(e.name(), e);
+ }
return new AbstractTypeMapper