From b4e97786b02afbefad7088e923c4d2ca7366d8a9 Mon Sep 17 00:00:00 2001 From: yushijinhun Date: Wed, 23 Jan 2019 20:17:27 +0800 Subject: [PATCH] polish --- .../yushi/authlibinjector/transform/CallbackSupport.java | 4 +++- .../transform/support/MC52974_1710Workaround.java | 6 ++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/moe/yushi/authlibinjector/transform/CallbackSupport.java b/src/main/java/moe/yushi/authlibinjector/transform/CallbackSupport.java index f148a17..00cf9f1 100644 --- a/src/main/java/moe/yushi/authlibinjector/transform/CallbackSupport.java +++ b/src/main/java/moe/yushi/authlibinjector/transform/CallbackSupport.java @@ -27,7 +27,9 @@ import org.objectweb.asm.Type; import moe.yushi.authlibinjector.transform.TransformUnit.TransformContext; -public class CallbackSupport { +public final class CallbackSupport { + private CallbackSupport() { + } private static Method findCallbackMethod(Class owner, String methodName) { for (Method method : owner.getDeclaredMethods()) { diff --git a/src/main/java/moe/yushi/authlibinjector/transform/support/MC52974_1710Workaround.java b/src/main/java/moe/yushi/authlibinjector/transform/support/MC52974_1710Workaround.java index f5c0509..abd5f5d 100644 --- a/src/main/java/moe/yushi/authlibinjector/transform/support/MC52974_1710Workaround.java +++ b/src/main/java/moe/yushi/authlibinjector/transform/support/MC52974_1710Workaround.java @@ -123,7 +123,6 @@ public class MC52974_1710Workaround { ctx.markModified(); super.visitInsn(DUP); CallbackSupport.invoke(ctx, mv, MC52974_1710Workaround.class, "markGameProfile"); - super.visitTypeInsn(CHECKCAST, "com/mojang/authlib/GameProfile"); } super.visitInsn(opcode); } @@ -154,11 +153,12 @@ public class MC52974_1710Workaround { return new MethodVisitor(ASM7, super.visitMethod(access, name, descriptor, signature, exceptions)) { @Override public void visitFieldInsn(int opcode, String owner, String name, String descriptor) { + super.visitFieldInsn(opcode, owner, name, descriptor); + if (opcode == GETFIELD && (isNotchName ? "gb".equals(owner) && "b".equals(name) && "Lcom/mojang/authlib/GameProfile;".equals(descriptor) : "net/minecraft/network/play/server/S0CPacketSpawnPlayer".equals(owner) && "field_148955_b".equals(name) && "Lcom/mojang/authlib/GameProfile;".equals(descriptor))) { ctx.markModified(); - super.visitFieldInsn(opcode, owner, name, descriptor); if (isNotchName) { super.visitMethodInsn(INVOKESTATIC, "net/minecraft/server/MinecraftServer", "I", "()Lnet/minecraft/server/MinecraftServer;", false); } else { @@ -167,8 +167,6 @@ public class MC52974_1710Workaround { super.visitLdcInsn(isNotchName ? 1 : 0); CallbackSupport.invoke(ctx, mv, MC52974_1710Workaround.class, "accessGameProfile"); super.visitTypeInsn(CHECKCAST, "com/mojang/authlib/GameProfile"); - } else { - super.visitFieldInsn(opcode, owner, name, descriptor); } } };