From d3f9b5381060f7f820f755c837a9cc3ae60cddf8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 24 Feb 2024 14:28:28 -0500 Subject: [PATCH] Parsing discs --- src/engine/objects/ItemTemplate.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 5453a1d0..87c8e85b 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -56,6 +56,8 @@ public class ItemTemplate { public EnumSet item_class_req = EnumSet.noneOf(Enum.ClassType.class); public EnumSet item_class_res = EnumSet.noneOf(Enum.ClassType.class); + public EnumSet item_disc_req = EnumSet.noneOf(Enum.ClassType.class); + public EnumSet item_disc_res = EnumSet.noneOf(Enum.ClassType.class); public ItemTemplate(JSONObject jsonObject) { @@ -203,6 +205,21 @@ public class ItemTemplate { item_class_req.add(Enum.ClassType.valueOf(classEntry)); } + JSONObject disc_required = (JSONObject) jsonObject.get("item_disc_req"); + restrict = ((Boolean) disc_required.get("restrict")); + JSONArray discs = (JSONArray) disc_required.get("classes"); + + for (Object o : discs) { + String disc = (String) o; + disc = disc.replaceAll("\\s", ""); + disc = disc.replaceAll(",", ""); + + if (restrict) + item_disc_res.add(Enum.ClassType.valueOf(disc)); + else + item_disc_req.add(Enum.ClassType.valueOf(disc)); + } + } catch (Exception e) { Logger.error(e); }