utitilies: add replaceTags(), update getName()

replaceTags() is helpful for finding remapped items.
Adding a getName(Item item) and using replaceTags() in old getName(Block
block)
This commit is contained in:
EoD committed 2014-09-09 18:59:40 +02:00
1 parent ffcbf444cd
commit 480b6c3629
1 file changed
+9 -6
@@ -57,18 +57,21 @@ public class General
return stack.getItem();
}
public static String getUnlocalizedName(Block block)
public static String getName(Item item)
{
String name = block.getUnlocalizedName();
if(name.startsWith("tile.")) name = name.substring(5);
return name;
String res = item.getUnlocalizedName();
return cleanTags(res);
}
public static String getName(Block block)
{
String res = block.getUnlocalizedName();
return res.substring(5);
return cleanTags(res);
}
public static String cleanTags(String tag)
{
return tag.replaceAll("[Cc]hisel\\p{Punct}", "").replaceFirst("^tile\\.", "").replaceFirst("^item\\.", "");
}