Package ru.cwcode.cwutils.items
Class InventorySerializer
java.lang.Object
ru.cwcode.cwutils.items.InventorySerializer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.inventory.InventoryfromBase64(String data) A method to get anInventoryfrom an encoded, Base64, string.static org.bukkit.inventory.ItemStack[]static StringitemStackArrayToBase64(org.bukkit.inventory.ItemStack[] items) A method to serialize anItemStackarray to Base64 String.static String[]playerInventoryToBase64(org.bukkit.inventory.PlayerInventory playerInventory) Converts the player inventory to a String array of Base64 strings.static StringtoBase64(org.bukkit.inventory.Inventory inventory) A method to serialize an inventory to Base64 string.
-
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 anItemStackarray to Base64 String.- Parameters:
items- to turn into a Base64 String.- Returns:
- Base64 string of the items.
- Throws:
IllegalStateException
-
itemStackArrayFromBase64
-
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
A method to get anInventoryfrom an encoded, Base64, string.- Parameters:
data- Base64 string of data containing an inventory.- Returns:
- Inventory created from the Base64 string.
- Throws:
IOException
-