make the check more resilient in case the transformer is blocked

This commit is contained in:
FalsePattern committed 2023-01-04 01:26:23 +01:00
1 parent 4b3fc3c812
commit 4cbda7a568
3 files changed
+20 -9

No files matched your search

@@ -20,8 +20,10 @@
*/
package com.falsepattern.lib.internal;
import com.falsepattern.lib.internal.asm.CoreLoadingPlugin;
import com.falsepattern.lib.internal.proxy.CommonProxy;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLConstructionEvent;
@@ -64,6 +66,9 @@ public class FalsePatternLib {
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent e) {
if (Loader.isModLoaded("gasstation")) {
CoreLoadingPlugin.validateGasStation();
}
proxy.postInit(e);
}
@@ -32,6 +32,8 @@ import cpw.mods.fml.relauncher.IFMLLoadingPlugin.SortingIndex;
import java.util.Map;
import static com.falsepattern.lib.mixin.MixinInfo.isClassPresentSafe;
/**
* Coremod stub so that forge loads the jar early
*/
@@ -103,6 +105,18 @@ public class CoreLoadingPlugin implements IFMLLoadingPlugin {
return skillIssue;
}
public static void validateGasStation() {
//Make sure everything is loaded correctly, crash if gasstation is bugged
if (!isClassPresentSafe("com.falsepattern.gasstation.core.GasStationCore") || //Validate core class
!isClassPresentSafe("makamys.mixingasm.api.TransformerInclusions") || //Validate the mixingasm compat
!isClassPresentSafe("ru.timeconqueror.spongemixins.core.SpongeMixinsCore") || //Validate the spongemixins compat
!isClassPresentSafe("io.github.tox1cozz.mixinbooterlegacy.MixinBooterLegacyPlugin") || //Validate the MBL compat
(!isClassPresentSafe("org.spongepowered.asm.lib.Opcodes") || isClassPresentSafe("org.spongepowered.libraries.org.objectweb.asm.Opcodes")) //Validate correct mixins class
) {
throw new Error("Failed to validate your GasStation mixin plugin installation. Please make sure you have the latest GasStation installed from the official source: https://github.com/FalsePattern/GasStation");
}
}
@Override
public String[] getASMTransformerClass() {
return new String[]{Tags.GROUPNAME + ".internal.asm.FPTransformer"};
@@ -35,15 +35,7 @@ public class GasStationValidatorTransformer implements IClassNodeTransformer {
@Override
public boolean shouldTransform(ClassNode cn, String transformedName, boolean obfuscated) {
if (transformedName.equals("com.falsepattern.gasstation.GasStation")) {
//Make sure everything is loaded correctly, crash if gasstation is bugged
if (!isClassPresentSafe("com.falsepattern.gasstation.core.GasStationCore") || //Validate core class
!isClassPresentSafe("makamys.mixingasm.api.TransformerInclusions") || //Validate the mixingasm compat
!isClassPresentSafe("ru.timeconqueror.spongemixins.core.SpongeMixinsCore") || //Validate the spongemixins compat
!isClassPresentSafe("io.github.tox1cozz.mixinbooterlegacy.MixinBooterLegacyPlugin") || //Validate the MBL compat
(!isClassPresentSafe("org.spongepowered.asm.lib.Opcodes") || isClassPresentSafe("org.spongepowered.libraries.org.objectweb.asm.Opcodes")) //Validate correct mixins class
) {
throw new Error("Failed to validate your GasStation mixin plugin installation. Please make sure you have the latest GasStation installed from the official source: https://github.com/FalsePattern/GasStation");
}
CoreLoadingPlugin.validateGasStation();
}
return false;
}