From 4d5700844809d45ca27a7efe8500d9d4c828ea2f Mon Sep 17 00:00:00 2001 From: PandaNinjas Date: Sun, 29 Jan 2023 21:42:45 -0800 Subject: On today's edition of why you shouldn't use git after 12 AM --- .../nosession/tweaks/CleanupTweaker.java | 82 ---------------------- 1 file changed, 82 deletions(-) delete mode 100644 src/main/java/gq/malwarefight/nosession/tweaks/CleanupTweaker.java (limited to 'src/main/java/gq/malwarefight/nosession/tweaks/CleanupTweaker.java') diff --git a/src/main/java/gq/malwarefight/nosession/tweaks/CleanupTweaker.java b/src/main/java/gq/malwarefight/nosession/tweaks/CleanupTweaker.java deleted file mode 100644 index 6deeeb0..0000000 --- a/src/main/java/gq/malwarefight/nosession/tweaks/CleanupTweaker.java +++ /dev/null @@ -1,82 +0,0 @@ -package gq.malwarefight.nosession.tweaks; - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import net.minecraft.launchwrapper.ITweaker; -import net.minecraft.launchwrapper.Launch; -import net.minecraft.launchwrapper.LaunchClassLoader; -import net.minecraftforge.fml.common.asm.ASMTransformerWrapper; - -import java.io.File; -import java.lang.reflect.*; -import java.net.URL; -import java.net.URLStreamHandler; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import gq.malwarefight.nosession.utils.Utils; - -public class CleanupTweaker implements ITweaker { - /** - * Cached to avoid expensive reflection operations - */ - public Method makeWrapper; - - public CleanupTweaker() throws NoSuchMethodException { - makeWrapper = ASMTransformerWrapper.class.getDeclaredMethod("makeWrapper", String.class); - makeWrapper.setAccessible(true); - } - @Override - @SuppressWarnings("unchecked") - public void acceptOptions(List args, File gameDir, File assetsDir, String profile) { - // add the FMLTweaker - ArrayList tweakerList = (ArrayList) Launch.blackboard.get("TweakClasses"); - tweakerList.add("net.minecraftforge.fml.common.launcher.FMLTweaker"); - // reset ASMTransformerWrapper - Class cls = ASMTransformerWrapper.class; - try { - Utils.setStaticValue(cls, "wrapperModMap", new HashMap()); - Utils.setStaticValue(cls, "wrapperParentMap", new HashMap()); - Utils.setStaticValue(cls, "wrapperCache", CacheBuilder.newBuilder().maximumSize(30L).weakValues().build(new CacheLoader() { - public byte[] load(String file) throws Exception { - return (byte[]) makeWrapper.invoke(null, file); - } - })); - Utils.setStaticValue(cls, "asmGenRoot", new URL("asmgen", null, -1, "/", getAsmGenHandler())); - Utils.setStaticValue(cls, "injected", false); - } catch (Exception e) { - System.err.println("NoSession: Fixing ASMTransformerWrapper failed. Things may break."); - e.printStackTrace(); - } - } - - @Override - public void injectIntoClassLoader(LaunchClassLoader classLoader) {} - - @Override - public String getLaunchTarget() { - return "net.minecraft.client.main.Main"; - } - - @Override - public String[] getLaunchArguments() { - return new String[0]; - } - - - - @SuppressWarnings("unchecked") - private URLStreamHandler getAsmGenHandler() throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { - Class cls = ASMTransformerWrapper.class; - for (Class candidate: cls.getDeclaredClasses()) { - if (candidate.getSimpleName().equals("ASMGenHandler")) { - Method pgdc = Class.class.getDeclaredMethod("privateGetDeclaredConstructors", boolean.class); - pgdc.setAccessible(true); - Constructor constructor = ((Constructor[]) pgdc.invoke(candidate, false))[0]; - constructor.setAccessible(true); - return constructor.newInstance(); - } - } - throw new RuntimeException("NoSession: unable to get the ASMGenHandler"); - } -} -- cgit