Java Code Examples for org.bukkit.util.io.BukkitObjectInputStream#close()
The following examples show how to use
org.bukkit.util.io.BukkitObjectInputStream#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InventoryTypeAdapter.java From IridiumSkyblock with GNU General Public License v2.0 | 6 votes |
public static Inventory fromBase64(String data) { try { ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt()); // Read the serialized inventory for (int i = 0; i < inventory.getSize(); i++) { inventory.setItem(i, (ItemStack) dataInput.readObject()); } dataInput.close(); return inventory; } catch (Exception e) { } return null; }
Example 2
Source File: Base64Serialization.java From PlayerVaults with GNU General Public License v3.0 | 6 votes |
public static Inventory fromBase64(String data, String target) { try { ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt()); // Read the serialized inventory for (int i = 0; i < inventory.getSize(); i++) { inventory.setItem(i, (ItemStack) dataInput.readObject()); } dataInput.close(); PlayerVaults.debug("Read " + inventory.getSize() + " items"); return inventory; } catch (Exception e) { PlayerVaults.getInstance().getLogger().log(Level.SEVERE, "Failed to load vault " + target, e); } return null; }
Example 3
Source File: Base64Serialize.java From ServerTutorial with MIT License | 6 votes |
public static Inventory fromBase64(String data) { try { ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt()); // Read the serialized inventory for (int i = 0; i < inventory.getSize(); i++) { inventory.setItem(i, (ItemStack) dataInput.readObject()); } dataInput.close(); return inventory; } catch (Exception e) { } return null; }
Example 4
Source File: Base64Serialize.java From ServerTutorial with MIT License | 6 votes |
/** * Gets an array of ItemStacks from Base64 string. * * <p /> * * Base off of {@link #fromBase64(String)}. * * @param data Base64 string to convert to ItemStack array. * @return ItemStack array created from the Base64 string. * @throws IOException */ public static ItemStack[] itemStackArrayFromBase64(String data) { try { ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); ItemStack[] items = new ItemStack[dataInput.readInt()]; // Read the serialized inventory for (int i = 0; i < items.length; i++) { items[i] = (ItemStack) dataInput.readObject(); } dataInput.close(); return items; } catch (IOException | ClassNotFoundException e) { } return null; }
Example 5
Source File: InventoryTypeAdapter.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
public static ItemStack[] StringToInventory(String data) throws IOException { try { ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); ItemStack[] items = new ItemStack[dataInput.readInt()]; for (int i = 0; i < items.length; i++) { items[i] = (ItemStack) dataInput.readObject(); } dataInput.close(); return items; } catch (ClassNotFoundException e) { throw new IOException("Unable to decode class type.", e); } }