mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-21 00:07:48 +01:00
Allow underscores in icons.
This commit is contained in:
parent
5f783684f4
commit
45f9c2248f
@ -54,7 +54,7 @@ public class CommandValidator {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static ItemStack matchItemStack(String input) throws CommandException {
|
public static ItemStack matchItemStack(String input) throws CommandException {
|
||||||
|
|
||||||
input = input.replace(" ", ""); // Cut the spaces
|
input = input.replace(" ", ""); // Remove the spaces
|
||||||
|
|
||||||
int dataValue = 0;
|
int dataValue = 0;
|
||||||
if (input.contains(":")) {
|
if (input.contains(":")) {
|
||||||
|
@ -43,17 +43,20 @@ public class ItemUtils {
|
|||||||
|
|
||||||
// A map with formatter materials (lowercase and without dashes) for fast access.
|
// A map with formatter materials (lowercase and without dashes) for fast access.
|
||||||
private static Map<String, Material> materialMap = new HashMap<String, Material>();
|
private static Map<String, Material> materialMap = new HashMap<String, Material>();
|
||||||
private static Pattern stripSymbolsPattern = Pattern.compile("_- ");
|
private static Pattern stripSymbolsPattern = Pattern.compile("[_ \\-]+");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (Material mat : Material.values()) {
|
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) {
|
public static Material matchMaterial(String input) {
|
||||||
return materialMap.get(stripSymbolsPattern.matcher(input.toLowerCase()).replaceAll(""));
|
return materialMap.get(stripSpacingChars(input).toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
Loading…
Reference in New Issue
Block a user