Skip to content

Commit

Permalink
may java help whoever wants to use this
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Jan 30, 2024
1 parent 15a435a commit b9ce309
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
5 changes: 0 additions & 5 deletions src/main/java/org/violetmoon/zeta/annotation/Requirement.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,4 @@
* Versions | Doesnt work yet
*/
String[] versionPredicates() default {};

/**
* if true, then mixin is applied when x mod is present otherwise not
*/
boolean applyIfPresent() default true;
}
20 changes: 16 additions & 4 deletions src/main/java/org/violetmoon/zeta/api/ConditionalMixinManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.violetmoon.zeta.api;

import org.jetbrains.annotations.ApiStatus;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.spongepowered.asm.service.MixinService;
Expand All @@ -11,6 +12,10 @@
import java.io.IOException;
import java.util.List;

/**
* You are on your own using this; I do not understand what's going on here with the for loops lmao
*/
@ApiStatus.Internal
public class ConditionalMixinManager {
public static boolean shouldApply(Zeta zeta, String targetClassName, String mixinClassName) {
try {
Expand All @@ -23,12 +28,19 @@ public static boolean shouldApply(Zeta zeta, String targetClassName, String mixi
List<Requirement> requirements = Annotations.getValue(node, "require", Requirement.class);
for (Requirement req : requirements) {
String[] modids = req.value();
boolean applyIfPresent = req.applyIfPresent();

boolean areModsLoaded = areModsLoaded(zeta, modids);
shouldApply = areModsLoaded(zeta, modids);

shouldApply = areModsLoaded == applyIfPresent;
Zeta.GLOBAL_LOG.info("{}: {} is{}being applied because the mod(s) {} are{}loaded", zeta.modid, targetClassName, shouldApply ? " " : " not ", modids, areModsLoaded ? " " : " not ");
Zeta.GLOBAL_LOG.info("{}: {} is{}being applied because the mod(s) {} are{}loaded", zeta.getModDisplayName(zeta.modid), targetClassName, shouldApply ? " " : " not ", modids, shouldApply ? " " : " not ");
}

List<Requirement> 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 ");
}
}
}
Expand Down

0 comments on commit b9ce309

Please sign in to comment.