Interface ItemMeta
- All Superinterfaces:
Cloneable
,ConfigurationSerializable
,PersistentDataHolder
- All Known Subinterfaces:
AxolotlBucketMeta
,BannerMeta
,BlockDataMeta
,BlockStateMeta
,BookMeta
,BundleMeta
,CompassMeta
,CrossbowMeta
,Damageable
,EnchantmentStorageMeta
,FireworkEffectMeta
,FireworkMeta
,KnowledgeBookMeta
,LeatherArmorMeta
,MapMeta
,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 Summary
Modifier and TypeMethodDescriptionboolean
addAttributeModifier
(Attribute attribute, AttributeModifier modifier) Add an Attribute and it's Modifier.boolean
addEnchant
(Enchantment ench, int level, boolean ignoreLevelRestriction) Adds the specified enchantment to this item meta.void
addItemFlags
(ItemFlag... itemFlags) Set itemflags which should be ignored when rendering a ItemStack in the Client.clone()
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
(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 have a givenEquipmentSlot
will be returned.int
Gets the custom model data that is set.Deprecated.Gets the display name that is set.int
getEnchantLevel
(Enchantment ench) Checks for the level of the specified enchantment.Returns a copy the enchantments in this ItemMeta.Get current set itemFlags.Gets the localized display name that is set.getLore()
Gets the lore that is set.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 display name.boolean
hasEnchant
(Enchantment ench) Checks for existence of the specified enchantment.boolean
Checks for the existence of any enchantments.boolean
hasItemFlag
(ItemFlag flag) Check if the specified flag is present on this item.boolean
Checks for existence of a localized name.boolean
hasLore()
Checks for existence of lore.boolean
Return if the unbreakable tag is true.boolean
removeAttributeModifier
(Attribute attribute) Remove allAttributeModifier
s associated with the givenAttribute
.boolean
removeAttributeModifier
(Attribute attribute, 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
(Enchantment ench) Removes the specified enchantment from this item meta.void
removeItemFlags
(ItemFlag... itemFlags) Remove specific set of itemFlags.void
setAttributeModifiers
(Multimap<Attribute, AttributeModifier> attributeModifiers) Set allAttribute
s and theirAttributeModifier
s.void
setCustomModelData
(Integer data) Sets the custom model data.void
setDisplayName
(String name) Sets the display name.void
setLocalizedName
(String name) Sets the localized name.void
Sets the lore for this item.void
setUnbreakable
(boolean unbreakable) Sets the unbreakable tag.void
setVersion
(int version) Deprecated.internal use onlyMethods 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
-
getDisplayName
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
Sets the display name.- Parameters:
name
- the name to set
-
hasLocalizedName
boolean hasLocalizedName()Checks for existence of a localized name.- Returns:
- true if this has a localized name
-
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
Sets the localized name.- Parameters:
name
- the name to set
-
hasLore
boolean hasLore()Checks for existence of lore.- Returns:
- true if this has lore
-
getLore
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
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
-
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
-
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
-
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
-
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
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
Return an immutable copy of allAttribute
s and theirAttributeModifier
s for a givenEquipmentSlot
.
AnyAttributeModifier
that does have 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
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
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
Set allAttribute
s and theirAttributeModifier
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
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
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.This string should not be relied upon as a serializable value. If serialization is desired, the
ConfigurationSerializable
API should be used instead.- Returns:
- the NBT 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
Deprecated.internal use onlyInternal use only! Do not use under any circumstances!- Parameters:
version
- version
-
clone
-
PersistentDataHolder
API.