Package org.bukkit.inventory.meta

# Interface ItemMeta

All Superinterfaces:
  `Cloneable`, `ConfigurationSerializable`, `PersistentDataHolder`

All Known Subinterfaces:
  `ArmorStandMeta`, `AxolotlBucketMeta`, `BannerMeta`, `BlockDataMeta`, `BlockStateMeta`, `BookMeta`, `BundleMeta`, `CompassMeta`, `CrossbowMeta`, `Damageable`, `EnchantmentStorageMeta`, `FireworkEffectMeta`, `FireworkMeta`, `KnowledgeBookMeta`, `LeatherArmorMeta`, `MapMeta`, `PotionMeta`, `SkullMeta`, `SpawnEggMeta`, `SuspiciousStewMeta`, `TropicalFishBucketMeta`

public interface ItemMeta extends Cloneable, ConfigurationSerializable, PersistentDataHolder
This type represents the storage mechanism for auxiliary item data.

An implementation will handle the creation and application for ItemMeta. This class should not be implemented by a plugin in a live environment.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`addAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier)`
Add an Attribute and it's Modifier.
`boolean`
`addEnchant(@NotNull Enchantment ench, int level, boolean ignoreLevelRestriction)`
Adds the specified enchantment to this item meta.
`void`
`addItemFlags(@NotNull ItemFlag... itemFlags)`
Set itemflags which should be ignored when rendering a ItemStack in the Client.
`@NotNull ItemMeta`
`clone()`
`Component`
`displayName()`
Gets the display name.
`void`
`displayName(Component displayName)`
Sets the display name.
`@Nullable Multimap<Attribute,AttributeModifier>`
`getAttributeModifiers()`
Return an immutable copy of all Attributes and their modifiers in this ItemMeta.
Returns null if none exist.
`@Nullable Collection<AttributeModifier>`
`getAttributeModifiers(@NotNull Attribute attribute)`
Return an immutable copy of all `AttributeModifier`s for a given `Attribute`
`@NotNull Multimap<Attribute,AttributeModifier>`
`getAttributeModifiers(@NotNull EquipmentSlot slot)`
Return an immutable copy of all `Attribute`s and their `AttributeModifier`s for a given `EquipmentSlot`.
Any `AttributeModifier` that does have have a given `EquipmentSlot` will be returned.
`Set<Material>`
`getCanDestroy()`
Deprecated.
Minecraft does not limit this to the material enum, Use `getDestroyableKeys()` as a replacement
`Set<Material>`
`getCanPlaceOn()`
Deprecated.
Minecraft does not limit this to the material enum, Use `getPlaceableKeys()` as a replacement
`int`
`getCustomModelData()`
Gets the custom model data that is set.
`@NotNull CustomItemTagContainer`
`getCustomTagContainer()`
Deprecated.
this API part has been replaced by the `PersistentDataHolder` API.
`@NotNull Set<Namespaced>`
`getDestroyableKeys()`
Gets the collection of namespaced keys that the item can destroy in `GameMode.ADVENTURE`
`@NotNull String`
`getDisplayName()`
Deprecated.
in favour of `displayName()`
`@NotNull BaseComponent[]`
`getDisplayNameComponent()`
Deprecated.
use `displayName()`
`int`
`getEnchantLevel(@NotNull Enchantment ench)`
Checks for the level of the specified enchantment.
`@NotNull Map<Enchantment,Integer>`
`getEnchants()`
Returns a copy the enchantments in this ItemMeta.
`@NotNull Set<ItemFlag>`
`getItemFlags()`
Get current set itemFlags.
`@NotNull String`
`getLocalizedName()`
Gets the localized display name that is set.
`@Nullable List<String>`
`getLore()`
Deprecated.
in favour of `lore()`
`@Nullable List<BaseComponent[]>`
`getLoreComponents()`
Deprecated.
use `lore()`
`@NotNull Set<Namespaced>`
`getPlaceableKeys()`
Gets the collection of namespaced keys that the item can be placed on in `GameMode.ADVENTURE`
`boolean`
`hasAttributeModifiers()`
Checks for the existence of any AttributeModifiers.
`boolean`
`hasConflictingEnchant(@NotNull Enchantment ench)`
Checks if the specified enchantment conflicts with any enchantments in this ItemMeta.
`boolean`
`hasCustomModelData()`
Checks for existence of custom model data.
`boolean`
`hasDestroyableKeys()`
Checks for the existence of any keys that the item can destroy
`boolean`
`hasDisplayName()`
Checks for existence of a display name.
`boolean`
`hasEnchant(@NotNull Enchantment ench)`
Checks for existence of the specified enchantment.
`boolean`
`hasEnchants()`
Checks for the existence of any enchantments.
`boolean`
`hasItemFlag(@NotNull ItemFlag flag)`
Check if the specified flag is present on this item.
`boolean`
`hasLocalizedName()`
Checks for existence of a localized name.
`boolean`
`hasLore()`
Checks for existence of lore.
`boolean`
`hasPlaceableKeys()`
Checks for the existence of any keys that the item can be placed on
`boolean`
`isUnbreakable()`
Return if the unbreakable tag is true.
`@Nullable List<Component>`
`lore()`
Gets the lore.
`void`
`lore(@Nullable List<Component> lore)`
Sets the lore.
`boolean`
`removeAttributeModifier(@NotNull Attribute attribute)`
Remove all `AttributeModifier`s associated with the given `Attribute`.
`boolean`
`removeAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier)`
Remove a specific `Attribute` and `AttributeModifier`.
`boolean`
`removeAttributeModifier(@NotNull EquipmentSlot slot)`
Remove all `Attribute`s and `AttributeModifier`s for a given `EquipmentSlot`.
If the given `EquipmentSlot` is null, this will remove all `AttributeModifier`s that do not have an EquipmentSlot set.
`boolean`
`removeEnchant(@NotNull Enchantment ench)`
Removes the specified enchantment from this item meta.
`void`
`removeItemFlags(@NotNull ItemFlag... itemFlags)`
Remove specific set of itemFlags.
`void`
`setAttributeModifiers(@Nullable Multimap<Attribute,AttributeModifier> attributeModifiers)`
Set all `Attribute`s and their `AttributeModifier`s.
`void`
`setCanDestroy(Set<Material> canDestroy)`
Deprecated.
Minecraft does not limit this to the material enum, Use `setDestroyableKeys(Collection)` as a replacement
`void`
`setCanPlaceOn(Set<Material> canPlaceOn)`
Deprecated.
Minecraft does not limit this to the material enum, Use `setPlaceableKeys(Collection)` as a replacement
`void`
`setCustomModelData(@Nullable Integer data)`
Sets the custom model data.
`void`
`setDestroyableKeys(@NotNull Collection<Namespaced> canDestroy)`
Sets the collection of namespaced keys that the item can destroy in `GameMode.ADVENTURE`
`void`
`setDisplayName(@Nullable String name)`
Deprecated.
in favour of `displayName(net.kyori.adventure.text.Component)`
`void`
`setDisplayNameComponent(@Nullable BaseComponent[] component)`
Deprecated.
use `displayName(Component)`
`void`
`setLocalizedName(@Nullable String name)`
Sets the localized name.
`void`
`setLore(@Nullable List<String> lore)`
Deprecated.
in favour of `lore(List)`
`void`
`setLoreComponents(@Nullable List<BaseComponent[]> lore)`
Deprecated.
use `lore(List)`
`void`
`setPlaceableKeys(@NotNull Collection<Namespaced> canPlaceOn)`
Sets the set of namespaced keys that the item can be placed on in `GameMode.ADVENTURE`
`void`
`setUnbreakable(boolean unbreakable)`
Sets the unbreakable tag.
`void`
`setVersion(int version)`
Deprecated.
internal use only

### Methods inherited from interface org.bukkit.configuration.serialization.ConfigurationSerializable

`serialize`

### Methods inherited from interface org.bukkit.persistence.PersistentDataHolder

`getPersistentDataContainer`

## Method Details

### hasDisplayName

boolean hasDisplayName()
Checks for existence of a display name.

Returns:
  true if this has a display name

### displayName

@Nullable Component displayName()
Gets the display name.

Plugins should check that `hasDisplayName()` returns `true` before calling this method.

Returns:
  the display name

### displayName

void displayName(@Nullable Component displayName)
Sets the display name.

Parameters:
  `displayName` - the display name to set

### getDisplayName

@Deprecated @NotNull @NotNull String getDisplayName()
Deprecated.
in favour of `displayName()`
Gets the display name that is set.

Plugins should check that hasDisplayName() returns `true` before calling this method.

Returns:
  the display name that is set

### getDisplayNameComponent

@NotNull @Deprecated @NotNull BaseComponent[] getDisplayNameComponent()
Deprecated.
use `displayName()`
Gets the display name that is set.

Plugins should check that hasDisplayName() returns `true` before calling this method.

Returns:
  the display name that is set

### setDisplayName

@Deprecated void setDisplayName(@Nullable @Nullable String name)
Deprecated.
in favour of `displayName(net.kyori.adventure.text.Component)`
Sets the display name.

Parameters:
  `name` - the name to set

### setDisplayNameComponent

@Deprecated void setDisplayNameComponent(@Nullable @Nullable BaseComponent[] component)
Deprecated.
use `displayName(Component)`
Sets the display name.

Parameters:
  `component` - the name component to set

### hasLocalizedName

boolean hasLocalizedName()
Checks for existence of a localized name.

Returns:
  true if this has a localized name

### getLocalizedName

@NotNull @NotNull String getLocalizedName()
Gets the localized display name that is set.

Plugins should check that hasLocalizedName() returns `true` before calling this method.

Returns:
  the localized name that is set

### setLocalizedName

void setLocalizedName(@Nullable @Nullable String name)
Sets the localized name.

Parameters:
  `name` - the name to set

### hasLore

boolean hasLore()
Checks for existence of lore.

Returns:
  true if this has lore

### lore

@Nullable @Nullable List<Component> lore()
Gets the lore.

Plugins should check that `hasLore()` returns `true` before calling this method.

Returns:
  the display name

### lore

void lore(@Nullable @Nullable List<Component> lore)
Sets the lore.

Parameters:
  `lore` - the lore to set

### getLore

@Deprecated @Nullable @Nullable List<String> getLore()
Deprecated.
in favour of `lore()`
Gets the lore that is set.

Plugins should check if hasLore() returns `true` before calling this method.

Returns:
  a list of lore that is set

### getLoreComponents

@Nullable @Deprecated @Nullable List<BaseComponent[]> getLoreComponents()
Deprecated.
use `lore()`
Gets the lore that is set.

Plugins should check if hasLore() returns `true` before calling this method.

Returns:
  a list of lore that is set

### setLore

@Deprecated void setLore(@Nullable @Nullable List<String> lore)
Deprecated.
in favour of `lore(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<BaseComponent[]> lore)
Deprecated.
use `lore(List)`
Sets the lore for this item. Removes lore when given null.

Parameters:
  `lore` - the lore that will be set

### hasCustomModelData

boolean 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

### getCustomModelData

int 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 `true` before calling this method.

Returns:
  the localized name that is set

### setCustomModelData

void setCustomModelData(@Nullable @Nullable Integer data)
Sets 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

### hasEnchants

boolean hasEnchants()
Checks for the existence of any enchantments.

Returns:
  true if an enchantment exists on this meta

### hasEnchant

boolean hasEnchant(@NotNull @NotNull Enchantment ench)
Checks for existence of the specified enchantment.

Parameters:
  `ench` - enchantment to check
Returns:
  true if this enchantment exists for this meta

### getEnchantLevel

int getEnchantLevel(@NotNull @NotNull Enchantment ench)
Checks for the level of the specified enchantment.

Parameters:
  `ench` - enchantment to check
Returns:
  The level that the specified enchantment has, or 0 if none

### getEnchants

@NotNull @NotNull Map<Enchantment,Integer> getEnchants()
Returns a copy the enchantments in this ItemMeta.
Returns an empty map if none.

Returns:
  An immutable copy of the enchantments

### addEnchant

boolean addEnchant(@NotNull @NotNull Enchantment ench, int level, boolean ignoreLevelRestriction)
Adds 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

### removeEnchant

boolean removeEnchant(@NotNull @NotNull Enchantment ench)
Removes 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

### hasConflictingEnchant

boolean hasConflictingEnchant(@NotNull @NotNull Enchantment ench)
Checks if the specified enchantment conflicts with any enchantments in this ItemMeta.

Parameters:
  `ench` - enchantment to test
Returns:
  true if the enchantment conflicts, false otherwise

### addItemFlags

void addItemFlags(@NotNull @NotNull ItemFlag... itemFlags)
Set 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

### removeItemFlags

void removeItemFlags(@NotNull @NotNull ItemFlag... itemFlags)
Remove 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

### getItemFlags

@NotNull @NotNull Set<ItemFlag> getItemFlags()
Get current set itemFlags. The collection returned is unmodifiable.

Returns:
  A set of all itemFlags set

### hasItemFlag

boolean hasItemFlag(@NotNull @NotNull ItemFlag flag)
Check if the specified flag is present on this item.

Parameters:
  `flag` - the flag to check
Returns:
  if it is present

### isUnbreakable

boolean isUnbreakable()
Return if the unbreakable tag is true. An unbreakable item will not lose durability.

Returns:
  true if the unbreakable tag is true

### setUnbreakable

void setUnbreakable(boolean unbreakable)
Sets the unbreakable tag. An unbreakable item will not lose durability.

Parameters:
  `unbreakable` - true if set unbreakable

### hasAttributeModifiers

boolean hasAttributeModifiers()
Checks for the existence of any AttributeModifiers.

Returns:
  true if any AttributeModifiers exist

### getAttributeModifiers

@Nullable @Nullable Multimap<Attribute,AttributeModifier> getAttributeModifiers()
Return an immutable copy of all Attributes and their modifiers in this ItemMeta.
Returns null if none exist.

Returns:
  an immutable `Multimap` of 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 all `Attribute`s and their `AttributeModifier`s for a given `EquipmentSlot`.
Any `AttributeModifier` that does have have a given `EquipmentSlot` will 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 `EquipmentSlot` to check
Returns:
  the immutable `Multimap` with 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 all `AttributeModifier`s for a given `Attribute`

Parameters:
  `attribute` - the `Attribute`
Returns:
  an immutable collection of `AttributeModifier`s or null if no AttributeModifiers exist for the Attribute.
Throws:
  `NullPointerException` - if Attribute is null

### addAttributeModifier

boolean addAttributeModifier(@NotNull @NotNull Attribute attribute, @NotNull @NotNull AttributeModifier modifier)
Add an Attribute and it's Modifier. AttributeModifiers can now support `EquipmentSlot`s. If not set, the `AttributeModifier` will be active in ALL slots.
Two `AttributeModifier`s that have the same `UUID` cannot exist on the same Attribute.

Parameters:
  `attribute` - the `Attribute` to modify
  `modifier` - the `AttributeModifier` specifying 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

### setAttributeModifiers

void setAttributeModifiers(@Nullable @Nullable Multimap<Attribute,AttributeModifier> attributeModifiers)
Set all `Attribute`s and their `AttributeModifier`s. 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

### removeAttributeModifier

boolean removeAttributeModifier(@NotNull @NotNull Attribute attribute)
Remove all `AttributeModifier`s associated with the given `Attribute`. 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

### removeAttributeModifier

boolean removeAttributeModifier(@NotNull @NotNull EquipmentSlot slot)
Remove all `Attribute`s and `AttributeModifier`s for a given `EquipmentSlot`.
If the given `EquipmentSlot` is null, this will remove all `AttributeModifier`s that do not have an EquipmentSlot set.

Parameters:
  `slot` - the `EquipmentSlot` to clear all Attributes and their modifiers for
Returns:
  true if all modifiers were removed that match the given EquipmentSlot.

### removeAttributeModifier

boolean removeAttributeModifier(@NotNull @NotNull Attribute attribute, @NotNull @NotNull AttributeModifier modifier)
Remove a specific `Attribute` and `AttributeModifier`. AttributeModifiers are matched according to their `UUID`.

Parameters:
  `attribute` - the `Attribute` to remove
  `modifier` - the `AttributeModifier` to remove
Returns:
  if any attribute modifiers were remove
Throws:
  `NullPointerException` - if the Attribute is null
  `NullPointerException` - if the AttributeModifier is null
See Also:
  - `AttributeModifier.getUniqueId()`

### getCustomTagContainer

@NotNull @Deprecated @NotNull CustomItemTagContainer getCustomTagContainer()
Deprecated.
this API part has been replaced by the `PersistentDataHolder` API. Please use `PersistentDataHolder.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

### setVersion

@Deprecated void setVersion(int version)
Deprecated.
internal use only
Internal use only! Do not use under any circumstances!

Parameters:
  `version` - version

### clone

@NotNull @NotNull ItemMeta clone()

### getCanDestroy

@Deprecated Set<Material> getCanDestroy()
Deprecated.
Minecraft does not limit this to the material enum, Use `getDestroyableKeys()` as a replacement
Gets set of materials what given item can destroy in `GameMode.ADVENTURE`

Returns:
  Set of materials

### setCanDestroy

@Deprecated void setCanDestroy(Set<Material> canDestroy)
Deprecated.
Minecraft does not limit this to the material enum, Use `setDestroyableKeys(Collection)` as a replacement
Sets set of materials what given item can destroy in `GameMode.ADVENTURE`

Parameters:
  `canDestroy` - Set of materials

### getCanPlaceOn

@Deprecated Set<Material> getCanPlaceOn()
Deprecated.
Minecraft does not limit this to the material enum, Use `getPlaceableKeys()` as a replacement
Gets set of materials where given item can be placed on in `GameMode.ADVENTURE`

Returns:
  Set of materials

### setCanPlaceOn

@Deprecated void setCanPlaceOn(Set<Material> canPlaceOn)
Deprecated.
Minecraft does not limit this to the material enum, Use `setPlaceableKeys(Collection)` as a replacement
Sets set of materials where given item can be placed on in `GameMode.ADVENTURE`

Parameters:
  `canPlaceOn` - Set of materials

### getDestroyableKeys

@NotNull @NotNull Set<Namespaced> getDestroyableKeys()
Gets the collection of namespaced keys that the item can destroy in `GameMode.ADVENTURE`

Returns:
  Set of `Namespaced`

### setDestroyableKeys

void setDestroyableKeys(@NotNull @NotNull Collection<Namespaced> canDestroy)
Sets the collection of namespaced keys that the item can destroy in `GameMode.ADVENTURE`

Parameters:
  `canDestroy` - Collection of `Namespaced`

### getPlaceableKeys

@NotNull @NotNull Set<Namespaced> getPlaceableKeys()
Gets the collection of namespaced keys that the item can be placed on in `GameMode.ADVENTURE`

Returns:
  Set of `Namespaced`

### setPlaceableKeys

@NotNull void setPlaceableKeys(@NotNull @NotNull Collection<Namespaced> canPlaceOn)
Sets the set of namespaced keys that the item can be placed on in `GameMode.ADVENTURE`

Parameters:
  `canPlaceOn` - Collection of `Namespaced`

### hasPlaceableKeys

boolean hasPlaceableKeys()
Checks for the existence of any keys that the item can be placed on

Returns:
  true if this item has placeable keys

### hasDestroyableKeys

boolean hasDestroyableKeys()
Checks for the existence of any keys that the item can destroy

Returns:
  true if this item has destroyable keys