Package xyz.srnyx.annoyingapi.data
Class ItemData
java.lang.Object
xyz.srnyx.annoyingapi.parents.AnnoyableClass
xyz.srnyx.annoyingapi.data.Data<org.bukkit.inventory.ItemStack>
xyz.srnyx.annoyingapi.data.ItemData
- All Implemented Interfaces:
Annoyable
Utility class for adding and getting data from item stacks
-
Field Summary
Fields inherited from class xyz.srnyx.annoyingapi.parents.AnnoyableClass
annoyingPlugin -
Constructor Summary
ConstructorsConstructorDescriptionItemData(@NotNull AnnoyingPlugin plugin, @NotNull org.bukkit.inventory.ItemStack item) Construct a newItemDatafor the given item stack -
Method Summary
Modifier and TypeMethodDescriptionvoidattemptItemNbtApi(@NotNull Runnable runnable) If theAnnoyingAPILibrary.ITEM_NBT_APIlibrary isn't loaded, load it.attemptItemNbtApi(@NotNull Supplier<String> supplier) If theAnnoyingAPILibrary.ITEM_NBT_APIlibrary isn't loaded, load it.@Nullable StringGet the data value for the given keybooleanRemove the data value with the given keyprotected booleanSet the data value for the given key.Methods inherited from class xyz.srnyx.annoyingapi.data.Data
get, getOptional, has, removeChain, sendError, set, setChain, toStringMethods inherited from class xyz.srnyx.annoyingapi.parents.AnnoyableClass
getAnnoyingPlugin
-
Constructor Details
-
ItemData
public ItemData(@NotNull @NotNull AnnoyingPlugin plugin, @NotNull @NotNull org.bukkit.inventory.ItemStack item) Construct a newItemDatafor the given item stack- Parameters:
item-Data.target
-
-
Method Details
-
attemptItemNbtApi
@NotNull public @NotNull Optional<String> attemptItemNbtApi(@NotNull @NotNull Supplier<String> supplier) If theAnnoyingAPILibrary.ITEM_NBT_APIlibrary isn't loaded, load it. Then attempt to run the given supplier and return the result- Parameters:
supplier- the supplier to attempt- Returns:
- the result of the runnable
-
attemptItemNbtApi
If theAnnoyingAPILibrary.ITEM_NBT_APIlibrary isn't loaded, load it. Then attempt to run the given runnable- Parameters:
runnable- the runnable to attempt
-
get
Get the data value for the given key -
set
Set the data value for the given key. If the key already exists, it will be overwritten -
remove
Remove the data value with the given key
-