From f803788c77ed57dec8e3cabcf0166defcf251fdc Mon Sep 17 00:00:00 2001 From: William Date: Thu, 28 Oct 2021 18:02:39 +0100 Subject: [PATCH] Fix #1 - EOFException caused by attempting to serialize zero-length PotionEffect array --- .../husksync/bukkit/data/DataSerializer.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bukkit/src/main/java/me/william278/husksync/bukkit/data/DataSerializer.java b/bukkit/src/main/java/me/william278/husksync/bukkit/data/DataSerializer.java index e93c4814..26861dba 100644 --- a/bukkit/src/main/java/me/william278/husksync/bukkit/data/DataSerializer.java +++ b/bukkit/src/main/java/me/william278/husksync/bukkit/data/DataSerializer.java @@ -28,6 +28,11 @@ public class DataSerializer { * @return The serialized inventory contents */ public static String serializeInventory(ItemStack[] inventoryContents) { + // Return an empty string if there is no inventory item data to serialize + if (inventoryContents.length == 0) { + return ""; + } + // Create an output stream that will be encoded into base 64 ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); @@ -108,6 +113,11 @@ public class DataSerializer { * @return The serialized potion effects */ public static String serializePotionEffects(PotionEffect[] potionEffects) { + // Return an empty string if there are no effects to serialize + if (potionEffects.length == 0) { + return ""; + } + // Create an output stream that will be encoded into base 64 ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();