From 0e4502d38f913317d4040406ed3992f4ea558f63 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Mon, 10 Feb 2020 19:10:08 +0100 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=9D=D0=BE=D1=80=D0=BC=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=B0=D1=8F=20=D1=81=D0=B5=D1=80=D0=B8=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20Enum.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/asm/InjectClassAcceptor.java | 2 ++ .../main/java/pro/gravit/launchserver/asm/NodeUtils.java | 7 +++++++ .../gravit/launchserver/binary/tasks/MainBuildTask.java | 1 - 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java index a852851b..fe5da412 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java @@ -171,6 +171,8 @@ private static InsnList serializeValue(Object value) { insnList.add(new LdcInsnNode(value)); return insnList; } + if (Enum.class.isInstance(value)) + return NodeUtils.makeValueEnumGetter((Enum)value); for (Map.Entry, Serializer> serializerEntry : serializers.entrySet()) { if (serializerEntry.getKey().isInstance(value)) { return ((Serializer) serializerEntry.getValue()).serialize(value); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/NodeUtils.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/NodeUtils.java index b85a27bd..1aabfbcf 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/NodeUtils.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/NodeUtils.java @@ -246,4 +246,11 @@ else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) ret.add(new LdcInsnNode(value)); return ret; } + + public static InsnList makeValueEnumGetter(@SuppressWarnings("rawtypes") Enum u) { + InsnList ret = new InsnList(); + Type e = Type.getType(u.getClass()); + ret.add(new FieldInsnNode(Opcodes.GETSTATIC, e.getInternalName(), u.name(), e.getDescriptor())); + return ret; + } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java index 2a4dd068..bbe656b9 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java @@ -8,7 +8,6 @@ import org.objectweb.asm.tree.FieldNode; import pro.gravit.launcher.Launcher; import pro.gravit.launcher.LauncherConfig; -import pro.gravit.launcher.LauncherConfig.LauncherEnvironment; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.asm.ClassMetadataReader; import pro.gravit.launchserver.asm.InjectClassAcceptor;