Package xyz.srnyx.annoyingapi.data
Class ItemData
java.lang.Object
xyz.srnyx.javautilities.parents.Stringable
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
-
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 theRuntimeLibrary.ITEM_NBT_APIlibrary isn't loaded, load it.attemptItemNbtApi(@NotNull Supplier<String> supplier) If theRuntimeLibrary.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, getAnnoyingPlugin, getOptional, has, removeChain, sendError, set, setChainMethods inherited from class xyz.srnyx.javautilities.parents.Stringable
toString, toString, toString, toString, toString
-
Constructor Details
-
ItemData
public ItemData(@NotNull @NotNull AnnoyingPlugin plugin, @NotNull @NotNull org.bukkit.inventory.ItemStack item) Construct a newItemDatafor the given item stack- Parameters:
plugin-Data.pluginitem-Data.target
-
-
Method Details
-
attemptItemNbtApi
@NotNull public @NotNull Optional<String> attemptItemNbtApi(@NotNull @NotNull Supplier<String> supplier) If theRuntimeLibrary.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 theRuntimeLibrary.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
-