public interface ItemMeta extends Cloneable, ConfigurationSerializable, PersistentDataHolder
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 and Description |
---|---|
static class |
ItemMeta.Spigot |
Modifier and Type | Method and 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
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. |
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 |
int |
getCustomModelData()
Gets the custom model data that is set.
|
CustomItemTagContainer |
getCustomTagContainer()
Deprecated.
this API part has been replaced by the
PersistentDataHolder API.
Please use PersistentDataHolder.getPersistentDataContainer() instead of this. |
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 |
hasCustomModelData()
Checks for existence of custom model data.
|
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
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(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 |
setCustomModelData(Integer data)
Sets the custom model data.
|
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.
|
void |
setVersion(int version)
Deprecated.
|
ItemMeta.Spigot |
spigot() |
serialize
getPersistentDataContainer
boolean 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 hasCustomModelData()
CustomModelData is an integer that may be associated client side with a custom item model.
int getCustomModelData()
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.
void setCustomModelData(@Nullable Integer data)
CustomModelData is an integer that may be associated client side with a custom item model.
data
- the data to set, or null to clearboolean 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)
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.@Nullable Collection<AttributeModifier> getAttributeModifiers(@NotNull Attribute attribute)
AttributeModifier
s
for a given Attribute
attribute
- the Attribute
AttributeModifier
s
or null if no AttributeModifiers exist for the Attribute.NullPointerException
- if Attribute is nullboolean addAttributeModifier(@NotNull Attribute attribute, @NotNull 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 modificationNullPointerException
- if Attribute is nullNullPointerException
- if AttributeModifier is nullIllegalArgumentException
- if AttributeModifier already existsvoid setAttributeModifiers(@Nullable 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(@NotNull Attribute attribute)
AttributeModifier
s 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)
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(@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 @Deprecated CustomItemTagContainer getCustomTagContainer()
PersistentDataHolder
API.
Please use PersistentDataHolder.getPersistentDataContainer()
instead of this.@Deprecated void setVersion(int version)
version
- version@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.ADVENTURE
canDestroy
- Set of materials@Deprecated Set<Material> getCanPlaceOn()
getPlaceableKeys()
as a replacementGameMode.ADVENTURE
@Deprecated void setCanPlaceOn(Set<Material> canPlaceOn)
setPlaceableKeys(Collection)
as a replacementGameMode.ADVENTURE
canPlaceOn
- Set of materials@NotNull Set<Namespaced> getDestroyableKeys()
GameMode.ADVENTURE
Namespaced
void setDestroyableKeys(@NotNull Collection<Namespaced> canDestroy)
GameMode.ADVENTURE
canDestroy
- Collection of Namespaced
@NotNull Set<Namespaced> getPlaceableKeys()
GameMode.ADVENTURE
Namespaced
@NotNull void setPlaceableKeys(@NotNull Collection<Namespaced> canPlaceOn)
GameMode.ADVENTURE
canPlaceOn
- Collection of Namespaced
boolean hasPlaceableKeys()
boolean hasDestroyableKeys()
Copyright © 2022. All rights reserved.