diff --git a/src/main/java/org/violetmoon/zeta/annotation/ConditionalMixin.java b/src/main/java/org/violetmoon/zeta/annotation/ConditionalMixin.java index ac01826..44cc6a8 100644 --- a/src/main/java/org/violetmoon/zeta/annotation/ConditionalMixin.java +++ b/src/main/java/org/violetmoon/zeta/annotation/ConditionalMixin.java @@ -12,12 +12,9 @@ @Retention(RetentionPolicy.RUNTIME) public @interface ConditionalMixin { /** - * Only load mixin if requirements are fulfilled + * List of mod id's */ - Requirement[] require() default {}; + String[] value(); - /** - * Don't load mixin if any of the requirements are fulfilled, higher priority then require - */ - Requirement[] conflict() default {}; + boolean applyIfPresent() default true; } diff --git a/src/main/java/org/violetmoon/zeta/annotation/Requirement.java b/src/main/java/org/violetmoon/zeta/annotation/Requirement.java deleted file mode 100644 index 90272a5..0000000 --- a/src/main/java/org/violetmoon/zeta/annotation/Requirement.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.violetmoon.zeta.annotation; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface Requirement { - /** - * List of mod-id's - */ - String[] value(); - - /** - * Versions | Doesnt work yet - */ - String[] versionPredicates() default {}; -} diff --git a/src/main/java/org/violetmoon/zeta/api/ConditionalMixinManager.java b/src/main/java/org/violetmoon/zeta/api/ConditionalMixinManager.java index 2fc8b77..e6acca4 100644 --- a/src/main/java/org/violetmoon/zeta/api/ConditionalMixinManager.java +++ b/src/main/java/org/violetmoon/zeta/api/ConditionalMixinManager.java @@ -7,7 +7,6 @@ import org.spongepowered.asm.util.Annotations; import org.violetmoon.zeta.Zeta; import org.violetmoon.zeta.annotation.ConditionalMixin; -import org.violetmoon.zeta.annotation.Requirement; import java.io.IOException; import java.util.List; @@ -28,23 +27,11 @@ public static boolean shouldApply(Zeta zeta, String targetClassName, String mixi boolean shouldApply = true; for (AnnotationNode node : annotationNodes) { if (node.desc.equals(Type.getDescriptor(ConditionalMixin.class))) { - List requirements = Annotations.getValue(node, "require", Requirement.class); - for (Requirement req : requirements) { - String[] modids = req.value(); - - shouldApply = areModsLoaded(zeta, modids); - - Zeta.GLOBAL_LOG.info("{}: {} is{}being applied because the mod(s) {} are{}loaded", zeta.getModDisplayName(zeta.modid), targetClassName, shouldApply ? " " : " not ", modids, shouldApply ? " " : " not "); - } - - List conflicts = Annotations.getValue(node, "conflict", Requirement.class); - for (Requirement conflict : conflicts) { - String[] modids = conflict.value(); - - shouldApply = areModsLoaded(zeta, modids); - - Zeta.GLOBAL_LOG.info("{}: {} is{}being applied because the mod(s) {} are{}loaded", zeta.getModDisplayName(zeta.modid), targetClassName, shouldApply ? " " : " not ", modids, shouldApply ? " " : " not "); - } + List mods = Annotations.getValue(node, "value"); + boolean applyIfPresent = Annotations.getValue(node, "applyIfPresent", Boolean.TRUE); + boolean anyModsLoaded = areModsLoaded(zeta, mods); + shouldApply = anyModsLoaded == applyIfPresent; + Zeta.GLOBAL_LOG.info("{}: {} is{}being applied because the mod(s) {} are{}loaded", zeta.getModDisplayName(zeta.modid), targetClassName, shouldApply ? " " : " not ", mods, anyModsLoaded ? " " : " not "); } } @@ -54,7 +41,7 @@ public static boolean shouldApply(Zeta zeta, String targetClassName, String mixi } } - private static boolean areModsLoaded(Zeta zeta, String[] modids) { + private static boolean areModsLoaded(Zeta zeta, List modids) { for (String mod : modids) { if (zeta.isModLoaded(mod)) { return true;