From 15bb92fbbac90601ebdc4d2819c7e338789753d8 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 29 Apr 2025 18:04:58 +0200 Subject: [PATCH] Improve error handling and logging in Techhider and TinyProtocol Refined logging messages for clarity by replacing "Techhider" with "PacketInterceptor" where appropriate. Adjusted error handling in `TechhiderbugCommand` by removing redundant `flush` calls and properly logging exceptions during bug report generation. These changes aim to enhance maintainability and debugging. --- .../steamwar/fightsystem/commands/TechhiderbugCommand.java | 3 --- .../src/com/comphenix/tinyprotocol/TinyProtocol.java | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java index eb0c82f5..3080c13e 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TechhiderbugCommand.java @@ -71,10 +71,7 @@ public class TechhiderbugCommand implements CommandExecutor { Bukkit.getOnlinePlayers().forEach(p -> writer.append(p.getName()).append(": ").append(String.join(" ", TinyProtocol.instance.getPlayerInterceptors().get(p).getChannel().pipeline().names())).append('\n')); } catch (Exception e) { writer.append("Error while generating bug report: ").append(e.getMessage()).append('\n'); - writer.flush(); Bukkit.getLogger().log(Level.SEVERE, "Error while generating bug report", e); - } finally { - writer.flush(); } SWException.log("Techhider-Bug reported by " + sender.getName() + ": " + Arrays.toString(args), writer.toString()); diff --git a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java index 6a77e082..c8070e46 100644 --- a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java +++ b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java @@ -95,7 +95,7 @@ public class TinyProtocol implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onPlayerLogin(PlayerLoginEvent e) { - plugin.getLogger().info("Creating Techhider for: " + e.getPlayer().getName() + " (" + closed + ")"); + plugin.getLogger().info("Creating PacketInterceptor for: " + e.getPlayer().getName() + " (" + closed + ")"); if(closed) return; new PacketInterceptor(e.getPlayer()); @@ -130,7 +130,7 @@ public class TinyProtocol implements Listener { } public final void close() { - plugin.getLogger().log(Level.INFO, "Closing Techhider", new Exception("Stacktrace")); + plugin.getLogger().log(Level.INFO, "Closing PacketInterceptor", new Exception("Stacktrace")); if(closed) return; @@ -169,9 +169,9 @@ public class TinyProtocol implements Listener { return; synchronized (playerInterceptors) { - plugin.getLogger().info("Adding Techhider for: " + player.getName()); playerInterceptors.put(player, this); } + plugin.getLogger().info("Adding Techhider for: " + player.getName()); try { channel.pipeline().addBefore("packet_handler", HANDLER_NAME, this);