From 624710397c5ef7766a10deffdb652087fca38d43 Mon Sep 17 00:00:00 2001 From: Hydroxycobalamin <54799651+Hydroxycobalamin@users.noreply.github.com> Date: Wed, 30 Nov 2022 23:49:39 +0100 Subject: [PATCH] Add `script` item advanced matcher (#2403) * add script item advanced matcher * move boolean --- .../java/com/denizenscript/denizen/objects/ItemTag.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/ItemTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/ItemTag.java index 111bef6f6f..7b5502adc7 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/ItemTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/ItemTag.java @@ -78,6 +78,7 @@ public class ItemTag implements ObjectTag, Adjustable, FlaggableObject { // @Matchable // ItemTag matchers, sometimes identified as "", often seen as "with:": // "potion": plaintext: matches if the item is any form of potion item. + // "script": plaintext: matches if the item is any form of script item. // "item_flagged:": A Flag Matcher for item flags. // "item_enchanted:": matches if the item is enchanted with the given enchantment name. Allows advanced matchers. // "raw_exact:": matches based on exact raw item data comparison (almost always a bad idea to use). @@ -943,6 +944,10 @@ else if (matcherLow.startsWith("raw_exact:")) { if (matcherLow.equals("potion") && CoreUtilities.toLowerCase(getBukkitMaterial().name()).contains("potion")) { return true; } + boolean isItemScript = isItemscript(); + if (matcherLow.equals("script") && isItemScript) { + return true; + } if (matcher.contains("[") && matcher.endsWith("]")) { ItemPropertyMatchHelper helper = getPropertyMatchHelper(matcher); if (helper == null) { @@ -950,7 +955,6 @@ else if (matcherLow.startsWith("raw_exact:")) { } return helper.doesMatch(this); } - boolean isItemScript = isItemscript(); if (isItemScript) { ScriptEvent.MatchHelper matchHelper = BukkitScriptEvent.createMatcher(matcher); if (matchHelper.doesMatch(getScriptName())) {