Interface ItemMeta
- All Superinterfaces:
Cloneable,ConfigurationSerializable,PersistentDataHolder
- All Known Subinterfaces:
ArmorMeta,AxolotlBucketMeta,BannerMeta,BlockDataMeta,BlockStateMeta,BookMeta,BundleMeta,ColorableArmorMeta,CompassMeta,CrossbowMeta,Damageable,EnchantmentStorageMeta,FireworkEffectMeta,FireworkMeta,KnowledgeBookMeta,LeatherArmorMeta,MapMeta,MusicInstrumentMeta,OminousBottleMeta,PotionMeta,Repairable,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 TypeMethodDescriptionbooleanaddAttributeModifier(Attribute attribute, AttributeModifier modifier) Add an Attribute and it's Modifier.booleanaddEnchant(Enchantment ench, int level, boolean ignoreLevelRestriction) Adds the specified enchantment to this item meta.voidaddItemFlags(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 allAttributeModifiers for a givenAttributeReturn an immutable copy of allAttributes and theirAttributeModifiers for a givenEquipmentSlot.
AnyAttributeModifierthat does have have a givenEquipmentSlotwill be returned.intGets the custom model data that is set.Deprecated.Gets the display name that is set.intgetEnchantLevel(Enchantment ench) Checks for the level of the specified enchantment.Sets the enchantment_glint_override.Returns a copy the enchantments in this ItemMeta.getFood()Gets the food set on this item, or creates an empty food instance.Get current set itemFlags.Gets the item name that is set.Deprecated, for removal: This API element is subject to removal in a future version.meta no longer existsgetLore()Gets the lore that is set.intGets the max_stack_size.Gets the item rarity.booleanChecks 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 existence of a display name.booleanhasEnchant(Enchantment ench) Checks for existence of the specified enchantment.booleanGets if an enchantment_glint_override is set.booleanChecks for the existence of any enchantments.booleanhasFood()Checks if the food is set.booleanhasItemFlag(ItemFlag flag) Check if the specified flag is present on this item.booleanChecks for existence of an item name.booleanDeprecated, for removal: This API element is subject to removal in a future version.meta no longer existsbooleanhasLore()Checks for existence of lore.booleanGets if the max_stack_size is set.booleanGets if the rarity is set.booleanChecks if this item is fire_resistant.booleanGets if this item has hide_tooltip set.booleanReturn if the unbreakable tag is true.booleanremoveAttributeModifier(Attribute attribute) Remove allAttributeModifiers associated with the givenAttribute.booleanremoveAttributeModifier(Attribute attribute, 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(Enchantment ench) Removes the specified enchantment from this item meta.voidRemoves all enchantments from this item meta.voidremoveItemFlags(ItemFlag... itemFlags) Remove specific set of itemFlags.voidsetAttributeModifiers(Multimap<Attribute, AttributeModifier> attributeModifiers) Set allAttributes and theirAttributeModifiers.voidsetCustomModelData(Integer data) Sets the custom model data.voidsetDisplayName(String name) Sets the display name.voidsetEnchantmentGlintOverride(Boolean override) Sets the enchantment_glint_override.voidsetFireResistant(boolean fireResistant) Sets if this item is fire_resistant.voidsetFood(FoodComponent food) Sets the item food.voidsetHideTooltip(boolean hideTooltip) Sets if this item has hide_tooltip set.voidsetItemName(String name) Sets the item name.voidsetLocalizedName(String name) Deprecated, for removal: This API element is subject to removal in a future version.meta no longer existsvoidSets the lore for this item.voidsetMaxStackSize(Integer max) Sets the max_stack_size.voidsetRarity(ItemRarity rarity) Sets the item rarity.voidsetUnbreakable(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.ConfigurationSerializable
serializeMethods 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
truebefore calling this method.- Returns:
- the display name that is set
-
setDisplayName
Sets the display name.- Parameters:
name- the name 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
-
getItemName
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
truebefore calling this method.- Returns:
- the item name that is set
-
setItemName
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.meta no longer existsChecks 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.meta no longer existsGets the localized display name that is set.Plugins should check that hasLocalizedName() returns
truebefore 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.meta no longer existsSets 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
truebefore 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
truebefore 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
-
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
-
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
-
isFireResistant
boolean isFireResistant()Checks if this item is fire_resistant. If true, it will not burn in fire or lava.- Returns:
- fire_resistant
-
setFireResistant
void setFireResistant(boolean fireResistant) Sets if this item is fire_resistant. If true, it will not burn in fire or lava.- Parameters:
fireResistant- fire_resistant
-
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
-
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.- Returns:
- food
-
setFood
Sets the item food.- Parameters:
food- new food
-
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
Multimapof Attributes and their AttributeModifiers, or null if none exist
-
getAttributeModifiers
Return an immutable copy of allAttributes and theirAttributeModifiers for a givenEquipmentSlot.
AnyAttributeModifierthat does have 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- theEquipmentSlotto check- Returns:
- the immutable
Multimapwith the respective Attributes and modifiers, or an empty map if no attributes are set.
-
getAttributeModifiers
Return an immutable copy of allAttributeModifiers for a givenAttribute- Parameters:
attribute- theAttribute- Returns:
- an immutable collection of
AttributeModifiers 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 supportEquipmentSlots. If not set, theAttributeModifierwill be active in ALL slots.
TwoAttributeModifiers that have the sameUUIDcannot exist on the same Attribute.- Parameters:
attribute- theAttributeto modifymodifier- theAttributeModifierspecifying 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 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
-
removeAttributeModifier
Remove 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
-
removeAttributeModifier
Remove allAttributes andAttributeModifiers for a givenEquipmentSlot.
If the givenEquipmentSlotis null, this will remove allAttributeModifiers that do not have an EquipmentSlot set.- Parameters:
slot- theEquipmentSlotto clear all Attributes and their modifiers for- Returns:
- true if all modifiers were removed that match the given EquipmentSlot.
-
removeAttributeModifier
Remove a specificAttributeandAttributeModifier. AttributeModifiers are matched according to theirUUID.- Parameters:
attribute- theAttributeto removemodifier- theAttributeModifierto 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
ConfigurationSerializableAPI should be used instead.- Returns:
- the NBT string
-
getCustomTagContainer
Deprecated.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
-
setVersion
@Internal void setVersion(int version) Internal use only! Do not use under any circumstances!- Parameters:
version- version- API Note:
- internal use only
-
clone
-
PersistentDataHolderAPI.