Class ItemStackUtils

java.lang.Object
com.ultikits.ultitools.utils.ItemStackUtils

public final class ItemStackUtils extends Object
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
    Modifier and Type
    Field
    Description
    private static final Logger
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.bukkit.inventory.ItemStack
    Deserializes a Base64-encoded string back to a single ItemStack.
    static org.bukkit.inventory.ItemStack[]
    Deserializes a Base64-encoded string back to an array of ItemStack.
    static boolean
    Checks if a serialized string is valid.
    static String
    serializeItem(org.bukkit.inventory.ItemStack item)
    Serializes a single ItemStack to a Base64-encoded string.
    static String
    serializeItems(org.bukkit.inventory.ItemStack[] items)
    Serializes an array of ItemStack to a Base64-encoded string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOGGER

      private static final Logger LOGGER
  • Constructor Details

    • ItemStackUtils

      private ItemStackUtils()
  • Method Details

    • serializeItems

      public static String serializeItems(org.bukkit.inventory.ItemStack[] items)
      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

      public static org.bukkit.inventory.ItemStack[] deserializeItems(String data)
      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

      public static String serializeItem(org.bukkit.inventory.ItemStack item)
      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

      public static org.bukkit.inventory.ItemStack deserializeItem(String data)
      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

      public static boolean isValidSerialized(String data)
      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