From 1447b0e3d2fe92971d8d050903853a2699dc43f5 Mon Sep 17 00:00:00 2001 From: Remasuri3 Date: Sat, 13 Dec 2025 06:00:24 +0100 Subject: [PATCH 1/3] Fix for null entries in PlayerPreparesEnchantScriptEvent --- .../player/PlayerPreparesEnchantScriptEvent.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/events/player/PlayerPreparesEnchantScriptEvent.java b/plugin/src/main/java/com/denizenscript/denizen/events/player/PlayerPreparesEnchantScriptEvent.java index af97ebd94b..6751fbb755 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/events/player/PlayerPreparesEnchantScriptEvent.java +++ b/plugin/src/main/java/com/denizenscript/denizen/events/player/PlayerPreparesEnchantScriptEvent.java @@ -76,7 +76,12 @@ public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) { return false; } for (int i = 0; i < offers.size(); i++) { - MapTag map = MapTag.getMapFor(offers.getObject(i), getTagContext(path)); + var offer = offers.getObject(i); + MapTag map = MapTag.getMapFor(offer, getTagContext(path)); + if(map.isEmpty()){ + event.getOffers()[i] = null; + continue; + } event.getOffers()[i].setCost(map.getElement("cost").asInt()); EnchantmentTag enchantment = map.getObjectAs("enchantment_type", EnchantmentTag.class, getTagContext(path)); if (enchantment == null) { @@ -108,6 +113,10 @@ public ObjectTag getContext(String name) { case "offers": ListTag output = new ListTag(); for (EnchantmentOffer offer : event.getOffers()) { + if(offer == null) { + output.addObject(new MapTag()); + continue; + } MapTag map = new MapTag(); map.putObject("cost", new ElementTag(offer.getCost())); map.putObject("enchantment", new ElementTag(offer.getEnchantment().getKey().getKey())); From 9073cb78a23d64d77ead0488788dceba6f852ba6 Mon Sep 17 00:00:00 2001 From: Remasuri3 Date: Sat, 13 Dec 2025 06:01:55 +0100 Subject: [PATCH 2/3] Fix for null entries in PlayerPreparesEnchantScriptEvent --- .../events/player/PlayerPreparesEnchantScriptEvent.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/events/player/PlayerPreparesEnchantScriptEvent.java b/plugin/src/main/java/com/denizenscript/denizen/events/player/PlayerPreparesEnchantScriptEvent.java index 6751fbb755..002b375b98 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/events/player/PlayerPreparesEnchantScriptEvent.java +++ b/plugin/src/main/java/com/denizenscript/denizen/events/player/PlayerPreparesEnchantScriptEvent.java @@ -76,8 +76,7 @@ public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) { return false; } for (int i = 0; i < offers.size(); i++) { - var offer = offers.getObject(i); - MapTag map = MapTag.getMapFor(offer, getTagContext(path)); + MapTag map = MapTag.getMapFor(offers.getObject(i), getTagContext(path)); if(map.isEmpty()){ event.getOffers()[i] = null; continue; From fca6ee7fb8d544d0713dba5f6f7ece728e4e957e Mon Sep 17 00:00:00 2001 From: Remasuri3 Date: Mon, 15 Dec 2025 22:44:22 +0100 Subject: [PATCH 3/3] Formatting fix --- .../events/player/PlayerPreparesEnchantScriptEvent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/events/player/PlayerPreparesEnchantScriptEvent.java b/plugin/src/main/java/com/denizenscript/denizen/events/player/PlayerPreparesEnchantScriptEvent.java index 002b375b98..af4caeb5eb 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/events/player/PlayerPreparesEnchantScriptEvent.java +++ b/plugin/src/main/java/com/denizenscript/denizen/events/player/PlayerPreparesEnchantScriptEvent.java @@ -77,7 +77,7 @@ public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) { } for (int i = 0; i < offers.size(); i++) { MapTag map = MapTag.getMapFor(offers.getObject(i), getTagContext(path)); - if(map.isEmpty()){ + if (map.isEmpty()){ event.getOffers()[i] = null; continue; } @@ -112,7 +112,7 @@ public ObjectTag getContext(String name) { case "offers": ListTag output = new ListTag(); for (EnchantmentOffer offer : event.getOffers()) { - if(offer == null) { + if (offer == null) { output.addObject(new MapTag()); continue; }