Permalink
Browse files

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.
  • Loading branch information...
wizjany committed Jan 12, 2017
1 parent e019890 commit 1c29e85f1914948ad69f6737c00e813eac810c79
@@ -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);
}
}

0 comments on commit 1c29e85

Please sign in to comment.