From db91b606f602bf84cec686681a93c222e56bcc78 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 1 Apr 2024 16:12:52 -0400 Subject: [PATCH] Proper parsing of power grants --- src/engine/objects/ItemTemplate.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index bf72c21e..cc180f04 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -350,13 +350,18 @@ public class ItemTemplate { item_user_power_action.put(power, arguments); } - JSONArray powerGrants = (JSONArray) jsonObject.get("item_power_grant"); + JSONArray powerGrantsArray = (JSONArray) jsonObject.get("item_power_grant"); - if (powerGrants.isEmpty() == false) { + if (powerGrantsArray.isEmpty() == false) { - for (Object grantedPower : powerGrants) { - JSONObject powerGrant = (JSONObject) grantedPower; + for (Object grantEntry : powerGrantsArray) { + JSONObject powerGrant = (JSONObject) grantEntry; + for (Object key : powerGrant.keySet()) { + String powerString = (String) key; + int powerLevel = ((Long) powerGrant.get(key)).intValue(); + item_power_grant.put(powerString, powerLevel); + } } }