Class InventorySerializer

java.lang.Object
ru.cwcode.cwutils.items.InventorySerializer

public class InventorySerializer extends Object
  • Constructor Details

    • InventorySerializer

      public InventorySerializer()
  • Method Details

    • playerInventoryToBase64

      public static String[] playerInventoryToBase64(org.bukkit.inventory.PlayerInventory playerInventory) throws IllegalStateException
      Converts the player inventory to a String array of Base64 strings. First string is the content and second string is the armor.
      Parameters:
      playerInventory - to turn into an array of strings.
      Returns:
      Array of strings: [ main content, armor content ]
      Throws:
      IllegalStateException
    • itemStackArrayToBase64

      public static String itemStackArrayToBase64(org.bukkit.inventory.ItemStack[] items) throws IllegalStateException
      A method to serialize an ItemStack array to Base64 String.
      Parameters:
      items - to turn into a Base64 String.
      Returns:
      Base64 string of the items.
      Throws:
      IllegalStateException
    • itemStackArrayFromBase64

      public static org.bukkit.inventory.ItemStack[] itemStackArrayFromBase64(String base)
    • toBase64

      public static String toBase64(org.bukkit.inventory.Inventory inventory) throws IllegalStateException
      A method to serialize an inventory to Base64 string.
      Parameters:
      inventory - to serialize
      Returns:
      Base64 string of the provided inventory
      Throws:
      IllegalStateException
    • fromBase64

      public static org.bukkit.inventory.Inventory fromBase64(String data) throws IOException
      A method to get an Inventory from an encoded, Base64, string.
      Parameters:
      data - Base64 string of data containing an inventory.
      Returns:
      Inventory created from the Base64 string.
      Throws:
      IOException