Allow underscores in icons.

This commit is contained in:
filoghost 2014-09-03 14:24:57 +02:00
parent 5f783684f4
commit 45f9c2248f
2 changed files with 7 additions and 4 deletions

View File

@ -54,7 +54,7 @@ public class CommandValidator {
@SuppressWarnings("deprecation")
public static ItemStack matchItemStack(String input) throws CommandException {
input = input.replace(" ", ""); // Cut the spaces
input = input.replace(" ", ""); // Remove the spaces
int dataValue = 0;
if (input.contains(":")) {

View File

@ -43,17 +43,20 @@ public class ItemUtils {
// A map with formatter materials (lowercase and without dashes) for fast access.
private static Map<String, Material> materialMap = new HashMap<String, Material>();
private static Pattern stripSymbolsPattern = Pattern.compile("_- ");
private static Pattern stripSymbolsPattern = Pattern.compile("[_ \\-]+");
static {
for (Material mat : Material.values()) {
materialMap.put(mat.toString().toLowerCase().replace("_", ""), mat);
materialMap.put(stripSpacingChars(mat.toString()).toLowerCase(), mat);
}
}
public static String stripSpacingChars(String input) {
return stripSymbolsPattern.matcher(input).replaceAll("");
}
public static Material matchMaterial(String input) {
return materialMap.get(stripSymbolsPattern.matcher(input.toLowerCase()).replaceAll(""));
return materialMap.get(stripSpacingChars(input).toLowerCase());
}
@SuppressWarnings("deprecation")