forked from MirrorHub/authlib-injector
parent
590ba38b3e
commit
79873f126c
2 changed files with 52 additions and 0 deletions
|
@ -51,6 +51,7 @@ import moe.yushi.authlibinjector.transform.DumpClassListener;
|
|||
import moe.yushi.authlibinjector.transform.SkinWhitelistTransformUnit;
|
||||
import moe.yushi.authlibinjector.transform.YggdrasilKeyTransformUnit;
|
||||
import moe.yushi.authlibinjector.transform.support.CitizensTransformer;
|
||||
import moe.yushi.authlibinjector.transform.support.LaunchWrapperTransformer;
|
||||
import moe.yushi.authlibinjector.util.Logging;
|
||||
import moe.yushi.authlibinjector.yggdrasil.CustomYggdrasilAPIProvider;
|
||||
import moe.yushi.authlibinjector.yggdrasil.MojangYggdrasilAPIProvider;
|
||||
|
@ -332,6 +333,7 @@ public final class AuthlibInjector {
|
|||
|
||||
transformer.units.add(new ConstantURLTransformUnit(urlProcessor));
|
||||
transformer.units.add(new CitizensTransformer());
|
||||
transformer.units.add(new LaunchWrapperTransformer());
|
||||
|
||||
transformer.units.add(new SkinWhitelistTransformUnit(config.getSkinDomains().toArray(new String[0])));
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package moe.yushi.authlibinjector.transform.support;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.ALOAD;
|
||||
import static org.objectweb.asm.Opcodes.ASM7;
|
||||
import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
|
||||
import static org.objectweb.asm.Opcodes.RETURN;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
|
||||
import moe.yushi.authlibinjector.transform.TransformUnit;
|
||||
|
||||
public class LaunchWrapperTransformer implements TransformUnit {
|
||||
|
||||
@Override
|
||||
public Optional<ClassVisitor> transform(ClassLoader classLoader, String className, ClassVisitor writer, Runnable modifiedCallback) {
|
||||
if ("net.minecraft.launchwrapper.LaunchClassLoader".equals(className)) {
|
||||
return Optional.of(new ClassVisitor(ASM7, writer) {
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
|
||||
if ("<init>".equals(name)) {
|
||||
return new MethodVisitor(ASM7, super.visitMethod(access, name, descriptor, signature, exceptions)) {
|
||||
@Override
|
||||
public void visitInsn(int opcode) {
|
||||
if (opcode == RETURN) {
|
||||
modifiedCallback.run();
|
||||
super.visitVarInsn(ALOAD, 0);
|
||||
super.visitLdcInsn("moe.yushi.authlibinjector.");
|
||||
super.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/launchwrapper/LaunchClassLoader", "addClassLoaderExclusion", "(Ljava/lang/String;)V", false);
|
||||
}
|
||||
super.visitInsn(opcode);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return super.visitMethod(access, name, descriptor, signature, exceptions);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LaunchWrapper Support";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue