|
@@ -6,17 +6,40 @@ import org.apache.logging.log4j.Logger;
|
|
|
import org.objectweb.asm.tree.ClassNode;
|
|
|
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
|
|
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
|
|
+import org.spongepowered.asm.service.MixinService;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
|
|
|
public abstract class FerriteMixinConfig implements IMixinConfigPlugin {
|
|
|
protected static final Logger LOGGER = LogManager.getLogger("ferritecore-mixin");
|
|
|
+ private static final boolean HAS_LITHIUM;
|
|
|
+
|
|
|
+ static {
|
|
|
+ boolean hasLithium;
|
|
|
+ try {
|
|
|
+ // This does *not* load the class!
|
|
|
+ MixinService.getService()
|
|
|
+ .getBytecodeProvider()
|
|
|
+ .getClassNode("me.jellysquid.mods.lithium.common.LithiumMod");
|
|
|
+ hasLithium = true;
|
|
|
+ } catch (ClassNotFoundException | IOException e) {
|
|
|
+ hasLithium = false;
|
|
|
+ }
|
|
|
+ HAS_LITHIUM = hasLithium;
|
|
|
+ }
|
|
|
private String prefix = null;
|
|
|
private final FerriteConfig.Option enableOption;
|
|
|
+ private final boolean disableWithLithium;
|
|
|
|
|
|
- protected FerriteMixinConfig(FerriteConfig.Option enableOption) {
|
|
|
+ protected FerriteMixinConfig(FerriteConfig.Option enableOption, boolean disableWithLithium) {
|
|
|
this.enableOption = enableOption;
|
|
|
+ this.disableWithLithium = disableWithLithium;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected FerriteMixinConfig(FerriteConfig.Option enableOption) {
|
|
|
+ this(enableOption, false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -25,6 +48,9 @@ public abstract class FerriteMixinConfig implements IMixinConfigPlugin {
|
|
|
if (!enableOption.isEnabled()) {
|
|
|
LOGGER.warn("Mixin " + mixinClassName + " is disabled by config");
|
|
|
return false;
|
|
|
+ } else if (disableWithLithium && HAS_LITHIUM) {
|
|
|
+ LOGGER.warn("Mixin " + mixinClassName + " is disabled automatically as lithium is installed");
|
|
|
+ return false;
|
|
|
} else {
|
|
|
return true;
|
|
|
}
|