Package org.bukkit.inventory.meta
Interface ItemMeta
-
- All Superinterfaces:
Cloneable,ConfigurationSerializable
- All Known Subinterfaces:
BannerMeta,BlockStateMeta,BookMeta,EnchantmentStorageMeta,FireworkEffectMeta,FireworkMeta,KnowledgeBookMeta,LeatherArmorMeta,MapMeta,PotionMeta,SkullMeta,SpawnEggMeta,TropicalFishBucketMeta
public interface ItemMeta extends Cloneable, ConfigurationSerializable
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classItemMeta.Spigot
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.ItemMetaclone()StringgetDisplayName()Gets the display name that is set.intgetEnchantLevel(Enchantment ench)Checks for the level of the specified enchantment.Map<Enchantment,Integer>getEnchants()Returns a copy the enchantments in this ItemMeta.Set<ItemFlag>getItemFlags()Get current set itemFlags.StringgetLocalizedName()Gets the localized display name that is set.List<String>getLore()Gets the lore that is set.booleanhasConflictingEnchant(Enchantment ench)Checks if the specified enchantment conflicts with any enchantments in this ItemMeta.booleanhasDisplayName()Checks for existence of a display name.booleanhasEnchant(Enchantment ench)Checks for existence of the specified enchantment.booleanhasEnchants()Checks for the existence of any enchantments.booleanhasItemFlag(ItemFlag flag)Check if the specified flag is present on this item.booleanhasLocalizedName()Checks for existence of a localized name.booleanhasLore()Checks for existence of lore.booleanisUnbreakable()Return if the unbreakable tag is true.booleanremoveEnchant(Enchantment ench)Removes the specified enchantment from this item meta.voidremoveItemFlags(ItemFlag... itemFlags)Remove specific set of itemFlags.voidsetDisplayName(String name)Sets the display name.voidsetLocalizedName(String name)Sets the localized name.voidsetLore(List<String> lore)Sets the lore for this item.voidsetUnbreakable(boolean unbreakable)Sets the unbreakable tag.ItemMeta.Spigotspigot()-
Methods inherited from interface org.bukkit.configuration.serialization.ConfigurationSerializable
serialize
-
-
-
-
Method Detail
-
hasDisplayName
boolean hasDisplayName()
Checks for existence of a display name.- Returns:
- true if this has a display name
-
getDisplayName
String 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
void setDisplayName(String name)
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
String getLocalizedName()
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
-
setLocalizedName
void setLocalizedName(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
-
getLore
List<String> 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
void setLore(List<String> lore)
Sets the lore for this item. Removes lore when given null.- Parameters:
lore- the lore that will be set
-
hasEnchants
boolean hasEnchants()
Checks for the existence of any enchantments.- Returns:
- true if an enchantment exists on this meta
-
hasEnchant
boolean hasEnchant(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(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
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(Enchantment ench, int level, boolean ignoreLevelRestriction)
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
boolean removeEnchant(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(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(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(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
Set<ItemFlag> getItemFlags()
Get current set itemFlags. The collection returned is unmodifiable.- Returns:
- A set of all itemFlags set
-
hasItemFlag
boolean hasItemFlag(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
-
clone
ItemMeta clone()
-
spigot
ItemMeta.Spigot spigot()
-
-