Hi, I am wondering if there if a built-in way of getting an item name from an ItemStack. I am currently using item.getType().getName().toLowercase().replace('_', ' '), but this is not completely accurate (by accurate, I mean compared to the bubble that pops up when you mouse over an item in your inventory.)
The way I get around this is using Code: ((CraftPlayer)p).getHandle().getLocale().b(CraftItemStack.asNMSCopy(item).a()+".name").replace('_', ' ').toLowerCase() but this only works if the plugin and the server are on the same version of craftbukkit. I'm trying to get one to work with only bukkit api but the problem is that items such as lapis will show up as ink sac because it has the same item ID and different data values. I guess one could write a big long function to check data values though.
Use... Code: String name = ""; if(item.hasItemMeta()){ name = item.getItemMeta().getDisplayName(); } else{ name = item.getType().toString(); }