diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index de49a86..c765932 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -73,15 +73,15 @@ public abstract class SWCommand { } }); + Set commandMethods = new HashSet<>(); for (Method method : getClass().getDeclaredMethods()) { addMapper(method); + addCommand(method, commandMethods); } - for (Method method : getClass().getDeclaredMethods()) { - addCommand(method); - } + commandMethods.forEach(method -> commandSet.add(new SubCommand(this, method))); } - private void addCommand(Method method) { + private void addCommand(Method method, Set commandMethods) { Register register = method.getDeclaredAnnotation(Register.class); Mapper methodMapper = method.getDeclaredAnnotation(Mapper.class); if (register == null || methodMapper != null) { @@ -101,17 +101,17 @@ public abstract class SWCommand { if (parameter.isVarArgs() && i == parameters.length - 1) { clazz = parameter.getType().getComponentType(); } - if (clazz.isEnum()) { + Mapper mapper = parameter.getAnnotation(Mapper.class); + if (clazz.isEnum() && mapper == null) { continue; } String name = clazz.getTypeName(); - Mapper mapper = parameter.getAnnotation(Mapper.class); if (mapper != null) { name = mapper.value(); } if (!SWCommandUtils.MAPPER_FUNCTIONS.containsKey(name)) return; } - commandSet.add(new SubCommand(this, method)); + commandMethods.add(method); } private void addMapper(Method method) {