Items
NovaItem
represents an item type. It is similar to Material
in Bukkit, except that it is only for items.
Getting a NovaItem
by name
To get a NovaItem
you first have to get the NovaItemRegistry
using the previously retrieved Nova instance.
Using this registry, you can now get a NovaItem
by id. It needs to be in the format namespace:name
.
- This will throw an exception if the item is not found. However, wrench always exists.
If you're unsure or processing user input usegetOrNull
instead.
Info
The same methods also exist for getting a NovaItem
from an ItemStack
.
If you want to retrieve all items with a certain name and ignore the namespace, you can do this:
Getting the id of an item
Example for nova:wrench
:
Getting the translated name of an item
Nova uses the resource pack to translate items client side. However, if you still need to get the translated name of an item,
you can use NovaItem.getLocalizedName(locale)
. The locale is the language code of the language you want to get the name in.
The code is the same as the language code used by Minecraft.
Info
If the given language code could not be found or is invalid, the english name of the item will be returned.
Example for nova:wrench
: