Package dev.despical.fileitems
Class SpecialItem
java.lang.Object
dev.despical.fileitems.SpecialItem
- Author:
- Despical
Created at 17.09.2024
-
Method Summary
Modifier and TypeMethodDescription@NotNull ItemBuilderCreates a newItemBuilderinitialized with this item's stack.booleanequals(@Nullable org.bukkit.inventory.ItemStack item) Checks if a BukkitItemStackmatches this SpecialItem based on material type, display name, and lore.<T> Optional<T> findCustomKey(@NotNull String key) Returns anOptionalcontaining the value mapped to the specified key, or an emptyOptionalif no mapping exists.<T> TgetCustomKey(@NotNull String key) Returns the value to which the specified key is mapped, ornullif the custom keys map contains no mapping for the key.@NotNull org.bukkit.inventory.ItemStackRetrieves a clone of the underlyingItemStack.@NotNull StringgetKey()Gets the unique key identifier for this special item.@NotNull org.bukkit.inventory.ItemStackRetrieves the original underlyingItemStack.voidgiveTo(org.bukkit.entity.Player player, int slot) Stores theItemStackof thisSpecialIteminstance at the givenslotindex of the givenplayer's inventory.voidRetrieves the slot index associated with the given custom key and stores theItemStackof thisSpecialIteminstance in that slot of the specifiedplayer's inventory.
-
Method Details
-
getItemStack
@NotNull public @NotNull org.bukkit.inventory.ItemStack getItemStack()Retrieves a clone of the underlyingItemStack.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 underlyingItemStack.Note: Modifying this stack will directly affect the stored item.
- Returns:
- the original
ItemStack
-
asItemBuilder
Creates a newItemBuilderinitialized with this item's stack.- Returns:
- a new
ItemBuilderwrapping the item stack
-
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 theItemStackof thisSpecialIteminstance at the givenslotindex of the givenplayer's inventory.- Parameters:
player- the player who will receive the itemslot- the slot index to store the item stack
-
giveTo
Retrieves the slot index associated with the given custom key and stores theItemStackof thisSpecialIteminstance in that slot of the specifiedplayer's inventory.- Parameters:
player- the player who will receive the itemkey- the custom key to retrieve the slot index
-
getCustomKey
Returns the value to which the specified key is mapped, ornullif 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
nullif this map contains no mapping for the key
-
findCustomKey
Returns anOptionalcontaining the value mapped to the specified key, or an emptyOptionalif 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
Optionalcontaining the value, or empty if not found
-
equals
public boolean equals(@Nullable @Nullable org.bukkit.inventory.ItemStack item) Checks if a BukkitItemStackmatches this SpecialItem based on material type, display name, and lore.- Parameters:
item- theItemStackto compare- Returns:
trueif the item matches this SpecialItem's metadata,falseotherwise
-