mirror of
https://github.com/SimplexDevelopment/SimplexCore.git
synced 2024-12-22 08:37:37 +00:00
BLEEDING_EDGE v1.3_03
- Added ReqType enum - Renamed ServerInfo to Requires, removed all boolean values and replaced with a single ReqType value() - Adjusted the registry to check for the requires annotation, and to disable the addon module if the server host is not running the requested server configuration
This commit is contained in:
parent
9bb8902eed
commit
d81b6137d7
@ -0,0 +1,7 @@
|
|||||||
|
package io.github.simplexdev.api.annotations;
|
||||||
|
|
||||||
|
public enum ReqType {
|
||||||
|
PAPER,
|
||||||
|
WATERFALL,
|
||||||
|
BUNGEECORD
|
||||||
|
}
|
@ -7,10 +7,6 @@ import java.lang.annotation.Target;
|
|||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
public @interface ServerInfo {
|
public @interface Requires {
|
||||||
boolean isPaper() default false;
|
ReqType value();
|
||||||
|
|
||||||
boolean isWaterfall() default false;
|
|
||||||
|
|
||||||
boolean isBungeeCord() default false;
|
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package io.github.simplexdev.simplexcore.plugin;
|
package io.github.simplexdev.simplexcore.plugin;
|
||||||
|
|
||||||
import io.github.simplexdev.api.annotations.ServerInfo;
|
import io.github.simplexdev.api.annotations.ReqType;
|
||||||
import io.github.simplexdev.api.func.Guard;
|
import io.github.simplexdev.api.annotations.Requires;
|
||||||
import io.github.simplexdev.simplexcore.utils.Constants;
|
import io.github.simplexdev.simplexcore.utils.Constants;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -51,16 +51,23 @@ public final class AddonRegistry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkAnnotation(Requires info, ReqType type) {
|
||||||
|
return info.value() == type;
|
||||||
|
}
|
||||||
|
|
||||||
public <T extends SimplexAddon<T>> void register(T addon) {
|
public <T extends SimplexAddon<T>> void register(T addon) {
|
||||||
if (addon.getClass().isAnnotationPresent(ServerInfo.class)) {
|
if (addon.getClass().isAnnotationPresent(Requires.class)) {
|
||||||
ServerInfo info = addon.getClass().getDeclaredAnnotation(ServerInfo.class);
|
Requires info = addon.getClass().getDeclaredAnnotation(Requires.class);
|
||||||
if (info.isPaper() && !isPaper(addon)) {
|
if (checkAnnotation(info, ReqType.PAPER)
|
||||||
|
&& !isPaper(addon)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (info.isBungeeCord() && !isBungee(addon)) {
|
if (checkAnnotation(info, ReqType.BUNGEECORD)
|
||||||
|
&& !isBungee(addon)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (info.isWaterfall() && !isWaterfall(addon)) {
|
if (checkAnnotation(info, ReqType.WATERFALL)
|
||||||
|
&& !isWaterfall(addon)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user