From 7f4f73603d004fc9de96add539bc821191d30302 Mon Sep 17 00:00:00 2001 From: Eduardo Alonso Date: Sat, 19 Jan 2019 01:53:10 +0100 Subject: [PATCH] Fix HEntity's HGender parser * Exceptions like: No enum constant gearth.extensions.parsers.HGender.m appeared when trying to parse an HEntity, adding a proper HGender parser seems to solve the problem --- .../src/main/java/gearth/extensions/parsers/HEntity.java | 2 +- .../src/main/java/gearth/extensions/parsers/HGender.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/G-Earth/src/main/java/gearth/extensions/parsers/HEntity.java b/G-Earth/src/main/java/gearth/extensions/parsers/HEntity.java index 860d111..9dcf20f 100644 --- a/G-Earth/src/main/java/gearth/extensions/parsers/HEntity.java +++ b/G-Earth/src/main/java/gearth/extensions/parsers/HEntity.java @@ -29,7 +29,7 @@ public class HEntity { switch (entityTypeId) { case 1: - gender = HGender.valueOf(packet.readString()); + gender = HGender.fromString(packet.readString()); packet.readInteger(); packet.readInteger(); favoriteGroup = packet.readString(); diff --git a/G-Earth/src/main/java/gearth/extensions/parsers/HGender.java b/G-Earth/src/main/java/gearth/extensions/parsers/HGender.java index 07d2d27..a3d528e 100644 --- a/G-Earth/src/main/java/gearth/extensions/parsers/HGender.java +++ b/G-Earth/src/main/java/gearth/extensions/parsers/HGender.java @@ -14,4 +14,12 @@ public enum HGender { public String toString() { return id; } + + public static HGender fromString(String text) { + for (HGender g : HGender.values()) { + if (g.toString().toLowerCase().equals(text.toLowerCase())) + return g; + } + return null; + } }