SteamWar/SpigotCore
Archiviert
13
0

Add SWCommand.Register.Registeres

Dieser Commit ist enthalten in:
yoyosource 2021-05-03 18:01:00 +02:00
Ursprung 1d010dcc19
Commit 8142224f67
2 geänderte Dateien mit 14 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -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) {
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 <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)
@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)

Datei anzeigen

@ -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;
return method.getAnnotation(annotation);
return method.getDeclaredAnnotationsByType(annotation);
}
}