Interface ItemMeta
- All Superinterfaces:
Cloneable
,ConfigurationSerializable
,PersistentDataHolder
,PersistentDataViewHolder
- All Known Subinterfaces:
ArmorMeta
,ArmorStandMeta
,AxolotlBucketMeta
,BannerMeta
,BlockDataMeta
,BlockStateMeta
,BookMeta
,BundleMeta
,ColorableArmorMeta
,CompassMeta
,CrossbowMeta
,Damageable
,EnchantmentStorageMeta
,FireworkEffectMeta
,FireworkMeta
,KnowledgeBookMeta
,LeatherArmorMeta
,MapMeta
,MusicInstrumentMeta
,OminousBottleMeta
,PotionMeta
,Repairable
,ShieldMeta
,SkullMeta
,SpawnEggMeta
,SuspiciousStewMeta
,TropicalFishBucketMeta
,WritableBookMeta
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 TypeMethodDescriptionboolean
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.clone()
Gets the custom name.void
customName
(@Nullable Component customName) Sets the custom name.Gets the display name.default void
displayName
(@Nullable Component displayName) Sets the display name.Get this ItemMeta as a component-compliant string.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 allAttributeModifier
s for a givenAttribute
Return an immutable copy of allAttribute
s and theirAttributeModifier
s for a givenEquipmentSlot
.
AnyAttributeModifier
that does have a givenEquipmentSlot
will be returned.Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.int
Gets the custom model data that is set.Gets the custom model data set on this item, or creates an empty custom model data instance.Deprecated.this API part has been replaced by thePersistentDataHolder
API.Gets the type of damage this item will be resistant to when in entity form.Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.Deprecated.in favour ofdisplayName()
net.md_5.bungee.api.chat.BaseComponent[]
Deprecated.usedisplayName()
int
Gets the enchantable component.int
Checks for the level of the specified enchantment.Sets the enchantment_glint_override.Returns a copy the enchantments in this ItemMeta.Gets the equippable set on this item, or creates an empty equippable instance.getFood()
Gets the food set on this item, or creates an empty food instance.Get current set itemFlags.Gets the custom item model.Deprecated.in favour ofitemName()
Gets the jukebox playable component set on this item.Deprecated, for removal: This API element is subject to removal in a future version.UsedisplayName()
and cast it to aTranslatableComponent
.getLore()
Deprecated.in favour oflore()
Deprecated.uselore()
int
Gets the max_stack_size.Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.Gets the item rarity.getTool()
Gets the tool set on this item, or creates an empty tool instance.Gets the custom tooltip style.Gets the use cooldown set on this item, or creates an empty cooldown instance.Gets the item which this item will convert to when used.boolean
Checks for the existence of any AttributeModifiers.boolean
Checks if the specified enchantment conflicts with any enchantments in this ItemMeta.boolean
Checks for existence of custom model data.boolean
Checks for existence of a custom name.boolean
Gets if this item is resistant to certain types of damage.boolean
Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaceddefault boolean
Checks for existence of a display name.boolean
hasEnchant
(@NotNull Enchantment ench) Checks for existence of the specified enchantment.boolean
Gets if the enchantable component is set.boolean
Gets if an enchantment_glint_override is set.boolean
Checks for the existence of any enchantments.boolean
Checks if the equippable is set.boolean
hasFood()
Checks if the food is set.boolean
hasItemFlag
(@NotNull ItemFlag flag) Check if the specified flag is present on this item.boolean
Gets if this item has a custom item model.boolean
Checks for existence of an item name.boolean
Checks if the jukebox playable is set.boolean
Deprecated, for removal: This API element is subject to removal in a future version.UsedisplayName()
and check if it is instanceof aTranslatableComponent
.boolean
hasLore()
Checks for existence of lore.boolean
Gets if the max_stack_size is set.boolean
Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replacedboolean
Gets if the rarity is set.boolean
hasTool()
Checks if the tool is set.boolean
Gets if this item has a custom tooltip style.boolean
Checks if the use cooldown is set.boolean
Checks if the use remainder is set.boolean
Deprecated.boolean
isGlider()
Checks if this item is a glider.boolean
Gets if this item has hide_tooltip set.boolean
Return if the unbreakable tag is true.itemName()
Gets the item name component that is set.void
Sets the item name.lore()
Gets the lore.void
Sets the lore.boolean
removeAttributeModifier
(@NotNull Attribute attribute) Remove allAttributeModifier
s associated with the givenAttribute
.boolean
removeAttributeModifier
(@NotNull Attribute attribute, @NotNull AttributeModifier modifier) Remove a specificAttribute
andAttributeModifier
.boolean
Remove allAttribute
s andAttributeModifier
s for a givenEquipmentSlot
.
If the givenEquipmentSlot
is null, this will remove allAttributeModifier
s that do not have an EquipmentSlot set.boolean
removeEnchant
(@NotNull Enchantment ench) Removes the specified enchantment from this item meta.void
Removes all enchantments from this item meta.void
removeItemFlags
(@NotNull ItemFlag... itemFlags) Remove specific set of itemFlags.void
setAttributeModifiers
(@Nullable Multimap<Attribute, AttributeModifier> attributeModifiers) Set allAttribute
s and theirAttributeModifier
s.void
setCanDestroy
(Set<Material> canDestroy) Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.void
setCanPlaceOn
(Set<Material> canPlaceOn) Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.void
Sets the custom model data.void
setCustomModelDataComponent
(@Nullable CustomModelDataComponent customModelData) Sets the custom model data component.void
Sets the type of damage this item will be resistant to when in entity form.void
setDestroyableKeys
(@NotNull Collection<Namespaced> canDestroy) Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.void
setDisplayName
(@Nullable String name) Deprecated.in favour ofdisplayName(net.kyori.adventure.text.Component)
void
setDisplayNameComponent
(net.md_5.bungee.api.chat.BaseComponent[] component) Deprecated.void
setEnchantable
(@Nullable Integer enchantable) Sets the enchantable.void
setEnchantmentGlintOverride
(@Nullable Boolean override) Sets the enchantment_glint_override.void
setEquippable
(@Nullable EquippableComponent equippable) Sets the equippable tool.void
setFireResistant
(boolean fireResistant) Deprecated.void
setFood
(@Nullable FoodComponent food) Sets the item food.void
setGlider
(boolean glider) Sets if this item is a glider.void
setHideTooltip
(boolean hideTooltip) Sets if this item has hide_tooltip set.void
setItemModel
(@Nullable NamespacedKey itemModel) Sets the custom item model.void
setItemName
(@Nullable String name) Deprecated.in favour ofitemName(Component)
void
setJukeboxPlayable
(@Nullable JukeboxPlayableComponent jukeboxPlayable) Sets the jukebox playable component.void
setLocalizedName
(@Nullable String name) Deprecated, for removal: This API element is subject to removal in a future version.UsedisplayName(Component)
with aTranslatableComponent
.void
Deprecated.in favour oflore(List)
void
setLoreComponents
(@Nullable List<net.md_5.bungee.api.chat.BaseComponent[]> lore) Deprecated.uselore(List)
void
Sets the max_stack_size.void
setPlaceableKeys
(@NotNull Collection<Namespaced> canPlaceOn) Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.void
setRarity
(@Nullable ItemRarity rarity) Sets the item rarity.void
setTool
(@Nullable ToolComponent tool) Sets the item tool.void
setTooltipStyle
(@Nullable NamespacedKey tooltipStyle) Sets the custom tooltip style.void
setUnbreakable
(boolean unbreakable) Sets the unbreakable tag.void
setUseCooldown
(@Nullable UseCooldownComponent cooldown) Sets the item use cooldown.void
setUseRemainder
(@Nullable ItemStack remainder) Sets the item which this item will convert to when used.void
setVersion
(int version) Internal use only! Do not use under any circumstances!Methods inherited from interface org.bukkit.configuration.serialization.ConfigurationSerializable
serialize
Methods inherited from interface org.bukkit.persistence.PersistentDataHolder
getPersistentDataContainer
-
Method Details
-
hasCustomName
boolean hasCustomName()Checks for existence of a custom name.- Returns:
- true if this has a custom name
-
customName
Gets the custom name.Plugins should check that
hasCustomName()
returnstrue
before calling this method.- Returns:
- the custom name
-
customName
Sets the custom name.- Parameters:
customName
- the custom name to set
-
hasDisplayName
Checks for existence of a display name.- Returns:
- true if this has a display name
- API Note:
- This method is obsolete, use
hasCustomName()
instead.
-
displayName
Gets the display name.Plugins should check that
hasDisplayName()
returnstrue
before calling this method.- Returns:
- the display name
- API Note:
- This method is obsolete, use
customName()
instead.
-
displayName
Sets the display name.- Parameters:
displayName
- the display name to set- API Note:
- This method is obsolete, use
customName(Component)
instead.
-
getDisplayName
Deprecated.in favour ofdisplayName()
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
Deprecated.usedisplayName()
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.in favour ofdisplayName(net.kyori.adventure.text.Component)
Sets the display name.- Parameters:
name
- the name to set
-
setDisplayNameComponent
@Deprecated void setDisplayNameComponent(@Nullable net.md_5.bungee.api.chat.BaseComponent[] component) Deprecated.Sets the display name.- Parameters:
component
- the name component to set
-
hasItemName
boolean hasItemName()Checks for existence of an item name.
Item name differs from display name in that it is cannot be edited by an anvil, is not styled with italics, and does not show labels.- Returns:
- true if this has an item name
-
itemName
Gets the item name component that is set.
Item name differs from display name in that it is cannot be edited by an anvil, is not styled with italics, and does not show labels.Plugins should check that
hasItemName()
returnstrue
before calling this method.- Returns:
- the item name that is set
- See Also:
-
itemName
Sets the item name.
Item name differs from display name in that it is cannot be edited by an anvil, is not styled with italics, and does not show labels.- Parameters:
name
- the name to set, null to remove it
-
getItemName
Deprecated.in favour ofitemName()
Gets the item name that is set.
Item name differs from display name in that it is cannot be edited by an anvil, is not styled with italics, and does not show labels.Plugins should check that hasItemName() returns
true
before calling this method.- Returns:
- the item name that is set
-
setItemName
Deprecated.in favour ofitemName(Component)
Sets the item name.
Item name differs from display name in that it is cannot be edited by an anvil, is not styled with italics, and does not show labels.- Parameters:
name
- the name to set
-
hasLocalizedName
Deprecated, for removal: This API element is subject to removal in a future version.UsedisplayName()
and check if it is instanceof aTranslatableComponent
.Checks for existence of a localized name.- Returns:
- true if this has a localized name
-
getLocalizedName
Deprecated, for removal: This API element is subject to removal in a future version.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
true
before calling this method.- Returns:
- the localized name that is set
-
setLocalizedName
Deprecated, for removal: This API element is subject to removal in a future version.UsedisplayName(Component)
with aTranslatableComponent
. No longer used by the client.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
Gets the lore.Plugins should check that
hasLore()
returnstrue
before calling this method.- Returns:
- the lore
-
lore
Sets the lore.- Parameters:
lore
- the lore to set
-
getLore
Deprecated.in favour oflore()
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
Deprecated.uselore()
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.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
-
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 custom model data that is set
-
getCustomModelDataComponent
Gets the custom model data set on this item, or creates an empty custom model data instance.The returned component is a snapshot of its current state and does not reflect a live view of what is on an item. After changing any value on this component, it must be set with
setCustomModelDataComponent(CustomModelDataComponent)
to apply the changes.- Returns:
- component
-
setCustomModelData
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
-
setCustomModelDataComponent
Sets the custom model data component.- Parameters:
customModelData
- new component
-
hasEnchantable
boolean hasEnchantable()Gets if the enchantable component is set.- Returns:
- if an enchantable is set.
-
getEnchantable
int getEnchantable()Gets the enchantable component. Higher values allow higher enchantments.- Returns:
- the enchantable value
-
setEnchantable
Sets the enchantable. Higher values allow higher enchantments.- Parameters:
enchantable
- enchantable value, must be positive
-
hasEnchants
boolean hasEnchants()Checks for the existence of any enchantments.- Returns:
- true if an enchantment exists on this meta
-
hasEnchant
Checks for existence of the specified enchantment.- Parameters:
ench
- enchantment to check- Returns:
- true if this enchantment exists for this meta
-
getEnchantLevel
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
Returns a copy the enchantments in this ItemMeta.
Returns an empty map if none.- Returns:
- An immutable copy of the enchantments
-
addEnchant
Adds the specified enchantment to this item meta.- Parameters:
ench
- Enchantment to addlevel
- Level for the enchantmentignoreLevelRestriction
- 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
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
-
removeEnchantments
void removeEnchantments()Removes all enchantments from this item meta. -
hasConflictingEnchant
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
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
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
Get current set itemFlags. The collection returned is unmodifiable.- Returns:
- A set of all itemFlags set
-
hasItemFlag
Check if the specified flag is present on this item.- Parameters:
flag
- the flag to check- Returns:
- if it is present
-
isHideTooltip
boolean isHideTooltip()Gets if this item has hide_tooltip set. An item with this set will not show any tooltip whatsoever.- Returns:
- hide_tooltip
-
setHideTooltip
void setHideTooltip(boolean hideTooltip) Sets if this item has hide_tooltip set. An item with this set will not show any tooltip whatsoever.- Parameters:
hideTooltip
- new hide_tooltip
-
hasTooltipStyle
boolean hasTooltipStyle()Gets if this item has a custom tooltip style.- Returns:
- if a tooltip_style is set
-
getTooltipStyle
Gets the custom tooltip style.- Returns:
- the tooltip style
-
setTooltipStyle
Sets the custom tooltip style.- Parameters:
tooltipStyle
- the new style
-
hasItemModel
boolean hasItemModel()Gets if this item has a custom item model.- Returns:
- if a item_model is set
-
getItemModel
Gets the custom item model.- Returns:
- the item model
-
setItemModel
Sets the custom item model.- Parameters:
itemModel
- the new model
-
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
-
hasEnchantmentGlintOverride
boolean hasEnchantmentGlintOverride()Gets if an enchantment_glint_override is set.- Returns:
- if an enchantment_glint_override is set
-
getEnchantmentGlintOverride
Sets the enchantment_glint_override. If true, the item will glint, even without enchantments; if false, the item will not glint, even with enchantments. Plugins should checkhasEnchantmentGlintOverride()
before calling this method.- Returns:
- enchantment_glint_override
-
setEnchantmentGlintOverride
Sets the enchantment_glint_override. If true, the item will glint, even without enchantments; if false, the item will not glint, even with enchantments. If null, the override will be cleared.- Parameters:
override
- new enchantment_glint_override
-
isGlider
boolean isGlider()Checks if this item is a glider. If true, this item will allow players to glide when it is equipped.- Returns:
- glider
-
setGlider
void setGlider(boolean glider) Sets if this item is a glider. If true, this item will allow players to glide when it is equipped.- Parameters:
glider
- glider
-
isFireResistant
Deprecated.Checks if this item is fire_resistant. If true, it will not burn in fire or lava.- Returns:
- fire_resistant
-
setFireResistant
Deprecated.Sets if this item is fire_resistant. If true, it will not burn in fire or lava.- Parameters:
fireResistant
- fire_resistant
-
hasDamageResistant
boolean hasDamageResistant()Gets if this item is resistant to certain types of damage.- Returns:
- true if a resistance is set
-
getDamageResistant
Gets the type of damage this item will be resistant to when in entity form. Plugins should checkhasDamageResistant()
before calling this method.- Returns:
- damage type
-
setDamageResistant
Sets the type of damage this item will be resistant to when in entity form.- Parameters:
tag
- the tag, or null to clear
-
hasMaxStackSize
boolean hasMaxStackSize()Gets if the max_stack_size is set.- Returns:
- if a max_stack_size is set.
-
getMaxStackSize
int getMaxStackSize()Gets the max_stack_size. This is the maximum amount which an item will stack.- Returns:
- max_stack_size
-
setMaxStackSize
Sets the max_stack_size. This is the maximum amount which an item will stack.- Parameters:
max
- max_stack_size, between 1 and 99 (inclusive)
-
hasRarity
boolean hasRarity()Gets if the rarity is set.- Returns:
- rarity
-
getRarity
Gets the item rarity. Plugins should checkhasRarity()
before calling this method.- Returns:
- rarity
-
setRarity
Sets the item rarity.- Parameters:
rarity
- new rarity
-
hasUseRemainder
boolean hasUseRemainder()Checks if the use remainder is set.- Returns:
- if a use remainder item is set
-
getUseRemainder
Gets the item which this item will convert to when used.- Returns:
- remainder
-
setUseRemainder
Sets the item which this item will convert to when used.- Parameters:
remainder
- new item
-
hasUseCooldown
boolean hasUseCooldown()Checks if the use cooldown is set.- Returns:
- if a use cooldown is set
-
getUseCooldown
Gets the use cooldown set on this item, or creates an empty cooldown instance.The returned component is a snapshot of its current state and does not reflect a live view of what is on an item. After changing any value on this component, it must be set with
setUseCooldown(UseCooldownComponent)
to apply the changes.- Returns:
- cooldown
-
setUseCooldown
Sets the item use cooldown.- Parameters:
cooldown
- new cooldown
-
hasFood
boolean hasFood()Checks if the food is set.- Returns:
- if a food is set
-
getFood
Gets the food set on this item, or creates an empty food instance.The returned component is a snapshot of its current state and does not reflect a live view of what is on an item. After changing any value on this component, it must be set with
setFood(FoodComponent)
to apply the changes.- Returns:
- food
-
setFood
Sets the item food.- Parameters:
food
- new food
-
hasTool
boolean hasTool()Checks if the tool is set.- Returns:
- if a tool is set
-
getTool
Gets the tool set on this item, or creates an empty tool instance.The returned component is a snapshot of its current state and does not reflect a live view of what is on an item. After changing any value on this component, it must be set with
setTool(ToolComponent)
to apply the changes.- Returns:
- tool
-
setTool
Sets the item tool.- Parameters:
tool
- new tool
-
hasEquippable
boolean hasEquippable()Checks if the equippable is set.- Returns:
- if a equippable is set
-
getEquippable
Gets the equippable set on this item, or creates an empty equippable instance.The returned component is a snapshot of its current state and does not reflect a live view of what is on an item. After changing any value on this component, it must be set with
setEquippable(EquippableComponent)
to apply the changes.- Returns:
- equippable
-
setEquippable
Sets the equippable tool.- Parameters:
equippable
- new equippable
-
hasJukeboxPlayable
boolean hasJukeboxPlayable()Checks if the jukebox playable is set.- Returns:
- if a jukebox playable is set
-
getJukeboxPlayable
Gets the jukebox playable component set on this item.The returned component is a snapshot of its current state and does not reflect a live view of what is on an item. After changing any value on this component, it must be set with
setJukeboxPlayable(org.bukkit.inventory.meta.components.JukeboxPlayableComponent)
to apply the changes.- Returns:
- component
-
setJukeboxPlayable
Sets the jukebox playable component.- Parameters:
jukeboxPlayable
- new component
-
hasAttributeModifiers
boolean hasAttributeModifiers()Checks for the existence of any AttributeModifiers.- Returns:
- true if any AttributeModifiers exist
-
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 allAttribute
s and theirAttributeModifier
s for a givenEquipmentSlot
.
AnyAttributeModifier
that does have a givenEquipmentSlot
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
- theEquipmentSlot
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 allAttributeModifier
s for a givenAttribute
- Parameters:
attribute
- theAttribute
- 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 supportEquipmentSlot
s. If not set, theAttributeModifier
will be active in ALL slots.
TwoAttributeModifier
s that have the sameUUID
cannot exist on the same Attribute.- Parameters:
attribute
- theAttribute
to modifymodifier
- theAttributeModifier
specifying the modification- Returns:
- true if the Attribute and AttributeModifier were successfully added
- Throws:
NullPointerException
- if Attribute is nullNullPointerException
- if AttributeModifier is nullIllegalArgumentException
- if AttributeModifier already exists
-
setAttributeModifiers
void setAttributeModifiers(@Nullable @Nullable Multimap<Attribute, AttributeModifier> attributeModifiers) Set allAttribute
s and theirAttributeModifier
s. To clear all custom attribute modifiers, usenull
. To set no modifiers (which will override the default modifiers), use an empty map. 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
Remove allAttributeModifier
s 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
-
removeAttributeModifier
Remove allAttribute
s andAttributeModifier
s for a givenEquipmentSlot
.
If the givenEquipmentSlot
is null, this will remove allAttributeModifier
s that do not have an EquipmentSlot set.- Parameters:
slot
- theEquipmentSlot
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 specificAttribute
andAttributeModifier
. AttributeModifiers are matched according to theirUUID
.- Parameters:
attribute
- theAttribute
to removemodifier
- theAttributeModifier
to remove- Returns:
- if any attribute modifiers were remove
- Throws:
NullPointerException
- if the Attribute is nullNullPointerException
- if the AttributeModifier is null- See Also:
-
getAsString
Get this ItemMeta as an NBT string. If this ItemMeta does not have any NBT, then"{}"
will be returned.This string should NEVER be relied upon as a serializable value. If serialization is desired, the
ConfigurationSerializable
API should be used instead.- Returns:
- the NBT string
-
getAsComponentString
Get this ItemMeta as a component-compliant string. If this ItemMeta does not contain any components, then"[]"
will be returned.The result of this method should yield a string representing the components altered by this ItemMeta instance. When passed to
ItemFactory.createItemStack(String)
with a prepended item type, it will create an ItemStack that has an ItemMeta matching this ItemMeta instance exactly. Note that this method returns ONLY the components and cannot be passed to createItemStack() alone. An example may look something like this:ItemStack itemStack = // ... an item stack obtained from somewhere ItemMeta itemMeta = itemStack.getItemMeta(); String components = itemMeta.getAsComponentString(); // example: "[minecraft:damage=53]" String itemTypeKey = itemStack.getType().getKey().toString(); // example: "minecraft:diamond_sword" String itemAsString = itemTypeKey + components; // results in: "minecraft:diamond_sword[minecraft:damage=53]" ItemStack recreatedItemStack = Bukkit.getItemFactory().createItemStack(itemAsString); assert itemStack.isSimilar(recreatedItemStack); // Should be true*
*Components not represented or explicitly overridden by this ItemMeta instance will not be included in the resulting string and therefore may result in ItemStacks that do not match exactly. For example, if
setDisplayName(String)
is not set, then the custom name component will not be included. Or if this ItemMeta is a PotionMeta, it will not include any components related to lodestone compasses, banners, or books, etc., only components modifiable by a PotionMeta instance.This string should NEVER be relied upon as a serializable value. If serialization is desired, the
ConfigurationSerializable
API should be used instead.- Returns:
- the component-compliant string
-
getCustomTagContainer
Deprecated.this API part has been replaced by thePersistentDataHolder
API. 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
-
setVersion
Internal use only! Do not use under any circumstances!- Parameters:
version
- version- API Note:
- internal use only
-
clone
-
getCanDestroy
Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.Gets set of materials what given item can destroy inGameMode.ADVENTURE
- Returns:
- Set of materials
-
setCanDestroy
Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.Sets set of materials what given item can destroy inGameMode.ADVENTURE
- Parameters:
canDestroy
- Set of materials
-
getCanPlaceOn
Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.Gets set of materials where given item can be placed on inGameMode.ADVENTURE
- Returns:
- Set of materials
-
setCanPlaceOn
Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.Sets set of materials where given item can be placed on inGameMode.ADVENTURE
- Parameters:
canPlaceOn
- Set of materials
-
getDestroyableKeys
Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.Gets the collection of namespaced keys that the item can destroy inGameMode.ADVENTURE
- Returns:
- Set of
Namespaced
-
setDestroyableKeys
@Deprecated(forRemoval=true, since="1.20.6") void setDestroyableKeys(@NotNull @NotNull Collection<Namespaced> canDestroy) Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.Sets the collection of namespaced keys that the item can destroy inGameMode.ADVENTURE
- Parameters:
canDestroy
- Collection ofNamespaced
-
getPlaceableKeys
Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.Gets the collection of namespaced keys that the item can be placed on inGameMode.ADVENTURE
- Returns:
- Set of
Namespaced
-
setPlaceableKeys
@Deprecated(forRemoval=true, since="1.20.6") void setPlaceableKeys(@NotNull @NotNull Collection<Namespaced> canPlaceOn) Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replaced, its usage may result in data loss related to place/destroy predicates.Sets the set of namespaced keys that the item can be placed on inGameMode.ADVENTURE
- Parameters:
canPlaceOn
- Collection ofNamespaced
-
hasPlaceableKeys
Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replacedChecks for the existence of any keys that the item can be placed on- Returns:
- true if this item has placeable keys
-
hasDestroyableKeys
Deprecated, for removal: This API element is subject to removal in a future version.this API is unsupported and will be replacedChecks for the existence of any keys that the item can destroy- Returns:
- true if this item has destroyable keys
-