Class SpecialItem

java.lang.Object
dev.despical.fileitems.SpecialItem

public final class SpecialItem extends Object
Author:
Despical

Created at 17.09.2024

  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull ItemBuilder
    Creates a new ItemBuilder initialized with this item's stack.
    boolean
    equals(@Nullable org.bukkit.inventory.ItemStack item)
    Checks if a Bukkit ItemStack matches this SpecialItem based on material type, display name, and lore.
    <T> Optional<T>
    findCustomKey(@NotNull String key)
    Returns an Optional containing the value mapped to the specified key, or an empty Optional if no mapping exists.
    <T> T
    getCustomKey(@NotNull String key)
    Returns the value to which the specified key is mapped, or null if the custom keys map contains no mapping for the key.
    @NotNull org.bukkit.inventory.ItemStack
    Retrieves a clone of the underlying ItemStack.
    @NotNull String
    Gets the unique key identifier for this special item.
    @NotNull org.bukkit.inventory.ItemStack
    Retrieves the original underlying ItemStack.
    void
    giveTo(org.bukkit.entity.Player player, int slot)
    Stores the ItemStack of this SpecialItem instance at the given slot index of the given player's inventory.
    void
    giveTo(org.bukkit.entity.Player player, String key)
    Retrieves the slot index associated with the given custom key and stores the ItemStack of this SpecialItem instance in that slot of the specified player's inventory.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getItemStack

      @NotNull public @NotNull org.bukkit.inventory.ItemStack getItemStack()
      Retrieves a clone of the underlying ItemStack.

      Modifying the returned stack will not affect the stored item.

      Returns:
      a clone of the stored ItemStack
    • getOriginalItemStack

      @NotNull public @NotNull org.bukkit.inventory.ItemStack getOriginalItemStack()
      Retrieves the original underlying ItemStack.

      Note: Modifying this stack will directly affect the stored item.

      Returns:
      the original ItemStack
    • asItemBuilder

      @NotNull public @NotNull ItemBuilder asItemBuilder()
      Creates a new ItemBuilder initialized with this item's stack.
      Returns:
      a new ItemBuilder wrapping the item stack
    • getKey

      @NotNull public @NotNull String getKey()
      Gets the unique key identifier for this special item.
      Returns:
      the unique key string
    • giveTo

      public void giveTo(org.bukkit.entity.Player player, int slot)
      Stores the ItemStack of this SpecialItem instance at the given slot index of the given player's inventory.
      Parameters:
      player - the player who will receive the item
      slot - the slot index to store the item stack
    • giveTo

      public void giveTo(org.bukkit.entity.Player player, String key)
      Retrieves the slot index associated with the given custom key and stores the ItemStack of this SpecialItem instance in that slot of the specified player's inventory.
      Parameters:
      player - the player who will receive the item
      key - the custom key to retrieve the slot index
    • getCustomKey

      public <T> T getCustomKey(@NotNull @NotNull String key)
      Returns the value to which the specified key is mapped, or null if the custom keys map contains no mapping for the key.
      Type Parameters:
      T - the class of the objects in the custom keys Map.
      Parameters:
      key - the key whose associated value is to be returned
      Returns:
      the value to which the specified key is mapped, or null if this map contains no mapping for the key
    • findCustomKey

      public <T> Optional<T> findCustomKey(@NotNull @NotNull String key)
      Returns an Optional containing the value mapped to the specified key, or an empty Optional if no mapping exists.
      Type Parameters:
      T - the type to cast the value to
      Parameters:
      key - the key whose associated value is to be returned
      Returns:
      an Optional containing the value, or empty if not found
    • equals

      public boolean equals(@Nullable @Nullable org.bukkit.inventory.ItemStack item)
      Checks if a Bukkit ItemStack matches this SpecialItem based on material type, display name, and lore.
      Parameters:
      item - the ItemStack to compare
      Returns:
      true if the item matches this SpecialItem's metadata, false otherwise