Package com.ultikits.ultitools.utils
Class ItemStackUtils
java.lang.Object
com.ultikits.ultitools.utils.ItemStackUtils
Utility class for ItemStack serialization and deserialization.
Uses Base64 encoding to convert ItemStack arrays to/from strings for storage.
- Since:
- 6.2.0
- Version:
- 1.0.0
- Author:
- wisdomme
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.inventory.ItemStackdeserializeItem(String data) Deserializes a Base64-encoded string back to a single ItemStack.static org.bukkit.inventory.ItemStack[]deserializeItems(String data) Deserializes a Base64-encoded string back to an array of ItemStack.static booleanisValidSerialized(String data) Checks if a serialized string is valid.static StringserializeItem(org.bukkit.inventory.ItemStack item) Serializes a single ItemStack to a Base64-encoded string.static StringserializeItems(org.bukkit.inventory.ItemStack[] items) Serializes an array of ItemStack to a Base64-encoded string.
-
Field Details
-
LOGGER
-
-
Constructor Details
-
ItemStackUtils
private ItemStackUtils()
-
-
Method Details
-
serializeItems
Serializes an array of ItemStack to a Base64-encoded string.- Parameters:
items- the ItemStack array to serialize- Returns:
- the Base64-encoded string, or null if serialization fails
-
deserializeItems
Deserializes a Base64-encoded string back to an array of ItemStack.- Parameters:
data- the Base64-encoded string- Returns:
- the ItemStack array, or null if deserialization fails
-
serializeItem
Serializes a single ItemStack to a Base64-encoded string.- Parameters:
item- the ItemStack to serialize- Returns:
- the Base64-encoded string, or null if serialization fails
-
deserializeItem
Deserializes a Base64-encoded string back to a single ItemStack.- Parameters:
data- the Base64-encoded string- Returns:
- the ItemStack, or null if deserialization fails or array is empty
-
isValidSerialized
Checks if a serialized string is valid.- Parameters:
data- the Base64-encoded string to check- Returns:
- true if the string can be deserialized, false otherwise
-