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;