mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-25 01:21:38 +01:00
Check Material in TargetMatcherParser.
This commit is contained in:
parent
358eebf96b
commit
6e8e59aee5
@ -23,6 +23,8 @@
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Ranges;
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
import com.sk89q.worldguard.util.Enums;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -52,10 +54,16 @@ private int parseType(String input) throws TargetMatcherParseException {
|
||||
return Integer.parseInt(input);
|
||||
} catch (NumberFormatException e) {
|
||||
int id = getItemID(input);
|
||||
if (id == 0) {
|
||||
throw new TargetMatcherParseException("Unknown block or item name: " + input);
|
||||
if (id != 0) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user