Better error handling for item serialization

This commit is contained in:
Heliosares
2025-01-29 12:41:25 -05:00
parent a00f188ff0
commit 717273fd8e
3 changed files with 6 additions and 6 deletions

View File

@@ -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);
}

View File

@@ -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());

View File

@@ -18,6 +18,6 @@
<properties>
<jars>${env.USERPROFILE}/eclipse-workspace/jars</jars>
<project.build.sourceEncoding>UTF8</project.build.sourceEncoding>
<revision>1.3.3-pre1</revision>
<revision>1.3.3-pre2</revision>
</properties>
</project>