From 717273fd8e93fd8fd2f3a84d661fa327aa221472 Mon Sep 17 00:00:00 2001 From: Heliosares <8331595+ks-hl@users.noreply.github.com> Date: Wed, 29 Jan 2025 12:41:25 -0500 Subject: [PATCH] Better error handling for item serialization --- .../dev/heliosares/auxprotect/spigot/AuxProtectSpigot.java | 6 +++--- .../dev/heliosares/auxprotect/utils/InvSerialization.java | 4 ++-- pom.xml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/AuxProtect_Core/src/main/java/dev/heliosares/auxprotect/spigot/AuxProtectSpigot.java b/AuxProtect_Core/src/main/java/dev/heliosares/auxprotect/spigot/AuxProtectSpigot.java index 37420bf..1950474 100644 --- a/AuxProtect_Core/src/main/java/dev/heliosares/auxprotect/spigot/AuxProtectSpigot.java +++ b/AuxProtect_Core/src/main/java/dev/heliosares/auxprotect/spigot/AuxProtectSpigot.java @@ -676,9 +676,9 @@ public final class AuxProtectSpigot extends JavaPlugin implements IAuxProtect { @Override public void print(Throwable t) { getLogger().log(Level.WARNING, t.getMessage(), t); - String stack = StackUtil.format(t, 3); - if (stackHashHistory.add(stack.hashCode())) { - stack = StackUtil.format(t, 20); + String stack = StackUtil.format(t, Integer.MAX_VALUE); + if (!stackHashHistory.add(stack.hashCode())) { + stack = StackUtil.format(t, 3); } logToStackLog(stack); } diff --git a/AuxProtect_Core/src/main/java/dev/heliosares/auxprotect/utils/InvSerialization.java b/AuxProtect_Core/src/main/java/dev/heliosares/auxprotect/utils/InvSerialization.java index 135ffe3..c176e6c 100644 --- a/AuxProtect_Core/src/main/java/dev/heliosares/auxprotect/utils/InvSerialization.java +++ b/AuxProtect_Core/src/main/java/dev/heliosares/auxprotect/utils/InvSerialization.java @@ -159,8 +159,8 @@ public class InvSerialization { private static void write(BukkitObjectOutputStream stream, ItemStack item, String playerName) throws IOException { try { stream.writeObject(item); - } catch (IOException e) { - String msg = "Failed to serialize " + item + " for " + playerName + ". This is not an issue with AuxProtect, it is Bukkit failing to serialize the item correctly. The item will be logged as an empty slot. (" + e.getMessage() + ")"; + } catch (Throwable e) { + String msg = "Failed to serialize " + item + " for " + playerName + ". This is not an issue with AuxProtect, it is Bukkit failing to serialize the item correctly. The item will be logged as an empty slot. (" + e.getClass().getName() + ": " + e.getMessage() + ")"; spamMap.values().removeIf(l -> System.currentTimeMillis() - l > 60000L); if (!spamMap.containsKey(msg)) { spamMap.put(msg, System.currentTimeMillis()); diff --git a/pom.xml b/pom.xml index c826b1b..5b32016 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,6 @@ ${env.USERPROFILE}/eclipse-workspace/jars UTF8 - 1.3.3-pre1 + 1.3.3-pre2 \ No newline at end of file