java.lang.Cloneable
, ConfigurationSerializable
ArmorStandMeta
, BannerMeta
, BlockStateMeta
, BookMeta
, EnchantmentStorageMeta
, FireworkEffectMeta
, FireworkMeta
, KnowledgeBookMeta
, LeatherArmorMeta
, MapMeta
, PotionMeta
, SkullMeta
, SpawnEggMeta
, TropicalFishBucketMeta
public interface ItemMeta extends java.lang.Cloneable, ConfigurationSerializable
An implementation will handle the creation and application for ItemMeta. This class should not be implemented by a plugin in a live environment.
Attribute related APIs are draft API
Modifier and Type | Interface | Description |
---|---|---|
static class |
ItemMeta.Spigot |
Modifier and Type | Method | Description |
---|---|---|
boolean |
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.
|
ItemMeta |
clone() |
|
com.google.common.collect.Multimap<Attribute,AttributeModifier> |
getAttributeModifiers() |
Return an immutable copy of all Attributes and
their modifiers in this ItemMeta.
Returns null if none exist. |
java.util.Collection<AttributeModifier> |
getAttributeModifiers(Attribute attribute) |
Return an immutable copy of all
AttributeModifier s
for a given Attribute |
com.google.common.collect.Multimap<Attribute,AttributeModifier> |
getAttributeModifiers(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. |
java.util.Set<Material> |
getCanDestroy() |
Gets set of materials what given item can destroy in
GameMode.ADVENTURE |
java.util.Set<Material> |
getCanPlaceOn() |
Gets set of materials where given item can be placed on in
GameMode.ADVENTURE |
java.lang.String |
getDisplayName() |
Gets the display name that is set.
|
int |
getEnchantLevel(Enchantment ench) |
Checks for the level of the specified enchantment.
|
java.util.Map<Enchantment,java.lang.Integer> |
getEnchants() |
Returns a copy the enchantments in this ItemMeta.
|
java.util.Set<ItemFlag> |
getItemFlags() |
Get current set itemFlags.
|
java.lang.String |
getLocalizedName() |
Gets the localized display name that is set.
|
java.util.List<java.lang.String> |
getLore() |
Gets the lore that is set.
|
boolean |
hasAttributeModifiers() |
Checks for the existence of any AttributeModifiers.
|
boolean |
hasConflictingEnchant(Enchantment ench) |
Checks if the specified enchantment conflicts with any enchantments in
this ItemMeta.
|
boolean |
hasDisplayName() |
Checks for existence of a display name.
|
boolean |
hasEnchant(Enchantment ench) |
Checks for existence of the specified enchantment.
|
boolean |
hasEnchants() |
Checks for the existence of any enchantments.
|
boolean |
hasItemFlag(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 |
isUnbreakable() |
Return if the unbreakable tag is true.
|
boolean |
removeAttributeModifier(Attribute attribute) |
Remove all
AttributeModifier s associated with the given
Attribute . |
boolean |
removeAttributeModifier(Attribute attribute,
AttributeModifier modifier) |
Remove a specific
Attribute and AttributeModifier . |
boolean |
removeAttributeModifier(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(Enchantment ench) |
Removes the specified enchantment from this item meta.
|
void |
removeItemFlags(ItemFlag... itemFlags) |
Remove specific set of itemFlags.
|
void |
setAttributeModifiers(com.google.common.collect.Multimap<Attribute,AttributeModifier> attributeModifiers) |
Set all
Attribute s and their AttributeModifier s. |
void |
setCanDestroy(java.util.Set<Material> canDestroy) |
Sets set of materials what given item can destroy in
GameMode.ADVENTURE |
void |
setCanPlaceOn(java.util.Set<Material> canPlaceOn) |
Sets set of materials where given item can be placed on in
GameMode.ADVENTURE |
void |
setDisplayName(java.lang.String name) |
Sets the display name.
|
void |
setLocalizedName(java.lang.String name) |
Sets the localized name.
|
void |
setLore(java.util.List<java.lang.String> lore) |
Sets the lore for this item.
|
void |
setUnbreakable(boolean unbreakable) |
Sets the unbreakable tag.
|
ItemMeta.Spigot |
spigot() |
serialize
boolean hasDisplayName()
java.lang.String getDisplayName()
Plugins should check that hasDisplayName() returns true
before calling this method.
void setDisplayName(java.lang.String name)
name
- the name to setboolean hasLocalizedName()
java.lang.String getLocalizedName()
Plugins should check that hasLocalizedName() returns true
before calling this method.
void setLocalizedName(java.lang.String name)
name
- the name to setboolean hasLore()
java.util.List<java.lang.String> getLore()
Plugins should check if hasLore() returns true
before
calling this method.
void setLore(java.util.List<java.lang.String> lore)
lore
- the lore that will be setboolean hasEnchants()
boolean hasEnchant(Enchantment ench)
ench
- enchantment to checkint getEnchantLevel(Enchantment ench)
ench
- enchantment to checkjava.util.Map<Enchantment,java.lang.Integer> getEnchants()
boolean addEnchant(Enchantment ench, int level, boolean ignoreLevelRestriction)
ench
- Enchantment to addlevel
- Level for the enchantmentignoreLevelRestriction
- this indicates the enchantment should be
applied, ignoring the level limitboolean removeEnchant(Enchantment ench)
ench
- Enchantment to removeboolean hasConflictingEnchant(Enchantment ench)
ench
- enchantment to testvoid addItemFlags(ItemFlag... itemFlags)
itemFlags
- The hideflags which shouldn't be renderedvoid removeItemFlags(ItemFlag... itemFlags)
itemFlags
- Hideflags which should be removedjava.util.Set<ItemFlag> getItemFlags()
boolean hasItemFlag(ItemFlag flag)
flag
- the flag to checkboolean isUnbreakable()
void setUnbreakable(boolean unbreakable)
unbreakable
- true if set unbreakableboolean hasAttributeModifiers()
com.google.common.collect.Multimap<Attribute,AttributeModifier> getAttributeModifiers()
Multimap
of Attributes
and their AttributeModifiers, or null if none existcom.google.common.collect.Multimap<Attribute,AttributeModifier> getAttributeModifiers(EquipmentSlot slot)
Attribute
s and their
AttributeModifier
s for a given EquipmentSlot
.AttributeModifier
that does have have a given
EquipmentSlot
will be returned. This is because
AttributeModifiers without a slot are active in any slot.slot
- the EquipmentSlot
to checkMultimap
with the
respective Attributes and modifiers, or an empty map
if no attributes are set.java.util.Collection<AttributeModifier> getAttributeModifiers(Attribute attribute)
AttributeModifier
s
for a given Attribute
attribute
- the Attribute
AttributeModifier
s
or null if no AttributeModifiers exist for the Attribute.java.lang.NullPointerException
- if Attribute is nullboolean addAttributeModifier(Attribute attribute, AttributeModifier modifier)
EquipmentSlot
s.
If not set, the AttributeModifier
will be active in ALL slots.
AttributeModifier
s that have the same UUID
cannot exist on the same Attribute.attribute
- the Attribute
to modifymodifier
- the AttributeModifier
specifying the modificationjava.lang.NullPointerException
- if Attribute is nulljava.lang.NullPointerException
- if AttributeModifier is nulljava.lang.IllegalArgumentException
- if AttributeModifier already existsvoid setAttributeModifiers(com.google.common.collect.Multimap<Attribute,AttributeModifier> attributeModifiers)
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.attributeModifiers
- the new Multimap containing the Attributes
and their AttributeModifiersboolean removeAttributeModifier(Attribute attribute)
AttributeModifier
s associated with the given
Attribute
.
This will return false if nothing was removed.attribute
- attribute to removejava.lang.NullPointerException
- if Attribute is nullboolean removeAttributeModifier(EquipmentSlot slot)
Attribute
s and AttributeModifier
s for a
given EquipmentSlot
.EquipmentSlot
is null, this will remove all
AttributeModifier
s that do not have an EquipmentSlot set.slot
- the EquipmentSlot
to clear all Attributes and
their modifiers forboolean removeAttributeModifier(Attribute attribute, AttributeModifier modifier)
Attribute
and AttributeModifier
.
AttributeModifiers are matched according to their UUID
.attribute
- the Attribute
to removemodifier
- the AttributeModifier
to removejava.lang.NullPointerException
- if the Attribute is nulljava.lang.NullPointerException
- if the AttributeModifier is nullAttributeModifier.getUniqueId()
ItemMeta clone()
ItemMeta.Spigot spigot()
java.util.Set<Material> getCanDestroy()
GameMode.ADVENTURE
void setCanDestroy(java.util.Set<Material> canDestroy)
GameMode.ADVENTURE
canDestroy
- Set of materialsjava.util.Set<Material> getCanPlaceOn()
GameMode.ADVENTURE
void setCanPlaceOn(java.util.Set<Material> canPlaceOn)
GameMode.ADVENTURE
canPlaceOn
- Set of materialsCopyright © 2018. All rights reserved.