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.
ItemStack 序列化和反序列化工具类。 使用 Base64 编码将 ItemStack 数组转换为字符串用于存储。
- 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.将 ItemStack 数组序列化为 Base64 编码的字符串。
- 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.将 Base64 编码的字符串反序列化为 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.将单个 ItemStack 序列化为 Base64 编码的字符串。
- 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.将 Base64 编码的字符串反序列化为单个 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
-