Interface ItemMeta
- All Superinterfaces:
- Cloneable,- ConfigurationSerializable,- PersistentDataHolder
- All Known Subinterfaces:
- ArmorMeta,- ArmorStandMeta,- AxolotlBucketMeta,- BannerMeta,- BlockDataMeta,- BlockStateMeta,- BookMeta,- BundleMeta,- ColorableArmorMeta,- CompassMeta,- CrossbowMeta,- Damageable,- EnchantmentStorageMeta,- FireworkEffectMeta,- FireworkMeta,- KnowledgeBookMeta,- LeatherArmorMeta,- MapMeta,- MusicInstrumentMeta,- PotionMeta,- Repairable,- SkullMeta,- SpawnEggMeta,- SuspiciousStewMeta,- TropicalFishBucketMeta
An implementation will handle the creation and application for ItemMeta. This class should not be implemented by a plugin in a live environment.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanaddAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier) Add an Attribute and it's Modifier.booleanaddEnchant(@NotNull Enchantment ench, int level, boolean ignoreLevelRestriction) Adds the specified enchantment to this item meta.voidaddItemFlags(@NotNull ItemFlag... itemFlags) Set itemflags which should be ignored when rendering a ItemStack in the Client.clone()Gets the display name.voiddisplayName(@Nullable Component displayName) Sets the display name.Get this ItemMeta as an NBT string.Return an immutable copy of all Attributes and their modifiers in this ItemMeta.
 Returns null if none exist.getAttributeModifiers(@NotNull Attribute attribute) Return an immutable copy of allAttributeModifiers for a givenAttributeReturn an immutable copy of allAttributes and theirAttributeModifiers for a givenEquipmentSlot.
 AnyAttributeModifierthat does have a givenEquipmentSlotwill be returned.Deprecated.Deprecated.Minecraft does not limit this to the material enum, UsegetPlaceableKeys()as a replacementintGets the custom model data that is set.Deprecated.this API part has been replaced by thePersistentDataHolderAPI.Gets the collection of namespaced keys that the item can destroy inGameMode.ADVENTUREDeprecated.in favour ofdisplayName()@NotNull net.md_5.bungee.api.chat.BaseComponent[]Deprecated.usedisplayName()intChecks for the level of the specified enchantment.Returns a copy the enchantments in this ItemMeta.Get current set itemFlags.Deprecated.UsedisplayName()and cast it to aTranslatableComponent.getLore()Deprecated.in favour oflore()Deprecated.uselore()Gets the collection of namespaced keys that the item can be placed on inGameMode.ADVENTUREbooleanChecks for the existence of any AttributeModifiers.booleanChecks if the specified enchantment conflicts with any enchantments in this ItemMeta.booleanChecks for existence of custom model data.booleanChecks for the existence of any keys that the item can destroybooleanChecks for existence of a display name.booleanhasEnchant(@NotNull Enchantment ench) Checks for existence of the specified enchantment.booleanChecks for the existence of any enchantments.booleanhasItemFlag(@NotNull ItemFlag flag) Check if the specified flag is present on this item.booleanDeprecated.UsedisplayName()and check if it is instanceof aTranslatableComponent.booleanhasLore()Checks for existence of lore.booleanChecks for the existence of any keys that the item can be placed onbooleanReturn if the unbreakable tag is true.lore()Gets the lore.voidSets the lore.booleanremoveAttributeModifier(@NotNull Attribute attribute) Remove allAttributeModifiers associated with the givenAttribute.booleanremoveAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier) Remove a specificAttributeandAttributeModifier.booleanRemove allAttributes andAttributeModifiers for a givenEquipmentSlot.
 If the givenEquipmentSlotis null, this will remove allAttributeModifiers that do not have an EquipmentSlot set.booleanremoveEnchant(@NotNull Enchantment ench) Removes the specified enchantment from this item meta.voidremoveItemFlags(@NotNull ItemFlag... itemFlags) Remove specific set of itemFlags.voidsetAttributeModifiers(@Nullable Multimap<Attribute, AttributeModifier> attributeModifiers) Set allAttributes and theirAttributeModifiers.voidsetCanDestroy(Set<Material> canDestroy) Deprecated.Minecraft does not limit this to the material enum, UsesetDestroyableKeys(Collection)as a replacementvoidsetCanPlaceOn(Set<Material> canPlaceOn) Deprecated.Minecraft does not limit this to the material enum, UsesetPlaceableKeys(Collection)as a replacementvoidSets the custom model data.voidsetDestroyableKeys(@NotNull Collection<Namespaced> canDestroy) Sets the collection of namespaced keys that the item can destroy inGameMode.ADVENTUREvoidsetDisplayName(@Nullable String name) Deprecated.in favour ofdisplayName(net.kyori.adventure.text.Component)voidsetDisplayNameComponent(@Nullable net.md_5.bungee.api.chat.BaseComponent[] component) Deprecated.voidsetLocalizedName(@Nullable String name) Deprecated.UsedisplayName(Component)with aTranslatableComponent.voidDeprecated.in favour oflore(List)voidsetLoreComponents(@Nullable List<net.md_5.bungee.api.chat.BaseComponent[]> lore) Deprecated.uselore(List)voidsetPlaceableKeys(@NotNull Collection<Namespaced> canPlaceOn) Sets the set of namespaced keys that the item can be placed on inGameMode.ADVENTUREvoidsetUnbreakable(boolean unbreakable) Sets the unbreakable tag.voidsetVersion(int version) Internal use only! Do not use under any circumstances!Methods inherited from interface org.bukkit.configuration.serialization.ConfigurationSerializableserializeMethods inherited from interface org.bukkit.persistence.PersistentDataHoldergetPersistentDataContainer
- 
Method Details- 
hasDisplayNameboolean hasDisplayName()Checks for existence of a display name.- Returns:
- true if this has a display name
 
- 
displayNameGets the display name.Plugins should check that hasDisplayName()returnstruebefore calling this method.- Returns:
- the display name
 
- 
displayNameSets the display name.- Parameters:
- displayName- the display name to set
 
- 
getDisplayNameDeprecated.in favour ofdisplayName()Gets the display name that is set.Plugins should check that hasDisplayName() returns truebefore calling this method.- Returns:
- the display name that is set
 
- 
getDisplayNameComponentDeprecated.usedisplayName()Gets the display name that is set.Plugins should check that hasDisplayName() returns truebefore calling this method.- Returns:
- the display name that is set
 
- 
setDisplayNameDeprecated.in favour ofdisplayName(net.kyori.adventure.text.Component)Sets the display name.- Parameters:
- name- the name to set
 
- 
setDisplayNameComponent@Deprecated void setDisplayNameComponent(@Nullable @Nullable net.md_5.bungee.api.chat.BaseComponent[] component) Deprecated.Sets the display name.- Parameters:
- component- the name component to set
 
- 
hasLocalizedNameDeprecated.UsedisplayName()and check if it is instanceof aTranslatableComponent.Checks for existence of a localized name.- Returns:
- true if this has a localized name
 
- 
getLocalizedNameDeprecated.UsedisplayName()and cast it to aTranslatableComponent. No longer used by the client.Gets the localized display name that is set.Plugins should check that hasLocalizedName() returns truebefore calling this method.- Returns:
- the localized name that is set
 
- 
setLocalizedNameDeprecated.UsedisplayName(Component)with aTranslatableComponent. No longer used by the client.Sets the localized name.- Parameters:
- name- the name to set
 
- 
hasLoreboolean hasLore()Checks for existence of lore.- Returns:
- true if this has lore
 
- 
loreGets the lore.Plugins should check that hasLore()returnstruebefore calling this method.- Returns:
- the lore
 
- 
loreSets the lore.- Parameters:
- lore- the lore to set
 
- 
getLoreDeprecated.in favour oflore()Gets the lore that is set.Plugins should check if hasLore() returns truebefore calling this method.- Returns:
- a list of lore that is set
 
- 
getLoreComponentsDeprecated.uselore()Gets the lore that is set.Plugins should check if hasLore() returns truebefore calling this method.- Returns:
- a list of lore that is set
 
- 
setLoreDeprecated.in favour oflore(List)Sets the lore for this item. Removes lore when given null.- Parameters:
- lore- the lore that will be set
 
- 
setLoreComponents@Deprecated void setLoreComponents(@Nullable @Nullable List<net.md_5.bungee.api.chat.BaseComponent[]> lore) Deprecated.uselore(List)Sets the lore for this item. Removes lore when given null.- Parameters:
- lore- the lore that will be set
 
- 
hasCustomModelDataboolean hasCustomModelData()Checks for existence of custom model data.CustomModelData is an integer that may be associated client side with a custom item model. - Returns:
- true if this has custom model data
 
- 
getCustomModelDataint getCustomModelData()Gets the custom model data that is set.CustomModelData is an integer that may be associated client side with a custom item model. Plugins should check that hasCustomModelData() returns truebefore calling this method.- Returns:
- the custom model data that is set
 
- 
setCustomModelDataSets the custom model data.CustomModelData is an integer that may be associated client side with a custom item model. - Parameters:
- data- the data to set, or null to clear
 
- 
hasEnchantsboolean hasEnchants()Checks for the existence of any enchantments.- Returns:
- true if an enchantment exists on this meta
 
- 
hasEnchantChecks for existence of the specified enchantment.- Parameters:
- ench- enchantment to check
- Returns:
- true if this enchantment exists for this meta
 
- 
getEnchantLevelChecks for the level of the specified enchantment.- Parameters:
- ench- enchantment to check
- Returns:
- The level that the specified enchantment has, or 0 if none
 
- 
getEnchantsReturns a copy the enchantments in this ItemMeta.
 Returns an empty map if none.- Returns:
- An immutable copy of the enchantments
 
- 
addEnchantAdds the specified enchantment to this item meta.- Parameters:
- ench- Enchantment to add
- level- Level for the enchantment
- ignoreLevelRestriction- this indicates the enchantment should be applied, ignoring the level limit
- Returns:
- true if the item meta changed as a result of this call, false otherwise
 
- 
removeEnchantRemoves the specified enchantment from this item meta.- Parameters:
- ench- Enchantment to remove
- Returns:
- true if the item meta changed as a result of this call, false otherwise
 
- 
hasConflictingEnchantChecks if the specified enchantment conflicts with any enchantments in this ItemMeta.- Parameters:
- ench- enchantment to test
- Returns:
- true if the enchantment conflicts, false otherwise
 
- 
addItemFlagsSet itemflags which should be ignored when rendering a ItemStack in the Client. This Method does silently ignore double set itemFlags.- Parameters:
- itemFlags- The hideflags which shouldn't be rendered
 
- 
removeItemFlagsRemove specific set of itemFlags. This tells the Client it should render it again. This Method does silently ignore double removed itemFlags.- Parameters:
- itemFlags- Hideflags which should be removed
 
- 
getItemFlagsGet current set itemFlags. The collection returned is unmodifiable.- Returns:
- A set of all itemFlags set
 
- 
hasItemFlagCheck if the specified flag is present on this item.- Parameters:
- flag- the flag to check
- Returns:
- if it is present
 
- 
isUnbreakableboolean isUnbreakable()Return if the unbreakable tag is true. An unbreakable item will not lose durability.- Returns:
- true if the unbreakable tag is true
 
- 
setUnbreakablevoid setUnbreakable(boolean unbreakable) Sets the unbreakable tag. An unbreakable item will not lose durability.- Parameters:
- unbreakable- true if set unbreakable
 
- 
hasAttributeModifiersboolean hasAttributeModifiers()Checks for the existence of any AttributeModifiers.- Returns:
- true if any AttributeModifiers exist
 
- 
getAttributeModifiersReturn an immutable copy of all Attributes and their modifiers in this ItemMeta.
 Returns null if none exist.- Returns:
- an immutable Multimapof Attributes and their AttributeModifiers, or null if none exist
 
- 
getAttributeModifiers@NotNull @NotNull Multimap<Attribute,AttributeModifier> getAttributeModifiers(@NotNull @NotNull EquipmentSlot slot) Return an immutable copy of allAttributes and theirAttributeModifiers for a givenEquipmentSlot.
 AnyAttributeModifierthat does have a givenEquipmentSlotwill be returned. This is because AttributeModifiers without a slot are active in any slot.
 If there are no attributes set for the given slot, an empty map will be returned.- Parameters:
- slot- the- EquipmentSlotto check
- Returns:
- the immutable Multimapwith the respective Attributes and modifiers, or an empty map if no attributes are set.
 
- 
getAttributeModifiers@Nullable @Nullable Collection<AttributeModifier> getAttributeModifiers(@NotNull @NotNull Attribute attribute) Return an immutable copy of allAttributeModifiers for a givenAttribute- Parameters:
- attribute- the- Attribute
- Returns:
- an immutable collection of AttributeModifiers or null if no AttributeModifiers exist for the Attribute.
- Throws:
- NullPointerException- if Attribute is null
 
- 
addAttributeModifierboolean addAttributeModifier(@NotNull @NotNull Attribute attribute, @NotNull @NotNull AttributeModifier modifier) Add an Attribute and it's Modifier. AttributeModifiers can now supportEquipmentSlots. If not set, theAttributeModifierwill be active in ALL slots.
 TwoAttributeModifiers that have the sameUUIDcannot exist on the same Attribute.- Parameters:
- attribute- the- Attributeto modify
- modifier- the- AttributeModifierspecifying the modification
- Returns:
- true if the Attribute and AttributeModifier were successfully added
- Throws:
- NullPointerException- if Attribute is null
- NullPointerException- if AttributeModifier is null
- IllegalArgumentException- if AttributeModifier already exists
 
- 
setAttributeModifiersvoid setAttributeModifiers(@Nullable @Nullable Multimap<Attribute, AttributeModifier> attributeModifiers) Set allAttributes and theirAttributeModifiers. To clear all currently set Attributes and AttributeModifiers use null or an empty Multimap. If not null nor empty, this will filter all entries that are not-null and add them to the ItemStack.- Parameters:
- attributeModifiers- the new Multimap containing the Attributes and their AttributeModifiers
 
- 
removeAttributeModifierRemove allAttributeModifiers associated with the givenAttribute. This will return false if nothing was removed.- Parameters:
- attribute- attribute to remove
- Returns:
- true if all modifiers were removed from a given Attribute. Returns false if no attributes were removed.
- Throws:
- NullPointerException- if Attribute is null
 
- 
removeAttributeModifierRemove allAttributes andAttributeModifiers for a givenEquipmentSlot.
 If the givenEquipmentSlotis null, this will remove allAttributeModifiers that do not have an EquipmentSlot set.- Parameters:
- slot- the- EquipmentSlotto clear all Attributes and their modifiers for
- Returns:
- true if all modifiers were removed that match the given EquipmentSlot.
 
- 
removeAttributeModifierboolean removeAttributeModifier(@NotNull @NotNull Attribute attribute, @NotNull @NotNull AttributeModifier modifier) Remove a specificAttributeandAttributeModifier. AttributeModifiers are matched according to theirUUID.- Parameters:
- attribute- the- Attributeto remove
- modifier- the- AttributeModifierto remove
- Returns:
- if any attribute modifiers were remove
- Throws:
- NullPointerException- if the Attribute is null
- NullPointerException- if the AttributeModifier is null
- See Also:
 
- 
getAsStringGet this ItemMeta as an NBT string.This string should not be relied upon as a serializable value. If serialization is desired, the ConfigurationSerializableAPI should be used instead.- Returns:
- the NBT string
 
- 
getCustomTagContainerDeprecated.this API part has been replaced by thePersistentDataHolderAPI. Please usePersistentDataHolder.getPersistentDataContainer()instead of this.Returns a public custom tag container capable of storing tags on the item. Those tags will be sent to the client with all of their content, so the client is capable of reading them. This will result in the player seeing a NBT Tag notification on the item. These tags can also be modified by the client once in creative mode- Returns:
- the custom tag container
 
- 
setVersionInternal use only! Do not use under any circumstances!- Parameters:
- version- version
- API Note:
- internal use only
 
- 
clone
- 
getCanDestroyDeprecated.Minecraft does not limit this to the material enum, UsegetDestroyableKeys()as a replacementGets set of materials what given item can destroy inGameMode.ADVENTURE- Returns:
- Set of materials
 
- 
setCanDestroyDeprecated.Minecraft does not limit this to the material enum, UsesetDestroyableKeys(Collection)as a replacementSets set of materials what given item can destroy inGameMode.ADVENTURE- Parameters:
- canDestroy- Set of materials
 
- 
getCanPlaceOnDeprecated.Minecraft does not limit this to the material enum, UsegetPlaceableKeys()as a replacementGets set of materials where given item can be placed on inGameMode.ADVENTURE- Returns:
- Set of materials
 
- 
setCanPlaceOnDeprecated.Minecraft does not limit this to the material enum, UsesetPlaceableKeys(Collection)as a replacementSets set of materials where given item can be placed on inGameMode.ADVENTURE- Parameters:
- canPlaceOn- Set of materials
 
- 
getDestroyableKeysGets the collection of namespaced keys that the item can destroy inGameMode.ADVENTURE- Returns:
- Set of Namespaced
 
- 
setDestroyableKeysSets the collection of namespaced keys that the item can destroy inGameMode.ADVENTURE- Parameters:
- canDestroy- Collection of- Namespaced
 
- 
getPlaceableKeysGets the collection of namespaced keys that the item can be placed on inGameMode.ADVENTURE- Returns:
- Set of Namespaced
 
- 
setPlaceableKeysSets the set of namespaced keys that the item can be placed on inGameMode.ADVENTURE- Parameters:
- canPlaceOn- Collection of- Namespaced
 
- 
hasPlaceableKeysboolean hasPlaceableKeys()Checks for the existence of any keys that the item can be placed on- Returns:
- true if this item has placeable keys
 
- 
hasDestroyableKeysboolean hasDestroyableKeys()Checks for the existence of any keys that the item can destroy- Returns:
- true if this item has destroyable keys
 
 
- 
getDestroyableKeys()as a replacement