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>

public class Item extends Taggable<Item,org.bukkit.inventory.meta.ItemMeta>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected @NotNull org.bukkit.inventory.ItemStack
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Item
    addAttribute(@NotNull org.bukkit.attribute.Attribute attribute, @NotNull org.bukkit.attribute.AttributeModifier modifier)
     
    @NotNull Item
    addItemFlag(@NotNull org.bukkit.inventory.ItemFlag itemFlag)
     
    int
     
    @NotNull Item
    amount(int amount)
    Set the amount of the item.
    @NotNull Item
    Clears all enchantments from this item
    @NotNull Item
     
    @NotNull Item
    color(Color plusColor)
    Change the color of this item.
    @NotNull Item
    color(@Nullable String hex)
    Change the color of this item.
    @NotNull Item
    color(@Nullable org.bukkit.Color color)
    Change the color of this item.
    @Nullable Integer
     
    @NotNull Item
    customModelData(@Nullable Integer customModelData)
     
    @Nullable Integer
     
    @NotNull Item
    damage(double percent)
    Changes the amount of damage this item has as a percentage.
    @NotNull Item
    damage(int damage)
    Changes the amount of damage this item has as a value.
    @NotNull Item
    Decrement the amount of items in the stack by 1.
    @NotNull Item
    decrease(int amount)
    Decrement the amount of items in the stack by the specified amount.
    @NotNull Item
    Decrement the amount of items in the stack by 1.
    @NotNull Item
    decrement(int amount)
    Decrement the amount of items in the stack by the specified amount.
    int
    enchant(@NotNull org.bukkit.enchantments.Enchantment enchantment)
    Get the level of the applied enchantment.
    @NotNull Item
    enchant(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level)
    Add an enchantment to this item.
    @NotNull Map<org.bukkit.enchantments.Enchantment,Integer>
     
    boolean
     
    @NotNull org.bukkit.inventory.ItemStack
    get()
     
    @NotNull org.bukkit.persistence.PersistentDataContainer
     
    @NotNull Item
     
    @NotNull Item
    glow(boolean glow)
     
    boolean
     
    boolean
    hasEnchant(@NotNull org.bukkit.enchantments.Enchantment enchantment)
     
    boolean
    hasItemFlag(@NotNull org.bukkit.inventory.ItemFlag itemFlag)
     
    boolean
     
    boolean
     
    @NotNull Item
     
    @NotNull Item
    hideItemFlags(boolean hideflags)
     
    @NotNull Item
    Hides the tooltip of the item.
    @NotNull Item
    hideTooltip(boolean hide)
    Hides the tooltip of the item.
    protected @NotNull Item
     
    @NotNull Item
    Increment the amount of items in the stack by 1.
    @NotNull Item
    increase(int amount)
    Increment the amount of items in the stack by the specified amount.
    @NotNull Item
    Increment the amount of items in the stack by 1.
    @NotNull Item
    increment(int amount)
    Increment the amount of items in the stack by the specified amount.
    boolean
    Checks if the item can be colored.
    boolean
    Checks if the item is dyed.
    boolean
     
    boolean
    Checks if the item tooltip is hidden.
    boolean
     
    boolean
     
    @NotNull org.bukkit.inventory.ItemStack
    Returns the item stack.
    @NotNull Item
    itemStack(@NotNull org.bukkit.inventory.ItemStack itemStack)
     
    @NotNull List<@NotNull String>
     
    @NotNull Item
    lore(@Nullable Collection<@NotNull String> lore)
     
    @NotNull Item
    lore(@Nullable List<? extends net.kyori.adventure.text.Component> lore)
     
    @NotNull org.bukkit.Material
     
    @NotNull Item
    material(@NotNull org.bukkit.Material material)
    Change the material type used in this item.
    int
     
    @NotNull Item
    maxStack(int maxStack)
    Change the max stack size of this item.
    @Nullable org.bukkit.inventory.meta.ItemMeta
     
    @NotNull Item
    meta(@NotNull Consumer<@NotNull org.bukkit.inventory.meta.ItemMeta> meta)
     
    @NotNull Item
    meta(@NotNull org.bukkit.inventory.meta.ItemMeta meta)
     
    @Nullable Text
     
    @NotNull Item
    name(@Nullable Text name)
     
    @NotNull Item
    name(@Nullable String name)
     
    @NotNull Item
    name(@Nullable net.kyori.adventure.text.Component name)
     
    static @NotNull Item
    of()
     
    static @NotNull Item
    of(@NotNull String item)
    Create an item from a compound string.
    static @NotNull Item
    of(@NotNull org.bukkit.Material material)
     
    static @NotNull Item
    of(@NotNull org.bukkit.Material material, int amount)
     
    static @NotNull Item
    of(@NotNull org.bukkit.Material material, int amount, @Nullable Text name)
     
    static @NotNull Item
    of(@NotNull org.bukkit.Material material, int amount, @Nullable Text name, @Nullable List<@NotNull Text> lore)
     
    static @NotNull Item
    of(@NotNull org.bukkit.Material material, int amount, @Nullable String name)
     
    static @NotNull Item
    of(@NotNull org.bukkit.Material material, int amount, @Nullable String name, @Nullable List<@NotNull String> lore)
     
    static @NotNull Item
    of(@Nullable org.bukkit.inventory.ItemStack itemStack)
     
    @NotNull Item
    removeAttribute(@NotNull org.bukkit.attribute.Attribute attribute)
     
    @NotNull Item
    removeAttribute(@NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot)
     
    @NotNull Item
    removeItemFlag(@NotNull org.bukkit.inventory.ItemFlag itemFlag)
     
    @NotNull Item
    skull(@Nullable com.destroystokyo.paper.profile.PlayerProfile playerProfile)
     
    @NotNull Item
    skull(@NotNull String url)
    Deprecated, for removal: This API element is subject to removal in a future version.
    @NotNull Item
    skull(@Nullable org.bukkit.OfflinePlayer player)
     
    @NotNull Item
    skullMinecraftUrl(@NotNull String minecraftUrl)
    Set the skull texture of this item.
    @NotNull Item
    skullValue(@NotNull String skullValue)
    Set the skull texture of this item.
    @NotNull org.bukkit.Material
     
    @NotNull Item
    type(@NotNull org.bukkit.Material material)
    Change the material type used in this item.
    boolean
     
    @NotNull Item
    unbreakable(boolean unbreakable)
     
    @NotNull Item
    withType(@NotNull org.bukkit.Material material)
    Change the material type used in this item.

    Methods inherited from class com.marcusslover.plus.lib.common.Taggable

    getTag, hasTag, removeTag, setTag, tag, tag, tagHolder

    Methods inherited from class java.lang.Object

    finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • itemStack

      @NotNull protected @NotNull org.bukkit.inventory.ItemStack itemStack
  • Method Details

    • name

      @NotNull public @NotNull Item name(@Nullable @Nullable Text name)
    • name

      @NotNull public @NotNull Item name(@Nullable @Nullable net.kyori.adventure.text.Component name)
    • lore

      @NotNull public @NotNull Item lore(@Nullable @Nullable Collection<@NotNull String> lore)
    • lore

      @NotNull public @NotNull Item lore(@Nullable @Nullable List<? extends net.kyori.adventure.text.Component> lore)
    • name

      @NotNull public @NotNull Item name(@Nullable @Nullable String name)
    • of

      @NotNull public static @NotNull Item of(@NotNull @NotNull String item)
      Create an item from a compound string.

      The input should match the same input as expected by Minecraft's /give command. For example,

      "minecraft:diamond_sword[minecraft:enchantments={levels:{"minecraft:sharpness": 3}}]"
      would yield an ItemStack of Material.DIAMOND_SWORD with an ItemMeta containing a level 3 Enchantment.SHARPNESS enchantment.
      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

      @NotNull public static @NotNull Item of()
    • of

      @NotNull public static @NotNull Item of(@NotNull @NotNull org.bukkit.Material material)
    • of

      @NotNull public static @NotNull Item of(@NotNull @NotNull org.bukkit.Material material, int amount)
    • of

      @NotNull public static @NotNull Item of(@NotNull @NotNull org.bukkit.Material material, int amount, @Nullable @Nullable Text name)
    • of

      @NotNull public static @NotNull Item of(@NotNull @NotNull org.bukkit.Material material, int amount, @Nullable @Nullable Text name, @Nullable @Nullable List<@NotNull Text> lore)
    • of

      @NotNull public static @NotNull Item of(@NotNull @NotNull org.bukkit.Material material, int amount, @Nullable @Nullable String name)
    • of

      @NotNull public static @NotNull Item of(@NotNull @NotNull org.bukkit.Material material, int amount, @Nullable @Nullable String name, @Nullable @Nullable List<@NotNull String> lore)
    • 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

      @NotNull public @NotNull Item maxStack(int 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

      @NotNull public @NotNull Item material(@NotNull @NotNull org.bukkit.Material material)
      Change the material type used in this item.
      Parameters:
      material - the material type of this item
      Returns:
      this item
    • type

      @NotNull public @NotNull Item type(@NotNull @NotNull org.bukkit.Material material)
      Change the material type used in this item.
      Parameters:
      material - the material type of this item
      Returns:
      this item
    • withType

      @NotNull public @NotNull Item withType(@NotNull @NotNull org.bukkit.Material material)
      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

      @NotNull public @NotNull Item increment()
      Increment the amount of items in the stack by 1.
      Returns:
      the item
    • increase

      @NotNull public @NotNull Item increase()
      Increment the amount of items in the stack by 1.
      Returns:
      the item
    • increase

      @NotNull public @NotNull Item increase(int amount)
      Increment the amount of items in the stack by the specified amount.
      Parameters:
      amount - the amount to increment by
      Returns:
      the item
    • amount

      @NotNull public @NotNull Item amount(int amount)
      Set the amount of the item.
      Parameters:
      amount - the amount items in the stack
      Returns:
      the item
    • amount

      public int amount()
      Returns:
      the amount of items in the stack
    • increment

      @NotNull public @NotNull Item increment(int amount)
      Increment the amount of items in the stack by the specified amount.
      Parameters:
      amount - the amount to increment by
      Returns:
      the item
    • decrement

      @NotNull public @NotNull Item decrement()
      Decrement the amount of items in the stack by 1.
      Returns:
      the item
    • decrease

      @NotNull public @NotNull Item decrease()
      Decrement the amount of items in the stack by 1.
      Returns:
      the item
    • decrease

      @NotNull public @NotNull Item decrease(int amount)
      Decrement the amount of items in the stack by the specified amount.
      Parameters:
      amount - the amount to decrement by
      Returns:
      the item
    • decrement

      @NotNull public @NotNull Item decrement(int amount)
      Decrement the amount of items in the stack by the specified amount.
      Parameters:
      amount - the amount to decrement by
      Returns:
      the item
    • damage

      @NotNull public @NotNull Item damage(double percent)
      Changes the amount of damage this item has as a percentage.
      Parameters:
      percent - 0.0 - 1.0
      Returns:
      this item
    • damage

      @Nullable public @Nullable Integer damage()
      Returns:
      the amount of damage this item has as a value.
    • damage

      @NotNull public @NotNull Item damage(int 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 - enchantment
      level - the level of the enchantment. If the level is 0, the enchantment will be removed.
      Returns:
      this item
    • clearEnchants

      @NotNull public @NotNull Item clearEnchants()
      Clears all enchantments from this item
      Returns:
      this item
    • enchants

      @NotNull public @NotNull Map<org.bukkit.enchantments.Enchantment,Integer> 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

      @NotNull public @NotNull Item glow()
    • glow

      @NotNull public @NotNull Item glow(boolean glow)
    • hideTooltip

      @NotNull public @NotNull Item hideTooltip()
      Hides the tooltip of the item.
      Returns:
      This item.
      Since:
      4.3.0
    • hideTooltip

      @NotNull public @NotNull Item hideTooltip(boolean hide)
      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

      @NotNull public @NotNull Item meta(@NotNull @NotNull org.bukkit.inventory.meta.ItemMeta meta)
    • meta

      @NotNull public @NotNull Item meta(@NotNull @NotNull Consumer<@NotNull org.bukkit.inventory.meta.ItemMeta> 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

      @NotNull public @NotNull Item color(@Nullable @Nullable String hex)
      Change the color of this item.
      Parameters:
      hex - The hex color code e.g. #FF0000.
      Returns:
      This item.
      See Also:
    • color

      @NotNull public @NotNull Item color(@Nullable Color plusColor)
      Change the color of this item.
      Parameters:
      plusColor - The color.
      Returns:
      This item.
      See Also:
    • color

      @NotNull public @NotNull Item color(@Nullable @Nullable org.bukkit.Color color)
      Change the color of this item. Works with Material.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_ARMOR and 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

      @NotNull public @NotNull Item addItemFlag(@NotNull @NotNull org.bukkit.inventory.ItemFlag itemFlag)
    • removeItemFlag

      @NotNull public @NotNull Item removeItemFlag(@NotNull @NotNull org.bukkit.inventory.ItemFlag itemFlag)
    • hasItemFlag

      public boolean hasItemFlag(@NotNull @NotNull org.bukkit.inventory.ItemFlag itemFlag)
    • hideItemFlags

      @NotNull public @NotNull Item hideItemFlags()
    • hideItemFlags

      @NotNull public @NotNull Item hideItemFlags(boolean hideflags)
    • unbreakable

      public boolean unbreakable()
      Returns:
      whether the item is breakable or not.
    • unbreakable

      @NotNull public @NotNull Item unbreakable(boolean 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

      @Nullable public @Nullable Integer customModelData()
    • customModelData

      @NotNull public @NotNull Item customModelData(@Nullable @Nullable Integer customModelData)
    • hasName

      public boolean hasName()
    • name

      @Nullable public @Nullable Text name()
    • lore

      @NotNull public @NotNull List<@NotNull String> lore()
    • hasLore

      public boolean hasLore()
    • skull

      @NotNull public @NotNull Item skull(@Nullable @Nullable com.destroystokyo.paper.profile.PlayerProfile playerProfile)
    • skull

      @NotNull public @NotNull Item skull(@Nullable @Nullable org.bukkit.OfflinePlayer player)
    • skullValue

      @NotNull public @NotNull Item skullValue(@NotNull @NotNull String skullValue)
      Set the skull texture of this item. Example: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODNjMjVhN2ExODgxOTZiMTg3MTcyNjRmZmU4MzdjYTM0OGNmNzE5ZTgyNzE3OWVkYzRiNzhjYmNiOGM3ZGQ4In19fQ==
      Parameters:
      skullValue - the skull texture
      Returns:
      this item
    • skullMinecraftUrl

      @NotNull public @NotNull Item skullMinecraftUrl(@NotNull @NotNull String minecraftUrl)
      Set the skull texture of this item. Example: 83c25a7a188196b18717264ffe837ca348cf719e827179edc4b78cbcb8c7dd8
      Parameters:
      minecraftUrl - the minecraft url
      Returns:
      this item
    • skull

      @Deprecated(forRemoval=true) @NotNull public @NotNull Item skull(@NotNull @NotNull String url)
      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

      @NotNull public @NotNull Item itemStack(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • clone

      @NotNull public @NotNull Item clone()
      Overrides:
      clone in class Object
    • holder

      @NotNull protected @NotNull Item holder()
      Specified by:
      holder in class Taggable<Item,org.bukkit.inventory.meta.ItemMeta>