From 4cbda7a568cb5b0fe86f7159d57c890cc497250b Mon Sep 17 00:00:00 2001 From: FalsePattern <30945458+FalsePattern@users.noreply.github.com> Date: Wed, 4 Jan 2023 01:26:23 +0100 Subject: [PATCH] make the check more resilient in case the transformer is blocked --- .../falsepattern/lib/internal/FalsePatternLib.java | 5 +++++ .../lib/internal/asm/CoreLoadingPlugin.java | 14 ++++++++++++++ .../asm/GasStationValidatorTransformer.java | 10 +--------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/falsepattern/lib/internal/FalsePatternLib.java b/src/main/java/com/falsepattern/lib/internal/FalsePatternLib.java index a7a426d..4a0ee53 100644 --- a/src/main/java/com/falsepattern/lib/internal/FalsePatternLib.java +++ b/src/main/java/com/falsepattern/lib/internal/FalsePatternLib.java @@ -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); } diff --git a/src/main/java/com/falsepattern/lib/internal/asm/CoreLoadingPlugin.java b/src/main/java/com/falsepattern/lib/internal/asm/CoreLoadingPlugin.java index 864483b..3baded9 100644 --- a/src/main/java/com/falsepattern/lib/internal/asm/CoreLoadingPlugin.java +++ b/src/main/java/com/falsepattern/lib/internal/asm/CoreLoadingPlugin.java @@ -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"}; diff --git a/src/main/java/com/falsepattern/lib/internal/asm/GasStationValidatorTransformer.java b/src/main/java/com/falsepattern/lib/internal/asm/GasStationValidatorTransformer.java index 391b89e..c9f5f85 100644 --- a/src/main/java/com/falsepattern/lib/internal/asm/GasStationValidatorTransformer.java +++ b/src/main/java/com/falsepattern/lib/internal/asm/GasStationValidatorTransformer.java @@ -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; }