From ddb7468db1d834eba211754a0bc5062b6e806264 Mon Sep 17 00:00:00 2001 From: Aria Sangarin Date: Wed, 26 Feb 2020 19:18:40 +0100 Subject: [PATCH] Extra check when loading MMOItemTriggers --- .../Indyuce/mmoitems/comp/mmocore/load/MMOItemTrigger.java | 4 ++-- src/main/java/net/Indyuce/mmoitems/manager/ItemManager.java | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/Indyuce/mmoitems/comp/mmocore/load/MMOItemTrigger.java b/src/main/java/net/Indyuce/mmoitems/comp/mmocore/load/MMOItemTrigger.java index 920fdd7b..ae66dfce 100644 --- a/src/main/java/net/Indyuce/mmoitems/comp/mmocore/load/MMOItemTrigger.java +++ b/src/main/java/net/Indyuce/mmoitems/comp/mmocore/load/MMOItemTrigger.java @@ -25,9 +25,9 @@ public class MMOItemTrigger extends Trigger { Validate.isTrue(MMOItems.plugin.getTypes().has(format), "Could not find item type " + format); type = MMOItems.plugin.getTypes().get(format); - id = config.getString("id"); + id = config.getString("id").replace("-", "_").toUpperCase(); amount = config.args().length > 0 ? Math.max(1, Integer.parseInt(config.args()[0])) : 1; - Validate.isTrue(MMOItems.plugin.getItems().getItem(type, id) != null, "Could not find item id " + id); + Validate.isTrue(MMOItems.plugin.getItems().exists(type, id), "Could not find item id " + id); } @Override diff --git a/src/main/java/net/Indyuce/mmoitems/manager/ItemManager.java b/src/main/java/net/Indyuce/mmoitems/manager/ItemManager.java index ca435977..54b0612c 100644 --- a/src/main/java/net/Indyuce/mmoitems/manager/ItemManager.java +++ b/src/main/java/net/Indyuce/mmoitems/manager/ItemManager.java @@ -71,6 +71,11 @@ public class ItemManager extends BukkitRunnable { return item == null ? null : item.newBuilder().build(); } + public boolean exists(Type type, String id) { + if(type == null) return false; + return type.getConfigFile().getConfig().contains(id.replace("-", "_").toUpperCase()); + } + /* * every two minutes, loops through any loaded item and uncaches any if they * have not been generated for more than 5 minutes.