From 62e13ade01bf10c7aebc3652adaabaf6e781cc1e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 19 Feb 2024 03:58:43 -0500 Subject: [PATCH] String cleanup for skill enums. --- src/engine/objects/ItemTemplate.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 0513e657..61e2798e 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -105,20 +105,22 @@ public class ItemTemplate { item_render_object_female = ((Long) jsonObject.get("item_render_object_female")).intValue(); item_health_full = ((Double) jsonObject.get("item_health_full")).floatValue(); - String skills_used = (String) jsonObject.get("item_skill_used"); + Object skills_used = jsonObject.get("item_skill_used"); - if (skills_used.length() > 1) { - skills_used = skills_used.replaceAll("\\s", ""); - skills_used = skills_used.replaceAll(",", ""); - item_skill_used.add(Enum.CharacterSkills.valueOf(skills_used)); + if (skills_used instanceof String) { + String skilString = (String) skills_used; + skilString = skilString.replaceAll("\\s", ""); + skilString = skilString.replaceAll(",", ""); + item_skill_used.add(Enum.CharacterSkills.valueOf(skilString)); } - String mastery_used = (String) jsonObject.get("item_skill_mastery_used"); + Object mastery_used = jsonObject.get("item_skill_mastery_used"); - if (mastery_used.length() > 1) { - mastery_used = mastery_used.replaceAll("\\s", ""); - mastery_used = mastery_used.replaceAll(",", ""); - item_skill_mastery_used.add(Enum.CharacterSkills.valueOf(mastery_used)); + if (mastery_used instanceof String) { + String masteryString = (String) mastery_used; + masteryString = masteryString.replaceAll("\\s", ""); + masteryString = masteryString.replaceAll(",", ""); + item_skill_mastery_used.add(Enum.CharacterSkills.valueOf(masteryString)); } }