Package com.marcusslover.plus.lib.item
Class Item
java.lang.Object
com.marcusslover.plus.lib.common.Taggable<Item,org.bukkit.inventory.meta.ItemMeta>
com.marcusslover.plus.lib.item.Item
- All Implemented Interfaces:
IMetaContainer<Item,org.bukkit.inventory.meta.ItemMeta>
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription@NotNull ItemaddAttribute(@NotNull org.bukkit.attribute.Attribute attribute, @NotNull org.bukkit.attribute.AttributeModifier modifier) @NotNull ItemaddItemFlag(@NotNull org.bukkit.inventory.ItemFlag itemFlag) intamount()@NotNull Itemamount(int amount) Set the amount of the item.@NotNull ItemClears all enchantments from this item@NotNull Itemclone()@NotNull ItemChange the color of this item.@NotNull ItemChange the color of this item.@NotNull Itemcolor(@Nullable org.bukkit.Color color) Change the color of this item.@Nullable Integer@NotNull ItemcustomModelData(@Nullable Integer customModelData) @Nullable Integerdamage()@NotNull Itemdamage(double percent) Changes the amount of damage this item has as a percentage.@NotNull Itemdamage(int damage) Changes the amount of damage this item has as a value.@NotNull Itemdecrease()Decrement the number of items in the stack by 1.@NotNull Itemdecrease(int amount) Decrement the number of items in the stack by the specified amount.@NotNull ItemDecrement the number of items in the stack by 1.@NotNull Itemdecrement(int amount) Decrement the number of items in the stack by the specified amount.intenchant(@NotNull org.bukkit.enchantments.Enchantment enchantment) Get the level of the applied enchantment.@NotNull Itemenchant(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level) Add an enchantment to this item.enchants()boolean@NotNull org.bukkit.inventory.ItemStackget()@NotNull org.bukkit.persistence.PersistentDataContainer@NotNull Itemglow()@NotNull Itemglow(boolean glow) booleanbooleanhasEnchant(@NotNull org.bukkit.enchantments.Enchantment enchantment) booleanhasItemFlag(@NotNull org.bukkit.inventory.ItemFlag itemFlag) booleanhasLore()booleanhasName()@NotNull Item@NotNull ItemhideItemFlags(boolean hideflags) @NotNull ItemHides the tooltip of the item.@NotNull ItemhideTooltip(boolean hide) Hides the tooltip of the item.protected @NotNull Itemholder()@NotNull Itemincrease()Increment the number of items in the stack by 1.@NotNull Itemincrease(int amount) Increment the number of items in the stack by the specified amount.@NotNull ItemIncrement the number of items in the stack by 1.@NotNull Itemincrement(int amount) Increment the number of items in the stack by the specified amount.booleanChecks if the item can be colored.booleanisDyed()Checks if the item is dyed.booleanisEmpty()booleanChecks if the item tooltip is hidden.booleanbooleanisValid()@NotNull org.bukkit.inventory.ItemStackReturns the item stack.@NotNull ItemitemStack(@NotNull org.bukkit.inventory.ItemStack itemStack) lore()@NotNull Itemlore(@Nullable Collection<@NotNull String> lore) @NotNull Item@Nullable List<net.kyori.adventure.text.Component> Retrieves the lore components of the item.Retrieves the lore text from the item's metadata if it exists.@NotNull org.bukkit.Materialmaterial()@NotNull Itemmaterial(@NotNull org.bukkit.Material material) Change the material type used in this item.intmaxStack()@NotNull ItemmaxStack(int maxStack) Change the max stack size of this item.@Nullable org.bukkit.inventory.meta.ItemMetameta()@NotNull Item@NotNull Itemmeta(@NotNull org.bukkit.inventory.meta.ItemMeta meta) @Nullable Textname()@NotNull Item@NotNull Item@NotNull Itemname(@Nullable net.kyori.adventure.text.Component name) @Nullable net.kyori.adventure.text.ComponentRetrieves the display name component of the item's metadata if available.static @NotNull Itemof()static @NotNull ItemCreate an item from a compound string.static @NotNull Itemof(@NotNull org.bukkit.Material material) static @NotNull Itemof(@NotNull org.bukkit.Material material, int amount) static @NotNull Itemstatic @NotNull Itemof(@NotNull org.bukkit.Material material, int amount, @Nullable Text name, @Nullable List<@NotNull Text> lore) static @NotNull Itemstatic @NotNull Itemof(@NotNull org.bukkit.Material material, int amount, @Nullable String name, @Nullable List<@NotNull String> lore) static @NotNull Itemof(@Nullable org.bukkit.inventory.ItemStack itemStack) @NotNull ItemremoveAttribute(@NotNull org.bukkit.attribute.Attribute attribute) @NotNull ItemremoveAttribute(@NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot) @NotNull ItemremoveItemFlag(@NotNull org.bukkit.inventory.ItemFlag itemFlag) @NotNull ItemHacky fix for https://github.com/PaperMC/Paper/issues/10693 Sets the item attributes to an empty multimap.@NotNull Itemskull(@Nullable com.destroystokyo.paper.profile.PlayerProfile playerProfile) @NotNull ItemDeprecated, for removal: This API element is subject to removal in a future version.@NotNull Itemskull(@Nullable org.bukkit.OfflinePlayer player) @NotNull ItemskullMinecraftUrl(@NotNull String minecraftUrl) Set the skull texture of this item.@NotNull ItemskullValue(@NotNull String skullValue) Set the skull texture of this item.@NotNull org.bukkit.Materialtype()@NotNull Itemtype(@NotNull org.bukkit.Material material) Change the material type used in this item.boolean@NotNull Itemunbreakable(boolean unbreakable) @NotNull ItemwithType(@NotNull org.bukkit.Material material) Change the material type used in this item.
-
Field Details
-
itemStack
@NotNull protected @NotNull org.bukkit.inventory.ItemStack itemStack
-
-
Method Details
-
of
Create an item from a compound string.The input should match the same input as expected by Minecraft's
/givecommand. For example,"minecraft:diamond_sword[minecraft:enchantments={levels:{"minecraft:sharpness": 3}}]"would yield an ItemStack ofMaterial.DIAMOND_SWORDwith anItemMetacontaining a level 3Enchantment.SHARPNESSenchantment.- Parameters:
item- The compound string.- Returns:
- The item.
- Since:
- 4.3.0
-
of
@NotNull public static @NotNull Item of(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack) -
of
-
of
-
of
-
of
-
of
-
of
-
of
-
name
-
name
-
lore
-
lore
-
name
-
hasName
public boolean hasName() -
name
-
nameComponent
@Nullable public @Nullable net.kyori.adventure.text.Component nameComponent()Retrieves the display name component of the item's metadata if available.- Returns:
- the display name as a Component if the item metadata exists and has a display name, or null otherwise.
- Since:
- 4.4.0
-
lore
-
loreTexts
Retrieves the lore text from the item's metadata if it exists. The lore is a collection of additional text associated with the item.- Returns:
- A list of
Textobjects representing the lore if present, or null if the item has no metadata, no lore, or the lore is empty. - Since:
- 4.4.0
-
loreComponents
Retrieves the lore components of the item. If the item meta is null or does not contain lore, an empty list is returned.- Returns:
- a list of lore
Componentobjects, or an empty list if no lore is present or item meta is null - Since:
- 4.4.0
-
hasLore
public boolean hasLore() -
isEmpty
public boolean isEmpty() -
isValid
public boolean isValid() -
type
@NotNull public @NotNull org.bukkit.Material type()- Returns:
- the material type of this item
-
isPresent
public boolean isPresent() -
maxStack
public int maxStack()- Returns:
- the max item stack of the item or a
-
maxStack
Change the max stack size of this item.- Parameters:
maxStack- the max stack size of this item- Returns:
- this item
-
material
@NotNull public @NotNull org.bukkit.Material material()- Returns:
- the material type of this item
-
material
Change the material type used in this item.- Parameters:
material- the material type of this item- Returns:
- this item
-
type
Change the material type used in this item.- Parameters:
material- the material type of this item- Returns:
- this item
-
withType
Change the material type used in this item. IMPORTANT: This method creates a new item with the specified material.- Parameters:
material- the material type of this item- Returns:
- brand-new item
-
increment
Increment the number of items in the stack by 1.- Returns:
- the item
-
increase
Increment the number of items in the stack by 1.- Returns:
- the item
-
increase
Increment the number of items in the stack by the specified amount.- Parameters:
amount- the amount to increment by- Returns:
- the item
-
amount
Set the amount of the item.- Parameters:
amount- the amount items in the stack- Returns:
- the item
-
amount
public int amount()- Returns:
- the number of items in the stack
-
increment
Increment the number of items in the stack by the specified amount.- Parameters:
amount- the amount to increment by- Returns:
- the item
-
decrement
Decrement the number of items in the stack by 1.- Returns:
- the item
-
decrease
Decrement the number of items in the stack by 1.- Returns:
- the item
-
decrease
Decrement the number of items in the stack by the specified amount.- Parameters:
amount- the amount to decrement by- Returns:
- the item
-
decrement
Decrement the number of items in the stack by the specified amount.- Parameters:
amount- the amount to decrement by- Returns:
- the item
-
damage
Changes the amount of damage this item has as a percentage.- Parameters:
percent- 0.0 - 1.0- Returns:
- this item
-
damage
- Returns:
- the amount of damage this item has as a value.
-
damage
Changes the amount of damage this item has as a value.- Parameters:
damage- item damage- Returns:
- this item
-
enchant
@NotNull public @NotNull Item enchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level) Add an enchantment to this item.- Parameters:
enchantment- enchantmentlevel- the level of the enchantment. If the level is 0, the enchantment will be removed.- Returns:
- this item
-
clearEnchants
Clears all enchantments from this item- Returns:
- this item
-
enchants
- Returns:
- a map of all the enchantments on this item
-
hasEnchant
public boolean hasEnchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment) -
enchant
public int enchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment) Get the level of the applied enchantment.- Parameters:
enchantment- enchantment- Returns:
- enchantment level
-
glow
-
glow
-
hideTooltip
Hides the tooltip of the item.- Returns:
- This item.
- Since:
- 4.3.0
-
hideTooltip
Hides the tooltip of the item.- Parameters:
hide- True to hide the tooltip, false otherwise.- Returns:
- This item.
- Since:
- 4.3.0
-
isHideTooltip
public boolean isHideTooltip()Checks if the item tooltip is hidden.- Returns:
- True if the item tooltip is hidden, false otherwise.
- Since:
- 4.3.0
-
isColorable
public boolean isColorable()Checks if the item can be colored.- Returns:
- True if the item can be colored, false otherwise.
-
meta
@Nullable public @Nullable org.bukkit.inventory.meta.ItemMeta meta() -
meta
-
meta
-
isDyed
public boolean isDyed()Checks if the item is dyed.- Returns:
- True if the item is dyed, false otherwise.
- Since:
- 4.3.0
-
color
Change the color of this item.- Parameters:
hex- The hex color code e.g. #FF0000.- Returns:
- This item.
- See Also:
-
color
Change the color of this item.- Parameters:
plusColor- The color.- Returns:
- This item.
- See Also:
-
color
Change the color of this item. Works withMaterial.POTION,Material.SPLASH_POTION,Material.LINGERING_POTION,Material.TIPPED_ARROW,Material.LEATHER_HELMET,Material.LEATHER_CHESTPLATE,Material.LEATHER_LEGGINGS,Material.LEATHER_BOOTS,Material.LEATHER_HORSE_ARMOR,Material.WOLF_ARMORand colored maps.- Parameters:
color- The color.- Returns:
- This item.
-
addAttribute
@NotNull public @NotNull Item addAttribute(@NotNull @NotNull org.bukkit.attribute.Attribute attribute, @NotNull @NotNull org.bukkit.attribute.AttributeModifier modifier) -
removeAttribute
@NotNull public @NotNull Item removeAttribute(@NotNull @NotNull org.bukkit.attribute.Attribute attribute) -
removeAttribute
@NotNull public @NotNull Item removeAttribute(@NotNull @NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot) -
addItemFlag
-
removeItemFlag
@NotNull public @NotNull Item removeItemFlag(@NotNull @NotNull org.bukkit.inventory.ItemFlag itemFlag) -
hasItemFlag
public boolean hasItemFlag(@NotNull @NotNull org.bukkit.inventory.ItemFlag itemFlag) -
setEmptyItemAttributes
Hacky fix for https://github.com/PaperMC/Paper/issues/10693 Sets the item attributes to an empty multimap.- Returns:
- this item
- Since:
- 4.4.0
-
hideItemFlags
-
hideItemFlags
-
unbreakable
public boolean unbreakable()- Returns:
- whether the item is breakable or not.
-
unbreakable
- Parameters:
unbreakable- whether the item is breakable or not.- Returns:
- this item.
-
getPersistentDataContainer
@NotNull public @NotNull org.bukkit.persistence.PersistentDataContainer getPersistentDataContainer() -
hasCustomModelData
public boolean hasCustomModelData() -
customModelData
-
customModelData
-
skull
@NotNull public @NotNull Item skull(@Nullable @Nullable com.destroystokyo.paper.profile.PlayerProfile playerProfile) -
skull
-
skullValue
Set the skull texture of this item. Example: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODNjMjVhN2ExODgxOTZiMTg3MTcyNjRmZmU4MzdjYTM0OGNmNzE5ZTgyNzE3OWVkYzRiNzhjYmNiOGM3ZGQ4In19fQ==- Parameters:
skullValue- the skull texture- Returns:
- this item
-
skullMinecraftUrl
Set the skull texture of this item. Example: 83c25a7a188196b18717264ffe837ca348cf719e827179edc4b78cbcb8c7dd8- Parameters:
minecraftUrl- the minecraft url- Returns:
- this item
-
skull
Deprecated, for removal: This API element is subject to removal in a future version. -
get
@NotNull public @NotNull org.bukkit.inventory.ItemStack get() -
itemStack
@NotNull public @NotNull org.bukkit.inventory.ItemStack itemStack()Returns the item stack.- Returns:
- The item stack.
- Since:
- 4.3.0
-
itemStack
-
equals
-
clone
-
holder
-