Package valorless.valorlessutils.items
Class ItemUtils
java.lang.Object
valorless.valorlessutils.items.ItemUtils
Utility class for interacting with 
ItemMeta fields introduced in Minecraft 1.20.5+.
 These helper methods allow for easy access to new item metadata, such as:
- Item name (internal vs. display name)
- Item rarity
- Custom max stack size
- Item model (resource key)
Note: These methods rely on APIs only available in 1.20.5 and above. Always check the server version before calling these methods to avoid errors on older servers.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic StringGetCustomName(org.bukkit.inventory.ItemStack item) Gets the custom display name.static org.bukkit.NamespacedKeyGetItemModel(org.bukkit.inventory.ItemStack item) Gets the namespaced key of the item's model.static StringGetItemName(org.bukkit.inventory.ItemStack item) Gets the internal item name.static IntegerGetMaxStackSize(org.bukkit.inventory.ItemStack item) Gets the maximum stack size defined on the item.static StringGetRarity(org.bukkit.inventory.ItemStack item) Gets the rarity of the item as a string.static BooleanHasCustomName(org.bukkit.inventory.ItemStack item) Checks if the item has a custom display name.static BooleanHasItemName(org.bukkit.inventory.ItemStack item) Checks if the item has an internal item name.static BooleanHasMaxStackSize(org.bukkit.inventory.ItemStack item) Checks if the item has a custom max stack size.static BooleanHasRarity(org.bukkit.inventory.ItemStack item) Checks if the item has a rarity value.static voidSetCustomName(org.bukkit.inventory.ItemStack item, String name) Sets the custom display name.static voidSetItemModel(org.bukkit.inventory.ItemStack item, String value) Sets the item model using a string in the format "namespace:key".static voidSetItemModel(org.bukkit.inventory.ItemStack item, org.bukkit.NamespacedKey value) Sets the item model using aNamespacedKey.static voidSetItemName(org.bukkit.inventory.ItemStack item, String name) Sets the internal item name.static voidSetMaxStackSize(org.bukkit.inventory.ItemStack item, Integer value) Sets a custom maximum stack size for the item.static voidSets the rarity of the item.
- 
Constructor Details- 
ItemUtilspublic ItemUtils()
 
- 
- 
Method Details- 
HasItemNameChecks if the item has an internal item name.- Parameters:
- item- The- ItemStackto check
- Returns:
- True if the item has an internal name, false otherwise
 
- 
GetItemNameGets the internal item name.- Parameters:
- item- The- ItemStackto get the name from
- Returns:
- The item name string
 
- 
SetItemNameSets the internal item name.- Parameters:
- item- The- ItemStackto modify
- name- The name to set
 
- 
HasCustomNameChecks if the item has a custom display name.- Parameters:
- item- The- ItemStackto check
- Returns:
- True if the item has a display name, false otherwise
 
- 
GetCustomNameGets the custom display name.- Parameters:
- item- The- ItemStackto get the display name from
- Returns:
- The display name string
 
- 
SetCustomNameSets the custom display name.- Parameters:
- item- The- ItemStackto modify
- name- The display name to set
 
- 
HasRarityChecks if the item has a rarity value.- Parameters:
- item- The- ItemStackto check
- Returns:
- True if the item has a rarity, false otherwise
 
- 
GetRarityGets the rarity of the item as a string.- Parameters:
- item- The- ItemStackto get rarity from
- Returns:
- The rarity as a string (e.g., "COMMON", "RARE", "EPIC")
 
- 
SetRaritySets the rarity of the item.- Parameters:
- item- The- ItemStackto modify
- rarity- The rarity as a string (must match- ItemRarityname)
 
- 
HasMaxStackSizeChecks if the item has a custom max stack size.- Parameters:
- item- The- ItemStackto check
- Returns:
- True if a custom max stack size is set, false otherwise
 
- 
GetMaxStackSizeGets the maximum stack size defined on the item.- Parameters:
- item- The- ItemStackto get the value from
- Returns:
- The maximum stack size
 
- 
SetMaxStackSizeSets a custom maximum stack size for the item.- Parameters:
- item- The- ItemStackto modify
- value- The maximum stack size value
 
- 
GetItemModelpublic static org.bukkit.NamespacedKey GetItemModel(org.bukkit.inventory.ItemStack item) Gets the namespaced key of the item's model.- Parameters:
- item- The- ItemStackto query
- Returns:
- The NamespacedKeyrepresenting the item model
 
- 
SetItemModelpublic static void SetItemModel(org.bukkit.inventory.ItemStack item, org.bukkit.NamespacedKey value) Sets the item model using aNamespacedKey.- Parameters:
- item- The- ItemStackto modify
- value- The- NamespacedKeyof the model
 
- 
SetItemModelSets the item model using a string in the format "namespace:key".- Parameters:
- item- The- ItemStackto modify
- value- The string representing the model key
 
 
-