diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index ae31780..60bda46 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -153,8 +153,8 @@ public abstract class SWCommand { } private void add(Class annotation, Method method, IntPredicate parameterTester, boolean firstParameter, Class returnType, BiConsumer consumer) { - T anno = SWCommandUtils.getAnnotation(method, annotation); - if (anno == null) { + T[] anno = SWCommandUtils.getAnnotation(method, annotation); + if (anno == null || anno.length == 0) { return; } @@ -171,7 +171,9 @@ public abstract class SWCommand { Bukkit.getLogger().log(Level.WARNING, "The method '" + method.toString() + "' is lacking the desired return type '" + returnType.getTypeName() + "'"); return; } - consumer.accept(anno, parameters); + for (T a : anno) { + consumer.accept(a, parameters); + } } private void addMapper(Class annotation, Method method, IntPredicate parameterTester, boolean firstParameter, Class returnType, BiConsumer> consumer) { @@ -200,10 +202,17 @@ public abstract class SWCommand { @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) + @Repeatable(Register.Registeres.class) protected @interface Register { String[] value() default {}; boolean help() default false; + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.METHOD}) + @interface Registeres { + Register[] value(); + } } @Retention(RetentionPolicy.RUNTIME) diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java b/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java index 0d09c7f..e6e281c 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java @@ -188,8 +188,8 @@ public class SWCommandUtils { }; } - static T getAnnotation(Method method, Class annotation) { + static T[] getAnnotation(Method method, Class annotation) { if (method.getAnnotations().length != 1) return null; - return method.getAnnotation(annotation); + return method.getDeclaredAnnotationsByType(annotation); } }