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 | Method and Description |
---|---|
boolean |
addAttributeModifier(@NotNull Attribute attribute,
@NotNull AttributeModifier modifier)
Add an Attribute and it's Modifier.
|
boolean |
addEnchant(@NotNull 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.
|
@NotNull ItemMeta |
clone() |
net.kyori.adventure.text.Component |
displayName()
Gets the display name.
|
void |
displayName(net.kyori.adventure.text.Component displayName)
Sets the display name.
|
@Nullable Multimap<Attribute,AttributeModifier> |
getAttributeModifiers()
Return an immutable copy of all Attributes and
their modifiers in this ItemMeta.
Returns null if none exist. |
@Nullable Collection<AttributeModifier> |
getAttributeModifiers(@NotNull Attribute attribute)
Return an immutable copy of all
AttributeModifier s
for a given Attribute |
@NotNull Multimap<Attribute,AttributeModifier> |
getAttributeModifiers(@NotNull 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.
|
@NotNull CustomItemTagContainer |
getCustomTagContainer()
Deprecated.
this API part has been replaced by the
PersistentDataHolder API.
Please use PersistentDataHolder.getPersistentDataContainer() instead of this. |
@NotNull Set<Namespaced> |
getDestroyableKeys()
Gets the collection of namespaced keys that the item can destroy in
GameMode.ADVENTURE |
@NotNull String |
getDisplayName()
Deprecated.
in favour of
displayName() |
BaseComponent[] |
getDisplayNameComponent()
Deprecated.
use
displayName() |
int |
getEnchantLevel(@NotNull Enchantment ench)
Checks for the level of the specified enchantment.
|
@NotNull Map<Enchantment,Integer> |
getEnchants()
Returns a copy the enchantments in this ItemMeta.
|
@NotNull Set<ItemFlag> |
getItemFlags()
Get current set itemFlags.
|
@NotNull String |
getLocalizedName()
Gets the localized display name that is set.
|
@Nullable List<String> |
getLore()
Deprecated.
in favour of
lore() |
@Nullable List<BaseComponent[]> |
getLoreComponents()
Deprecated.
use
lore() |
@NotNull 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(@NotNull 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(@NotNull Enchantment ench)
Checks for existence of the specified enchantment.
|
boolean |
hasEnchants()
Checks for the existence of any enchantments.
|
boolean |
hasItemFlag(@NotNull 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.
|
@Nullable List<net.kyori.adventure.text.Component> |
lore()
Gets the lore.
|
void |
lore(@Nullable List<net.kyori.adventure.text.Component> lore)
Sets the lore.
|
boolean |
removeAttributeModifier(@NotNull Attribute attribute)
Remove all
AttributeModifier s associated with the given
Attribute . |
boolean |
removeAttributeModifier(@NotNull Attribute attribute,
@NotNull AttributeModifier modifier)
Remove a specific
Attribute and AttributeModifier . |
boolean |
removeAttributeModifier(@NotNull 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(@NotNull Enchantment ench)
Removes the specified enchantment from this item meta.
|
void |
removeItemFlags(ItemFlag... itemFlags)
Remove specific set of itemFlags.
|
void |
setAttributeModifiers(@Nullable 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(@Nullable Integer data)
Sets the custom model data.
|
void |
setDestroyableKeys(@NotNull Collection<Namespaced> canDestroy)
Sets the collection of namespaced keys that the item can destroy in
GameMode.ADVENTURE |
void |
setDisplayName(@Nullable String name)
Deprecated.
in favour of
displayName(net.kyori.adventure.text.Component) |
void |
setDisplayNameComponent(BaseComponent[] component)
Deprecated.
|
void |
setLocalizedName(@Nullable String name)
Sets the localized name.
|
void |
setLore(@Nullable List<String> lore)
Deprecated.
in favour of
lore(List) |
void |
setLoreComponents(@Nullable List<BaseComponent[]> lore)
Deprecated.
use
lore(List) |
void |
setPlaceableKeys(@NotNull 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.
internal use only
|
serialize
getPersistentDataContainer
boolean hasDisplayName()
@Nullable net.kyori.adventure.text.Component displayName()
Plugins should check that hasDisplayName()
returns true
before calling this method.
void displayName(@Nullable net.kyori.adventure.text.Component displayName)
displayName
- the display name to set@Deprecated @NotNull @NotNull String getDisplayName()
displayName()
Plugins should check that hasDisplayName() returns true
before calling this method.
@NotNull @Deprecated BaseComponent[] getDisplayNameComponent()
displayName()
Plugins should check that hasDisplayName() returns true
before calling this method.
@Deprecated void setDisplayName(@Nullable @Nullable String name)
displayName(net.kyori.adventure.text.Component)
name
- the name to set@Deprecated void setDisplayNameComponent(@Nullable BaseComponent[] component)
displayName(Component)
component
- the name component to setboolean hasLocalizedName()
@NotNull @NotNull String getLocalizedName()
Plugins should check that hasLocalizedName() returns true
before calling this method.
void setLocalizedName(@Nullable @Nullable String name)
name
- the name to setboolean hasLore()
@Nullable @Nullable List<net.kyori.adventure.text.Component> lore()
Plugins should check that hasLore()
returns true
before calling this method.
void lore(@Nullable @Nullable List<net.kyori.adventure.text.Component> lore)
lore
- the lore to set@Deprecated @Nullable @Nullable List<String> getLore()
lore()
Plugins should check if hasLore() returns true
before
calling this method.
@Nullable @Deprecated @Nullable List<BaseComponent[]> getLoreComponents()
lore()
Plugins should check if hasLore() returns true
before
calling this method.
@Deprecated void setLore(@Nullable @Nullable List<String> lore)
lore(List)
lore
- the lore that will be set@Deprecated void setLoreComponents(@Nullable @Nullable List<BaseComponent[]> lore)
lore(List)
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 @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 @NotNull Enchantment ench)
ench
- enchantment to checkint getEnchantLevel(@NotNull @NotNull Enchantment ench)
ench
- enchantment to check@NotNull @NotNull Map<Enchantment,Integer> getEnchants()
boolean addEnchant(@NotNull @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 @NotNull Enchantment ench)
ench
- Enchantment to removeboolean hasConflictingEnchant(@NotNull @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 @NotNull Set<ItemFlag> getItemFlags()
boolean hasItemFlag(@NotNull @NotNull ItemFlag flag)
flag
- the flag to checkboolean isUnbreakable()
void setUnbreakable(boolean unbreakable)
unbreakable
- true if set unbreakableboolean hasAttributeModifiers()
@Nullable @Nullable Multimap<Attribute,AttributeModifier> getAttributeModifiers()
Multimap
of Attributes
and their AttributeModifiers, or null if none exist@NotNull @NotNull Multimap<Attribute,AttributeModifier> getAttributeModifiers(@NotNull @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 @Nullable Collection<AttributeModifier> getAttributeModifiers(@NotNull @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 @NotNull Attribute attribute, @NotNull @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 @Nullable 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 @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 @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 @NotNull Attribute attribute, @NotNull @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 @NotNull CustomItemTagContainer getCustomTagContainer()
PersistentDataHolder
API.
Please use PersistentDataHolder.getPersistentDataContainer()
instead of this.@Deprecated void setVersion(int version)
version
- version@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 @NotNull Set<Namespaced> getDestroyableKeys()
GameMode.ADVENTURE
Namespaced
void setDestroyableKeys(@NotNull @NotNull Collection<Namespaced> canDestroy)
GameMode.ADVENTURE
canDestroy
- Collection of Namespaced
@NotNull @NotNull Set<Namespaced> getPlaceableKeys()
GameMode.ADVENTURE
Namespaced
@NotNull void setPlaceableKeys(@NotNull @NotNull Collection<Namespaced> canPlaceOn)
GameMode.ADVENTURE
canPlaceOn
- Collection of Namespaced
boolean hasPlaceableKeys()
boolean hasDestroyableKeys()
Copyright © 2021. All rights reserved.