diff --git a/src/main/java/io/github/simplexdev/api/annotations/ReqType.java b/src/main/java/io/github/simplexdev/api/annotations/ReqType.java new file mode 100644 index 0000000..b9678ef --- /dev/null +++ b/src/main/java/io/github/simplexdev/api/annotations/ReqType.java @@ -0,0 +1,7 @@ +package io.github.simplexdev.api.annotations; + +public enum ReqType { + PAPER, + WATERFALL, + BUNGEECORD +} diff --git a/src/main/java/io/github/simplexdev/api/annotations/ServerInfo.java b/src/main/java/io/github/simplexdev/api/annotations/Requires.java similarity index 64% rename from src/main/java/io/github/simplexdev/api/annotations/ServerInfo.java rename to src/main/java/io/github/simplexdev/api/annotations/Requires.java index 7980453..8152537 100644 --- a/src/main/java/io/github/simplexdev/api/annotations/ServerInfo.java +++ b/src/main/java/io/github/simplexdev/api/annotations/Requires.java @@ -7,10 +7,6 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) -public @interface ServerInfo { - boolean isPaper() default false; - - boolean isWaterfall() default false; - - boolean isBungeeCord() default false; +public @interface Requires { + ReqType value(); } diff --git a/src/main/java/io/github/simplexdev/simplexcore/plugin/AddonRegistry.java b/src/main/java/io/github/simplexdev/simplexcore/plugin/AddonRegistry.java index f9ac4cb..1b9c76d 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/plugin/AddonRegistry.java +++ b/src/main/java/io/github/simplexdev/simplexcore/plugin/AddonRegistry.java @@ -1,7 +1,7 @@ package io.github.simplexdev.simplexcore.plugin; -import io.github.simplexdev.api.annotations.ServerInfo; -import io.github.simplexdev.api.func.Guard; +import io.github.simplexdev.api.annotations.ReqType; +import io.github.simplexdev.api.annotations.Requires; import io.github.simplexdev.simplexcore.utils.Constants; import java.util.HashSet; @@ -51,16 +51,23 @@ public final class AddonRegistry { } } + private boolean checkAnnotation(Requires info, ReqType type) { + return info.value() == type; + } + public > void register(T addon) { - if (addon.getClass().isAnnotationPresent(ServerInfo.class)) { - ServerInfo info = addon.getClass().getDeclaredAnnotation(ServerInfo.class); - if (info.isPaper() && !isPaper(addon)) { + if (addon.getClass().isAnnotationPresent(Requires.class)) { + Requires info = addon.getClass().getDeclaredAnnotation(Requires.class); + if (checkAnnotation(info, ReqType.PAPER) + && !isPaper(addon)) { return; } - if (info.isBungeeCord() && !isBungee(addon)) { + if (checkAnnotation(info, ReqType.BUNGEECORD) + && !isBungee(addon)) { return; } - if (info.isWaterfall() && !isWaterfall(addon)) { + if (checkAnnotation(info, ReqType.WATERFALL) + && !isWaterfall(addon)) { return; } }