Cloneable, ConfigurationSerializableArmorStandMeta, BannerMeta, BlockStateMeta, BookMeta, EnchantmentStorageMeta, FireworkEffectMeta, FireworkMeta, KnowledgeBookMeta, LeatherArmorMeta, MapMeta, PotionMeta, SkullMeta, SpawnEggMeta, TropicalFishBucketMetapublic interface ItemMeta extends 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.
| 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. |
Collection<AttributeModifier> |
getAttributeModifiers(Attribute attribute) |
Return an immutable copy of all
AttributeModifiers
for a given Attribute |
com.google.common.collect.Multimap<Attribute,AttributeModifier> |
getAttributeModifiers(EquipmentSlot slot) |
Return an immutable copy of all
Attributes and their
AttributeModifiers for a given EquipmentSlot.Any AttributeModifier that does have have a given
EquipmentSlot will be returned. |
Set<Material> |
getCanDestroy() |
Deprecated.
Minecraft does not limit this to the material enum, Use
getDestroyableKeys() as a replacement |
Set<Material> |
getCanPlaceOn() |
Deprecated.
Minecraft does not limit this to the material enum, Use
getPlaceableKeys() as a replacement |
CustomItemTagContainer |
getCustomTagContainer() |
Returns a public custom tag container capable of storing tags on the
item.
|
Set<Namespaced> |
getDestroyableKeys() |
Gets the collection of namespaced keys that the item can destroy in
GameMode.ADVENTURE |
String |
getDisplayName() |
Gets the display name that is set.
|
int |
getEnchantLevel(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.
|
String |
getLocalizedName() |
Gets the localized display name that is set.
|
List<String> |
getLore() |
Gets the lore that is set.
|
Set<Namespaced> |
getPlaceableKeys() |
Gets the collection of namespaced keys that the item can be placed on in
GameMode.ADVENTURE |
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 |
hasDestroyableKeys() |
Checks for the existence of any keys that the item can destroy
|
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 |
hasPlaceableKeys() |
Checks for the existence of any keys that the item can be placed on
|
boolean |
isUnbreakable() |
Return if the unbreakable tag is true.
|
boolean |
removeAttributeModifier(Attribute attribute) |
Remove all
AttributeModifiers associated with the given
Attribute. |
boolean |
removeAttributeModifier(Attribute attribute,
AttributeModifier modifier) |
Remove a specific
Attribute and AttributeModifier. |
boolean |
removeAttributeModifier(EquipmentSlot slot) |
Remove all
Attributes and AttributeModifiers for a
given EquipmentSlot.If the given EquipmentSlot is null, this will remove all
AttributeModifiers 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
Attributes and their AttributeModifiers. |
void |
setCanDestroy(Set<Material> canDestroy) |
Deprecated.
Minecraft does not limit this to the material enum, Use
setDestroyableKeys(Collection) as a replacement |
void |
setCanPlaceOn(Set<Material> canPlaceOn) |
Deprecated.
Minecraft does not limit this to the material enum, Use
setPlaceableKeys(Collection) as a replacement |
void |
setDestroyableKeys(Collection<Namespaced> canDestroy) |
Sets the collection of namespaced keys that the item can destroy in
GameMode.ADVENTURE |
void |
setDisplayName(String name) |
Sets the display name.
|
void |
setLocalizedName(String name) |
Sets the localized name.
|
void |
setLore(List<String> lore) |
Sets the lore for this item.
|
void |
setPlaceableKeys(Collection<Namespaced> canPlaceOn) |
Sets the set of namespaced keys that the item can be placed on in
GameMode.ADVENTURE |
void |
setUnbreakable(boolean unbreakable) |
Sets the unbreakable tag.
|
ItemMeta.Spigot |
spigot() |
serializeboolean hasDisplayName()
@NotNull String getDisplayName()
Plugins should check that hasDisplayName() returns true
before calling this method.
void setDisplayName(@Nullable
String name)
name - the name to setboolean hasLocalizedName()
@NotNull String getLocalizedName()
Plugins should check that hasLocalizedName() returns true
before calling this method.
void setLocalizedName(@Nullable
String name)
name - the name to setboolean hasLore()
@Nullable List<String> getLore()
Plugins should check if hasLore() returns true before
calling this method.
void setLore(@Nullable
List<String> lore)
lore - the lore that will be setboolean hasEnchants()
boolean hasEnchant(@NotNull
Enchantment ench)
ench - enchantment to checkint getEnchantLevel(@NotNull
Enchantment ench)
ench - enchantment to check@NotNull Map<Enchantment,Integer> getEnchants()
boolean addEnchant(@NotNull
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(@NotNull
Enchantment ench)
ench - Enchantment to removeboolean hasConflictingEnchant(@NotNull
Enchantment ench)
ench - enchantment to testvoid addItemFlags(@NotNull
ItemFlag... itemFlags)
itemFlags - The hideflags which shouldn't be renderedvoid removeItemFlags(@NotNull
ItemFlag... itemFlags)
itemFlags - Hideflags which should be removed@NotNull Set<ItemFlag> getItemFlags()
boolean hasItemFlag(@NotNull
ItemFlag flag)
flag - the flag to checkboolean isUnbreakable()
void setUnbreakable(boolean unbreakable)
unbreakable - true if set unbreakableboolean hasAttributeModifiers()
@Nullable com.google.common.collect.Multimap<Attribute,AttributeModifier> getAttributeModifiers()
Multimap of Attributes
and their AttributeModifiers, or null if none exist@NotNull com.google.common.collect.Multimap<Attribute,AttributeModifier> getAttributeModifiers(@NotNull EquipmentSlot slot)
Attributes and their
AttributeModifiers 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.@Nullable Collection<AttributeModifier> getAttributeModifiers(@NotNull Attribute attribute)
AttributeModifiers
for a given Attributeattribute - the AttributeAttributeModifiers
or null if no AttributeModifiers exist for the Attribute.NullPointerException - if Attribute is nullboolean addAttributeModifier(@NotNull
Attribute attribute,
@NotNull
AttributeModifier modifier)
EquipmentSlots.
If not set, the AttributeModifier will be active in ALL slots.
AttributeModifiers that have the same UUID
cannot exist on the same Attribute.attribute - the Attribute to modifymodifier - the AttributeModifier specifying the modificationNullPointerException - if Attribute is nullNullPointerException - if AttributeModifier is nullIllegalArgumentException - if AttributeModifier already existsvoid setAttributeModifiers(@Nullable
com.google.common.collect.Multimap<Attribute,AttributeModifier> attributeModifiers)
Attributes and their AttributeModifiers.
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(@NotNull
Attribute attribute)
AttributeModifiers associated with the given
Attribute.
This will return false if nothing was removed.attribute - attribute to removeNullPointerException - if Attribute is nullboolean removeAttributeModifier(@NotNull
EquipmentSlot slot)
Attributes and AttributeModifiers for a
given EquipmentSlot.EquipmentSlot is null, this will remove all
AttributeModifiers that do not have an EquipmentSlot set.slot - the EquipmentSlot to clear all Attributes and
their modifiers forboolean removeAttributeModifier(@NotNull
Attribute attribute,
@NotNull
AttributeModifier modifier)
Attribute and AttributeModifier.
AttributeModifiers are matched according to their UUID.attribute - the Attribute to removemodifier - the AttributeModifier to removeNullPointerException - if the Attribute is nullNullPointerException - if the AttributeModifier is nullAttributeModifier.getUniqueId()@NotNull CustomItemTagContainer getCustomTagContainer()
@NotNull ItemMeta clone()
@NotNull ItemMeta.Spigot spigot()
@Deprecated Set<Material> getCanDestroy()
getDestroyableKeys() as a replacementGameMode.ADVENTURE@Deprecated void setCanDestroy(Set<Material> canDestroy)
setDestroyableKeys(Collection) as a replacementGameMode.ADVENTUREcanDestroy - Set of materials@Deprecated Set<Material> getCanPlaceOn()
getPlaceableKeys() as a replacementGameMode.ADVENTURE@Deprecated void setCanPlaceOn(Set<Material> canPlaceOn)
setPlaceableKeys(Collection) as a replacementGameMode.ADVENTUREcanPlaceOn - Set of materials@NotNull Set<Namespaced> getDestroyableKeys()
GameMode.ADVENTURENamespacedvoid setDestroyableKeys(@NotNull
Collection<Namespaced> canDestroy)
GameMode.ADVENTUREcanDestroy - Collection of Namespaced@NotNull Set<Namespaced> getPlaceableKeys()
GameMode.ADVENTURENamespaced@NotNull
void setPlaceableKeys(@NotNull
Collection<Namespaced> canPlaceOn)
GameMode.ADVENTUREcanPlaceOn - Collection of Namespacedboolean hasPlaceableKeys()
boolean hasDestroyableKeys()
Copyright © 2020. All rights reserved.