Check Material in TargetMatcherParser.

This commit is contained in:
sk89q 2014-08-29 12:38:27 -07:00
parent 358eebf96b
commit 6e8e59aee5

View File

@ -23,6 +23,8 @@
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.collect.Ranges; import com.google.common.collect.Ranges;
import com.sk89q.worldedit.blocks.ItemType; import com.sk89q.worldedit.blocks.ItemType;
import com.sk89q.worldguard.util.Enums;
import org.bukkit.Material;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -52,11 +54,17 @@ private int parseType(String input) throws TargetMatcherParseException {
return Integer.parseInt(input); return Integer.parseInt(input);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
int id = getItemID(input); int id = getItemID(input);
if (id == 0) { if (id != 0) {
throw new TargetMatcherParseException("Unknown block or item name: " + input);
}
return id; return id;
} }
Material material = Enums.findFuzzyByValue(Material.class, input);
if (material != null) {
return material.getId();
}
throw new TargetMatcherParseException("Unknown block or item name: " + input);
}
} }
private Predicate<Short> parseDataValueRanges(String input) throws TargetMatcherParseException { private Predicate<Short> parseDataValueRanges(String input) throws TargetMatcherParseException {