From 1c29e85f1914948ad69f6737c00e813eac810c79 Mon Sep 17 00:00:00 2001 From: wizjany Date: Thu, 12 Jan 2017 14:11:57 -0500 Subject: [PATCH] Prefer Material enum over ItemType lookup when parsing TargetMatchers. This will make Bukkit's names take priority when trying to identify a block or item, since ItemType lookup will return, e.g. "birch_door_item" for "birch_door", even though there's a block with the name "birch_door". Note that using int ids is always preferable when possible since there's no confusion there. Fixes WORLDGUARD-3790. --- .../blacklist/target/TargetMatcherParser.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/blacklist/target/TargetMatcherParser.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/blacklist/target/TargetMatcherParser.java index c698c469..b5f9aab8 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/blacklist/target/TargetMatcherParser.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/blacklist/target/TargetMatcherParser.java @@ -53,16 +53,16 @@ private int parseType(String input) throws TargetMatcherParseException { try { return Integer.parseInt(input); } catch (NumberFormatException e) { - int id = getItemID(input); - if (id > 0) { - return id; - } - Material material = Enums.findFuzzyByValue(Material.class, input); if (material != null) { return material.getId(); } + int id = getItemID(input); + if (id > 0) { + return id; + } + throw new TargetMatcherParseException("Unknown block or item name: " + input); } }