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.
This commit is contained in:
wizjany 2017-01-12 14:11:57 -05:00
parent e019890f1d
commit 1c29e85f19

View File

@ -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);
}
}