Class ItemSpec

java.lang.Object
com.ultikits.ultitools.item.ItemSpec

public final class ItemSpec extends Object
Deeply immutable and thread-safe provided pass-through values are immutable (see ItemSpec.Builder.data(DataComponentType.Valued, Object)); equals/hashCode compare every attribute, including marker values by content, and the GUI diff relies on it. An ItemRenderer renders its name and lore once the viewer's locale is known; Paper does not translate item text per client.

Building from a Key with amount, text, model, glint, tooltip flags and markers needs no running server; builder(Material) and any DataComponentType argument need Paper's registries (a server or MockBukkit).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A non-thread-safe builder; repeated builds produce independent immutable descriptions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
     
    private final @Nullable Boolean
     
    private final Set<io.papermc.paper.datacomponent.DataComponentType>
     
    private final Set<org.bukkit.NamespacedKey>
     
    private final net.kyori.adventure.key.Key
     
    private final List<Text>
     
    private final List<ItemMarker<?,?>>
     
    private final @Nullable net.kyori.adventure.key.Key
     
    private final @Nullable Text
     
    private final List<DataPatch>
     
    private final boolean
     
    private static final Set<String>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the amount, in 1..99.
    builder(net.kyori.adventure.key.Key itemType)
    Returns a builder for the item key, initially with amount 1.
    builder(org.bukkit.Material material)
    Shorthand for builder(material.getKey()).
    boolean
    Compares all attributes, including the order of patches and markers.
    @Nullable Boolean
    Returns ENCHANTMENT_GLINT_OVERRIDE, or absent for the item's default.
    int
    Returns a hash of every attribute.
    Set<io.papermc.paper.datacomponent.DataComponentType>
    Components whose tooltip lines are hidden (TOOLTIP_DISPLAY hiddenComponents); unmodifiable, may be empty.
    net.kyori.adventure.key.Key
    Returns the registry key of the item to create.
    Returns unmodifiable lore; empty means no LORE component is set.
    Returns unmodifiable persistent-data markers in insertion order.
    @Nullable net.kyori.adventure.key.Key
    Returns ITEM_MODEL, or absent.
    @Nullable Text
    Returns text for ITEM_NAME (the non-italic default name), or absent.
    Returns unmodifiable pass-through changes in insertion order.
    Returns a builder initialized with every attribute of this description.
    boolean
    Returns whether TOOLTIP_DISPLAY hides the entire tooltip.
    Returns every attribute for diagnostics.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • TYPED_COMPONENTS

      private static final Set<String> TYPED_COMPONENTS
    • itemType

      private final net.kyori.adventure.key.Key itemType
    • amount

      private final int amount
    • name

      @Nullable private final @Nullable Text name
    • lore

      private final List<Text> lore
    • model

      @Nullable private final @Nullable net.kyori.adventure.key.Key model
    • glint

      @Nullable private final @Nullable Boolean glint
    • tooltipHidden

      private final boolean tooltipHidden
    • hiddenInTooltip

      private final Set<io.papermc.paper.datacomponent.DataComponentType> hiddenInTooltip
    • hiddenTooltipKeys

      private final Set<org.bukkit.NamespacedKey> hiddenTooltipKeys
    • patches

      private final List<DataPatch> patches
    • markers

      private final List<ItemMarker<?,?>> markers
  • Constructor Details

  • Method Details

    • builder

      public static ItemSpec.Builder builder(net.kyori.adventure.key.Key itemType)
      Returns a builder for the item key, initially with amount 1.
      Throws:
      IllegalArgumentException - for minecraft:air
    • builder

      public static ItemSpec.Builder builder(org.bukkit.Material material)
      Shorthand for builder(material.getKey()).
      Throws:
      IllegalArgumentException - if the material is AIR or is not an item
    • itemType

      public net.kyori.adventure.key.Key itemType()
      Returns the registry key of the item to create.
    • amount

      public int amount()
      Returns the amount, in 1..99.
    • name

      @Nullable public @Nullable Text name()
      Returns text for ITEM_NAME (the non-italic default name), or absent.
    • lore

      public List<Text> lore()
      Returns unmodifiable lore; empty means no LORE component is set.
    • model

      @Nullable public @Nullable net.kyori.adventure.key.Key model()
      Returns ITEM_MODEL, or absent.
    • glint

      @Nullable public @Nullable Boolean glint()
      Returns ENCHANTMENT_GLINT_OVERRIDE, or absent for the item's default.
    • tooltipHidden

      public boolean tooltipHidden()
      Returns whether TOOLTIP_DISPLAY hides the entire tooltip.
    • hiddenInTooltip

      public Set<io.papermc.paper.datacomponent.DataComponentType> hiddenInTooltip()
      Components whose tooltip lines are hidden (TOOLTIP_DISPLAY hiddenComponents); unmodifiable, may be empty.
    • patches

      public List<DataPatch> patches()
      Returns unmodifiable pass-through changes in insertion order.
    • markers

      public List<ItemMarker<?,?>> markers()
      Returns unmodifiable persistent-data markers in insertion order.
    • toBuilder

      public ItemSpec.Builder toBuilder()
      Returns a builder initialized with every attribute of this description.
    • equals

      public boolean equals(Object o)
      Compares all attributes, including the order of patches and markers.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns a hash of every attribute.
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Returns every attribute for diagnostics.
      Overrides:
      toString in class Object