Add SWCommand.Register.Registeres
Dieser Commit ist enthalten in:
Ursprung
1d010dcc19
Commit
8142224f67
@ -153,8 +153,8 @@ public abstract class SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <T extends Annotation> void add(Class<T> annotation, Method method, IntPredicate parameterTester, boolean firstParameter, Class<?> returnType, BiConsumer<T, Parameter[]> consumer) {
|
private <T extends Annotation> void add(Class<T> annotation, Method method, IntPredicate parameterTester, boolean firstParameter, Class<?> returnType, BiConsumer<T, Parameter[]> consumer) {
|
||||||
T anno = SWCommandUtils.getAnnotation(method, annotation);
|
T[] anno = SWCommandUtils.getAnnotation(method, annotation);
|
||||||
if (anno == null) {
|
if (anno == null || anno.length == 0) {
|
||||||
return;
|
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() + "'");
|
Bukkit.getLogger().log(Level.WARNING, "The method '" + method.toString() + "' is lacking the desired return type '" + returnType.getTypeName() + "'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
consumer.accept(anno, parameters);
|
for (T a : anno) {
|
||||||
|
consumer.accept(a, parameters);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends Annotation> void addMapper(Class<T> annotation, Method method, IntPredicate parameterTester, boolean firstParameter, Class<?> returnType, BiConsumer<T, TypeMapper<?>> consumer) {
|
private <T extends Annotation> void addMapper(Class<T> annotation, Method method, IntPredicate parameterTester, boolean firstParameter, Class<?> returnType, BiConsumer<T, TypeMapper<?>> consumer) {
|
||||||
@ -200,10 +202,17 @@ public abstract class SWCommand {
|
|||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.METHOD})
|
@Target({ElementType.METHOD})
|
||||||
|
@Repeatable(Register.Registeres.class)
|
||||||
protected @interface Register {
|
protected @interface Register {
|
||||||
String[] value() default {};
|
String[] value() default {};
|
||||||
|
|
||||||
boolean help() default false;
|
boolean help() default false;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.METHOD})
|
||||||
|
@interface Registeres {
|
||||||
|
Register[] value();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@ -188,8 +188,8 @@ public class SWCommandUtils {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static <T extends Annotation> T getAnnotation(Method method, Class<T> annotation) {
|
static <T extends Annotation> T[] getAnnotation(Method method, Class<T> annotation) {
|
||||||
if (method.getAnnotations().length != 1) return null;
|
if (method.getAnnotations().length != 1) return null;
|
||||||
return method.getAnnotation(annotation);
|
return method.getDeclaredAnnotationsByType(annotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren