forked from SteamWar/SteamWar
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.
This commit is contained in:
-3
@@ -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'));
|
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) {
|
} catch (Exception e) {
|
||||||
writer.append("Error while generating bug report: ").append(e.getMessage()).append('\n');
|
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);
|
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());
|
SWException.log("Techhider-Bug reported by " + sender.getName() + ": " + Arrays.toString(args), writer.toString());
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class TinyProtocol implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerLogin(PlayerLoginEvent e) {
|
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)
|
if(closed)
|
||||||
return;
|
return;
|
||||||
new PacketInterceptor(e.getPlayer());
|
new PacketInterceptor(e.getPlayer());
|
||||||
@@ -130,7 +130,7 @@ public class TinyProtocol implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void close() {
|
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)
|
if(closed)
|
||||||
return;
|
return;
|
||||||
@@ -169,9 +169,9 @@ public class TinyProtocol implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
synchronized (playerInterceptors) {
|
synchronized (playerInterceptors) {
|
||||||
plugin.getLogger().info("Adding Techhider for: " + player.getName());
|
|
||||||
playerInterceptors.put(player, this);
|
playerInterceptors.put(player, this);
|
||||||
}
|
}
|
||||||
|
plugin.getLogger().info("Adding Techhider for: " + player.getName());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
channel.pipeline().addBefore("packet_handler", HANDLER_NAME, this);
|
channel.pipeline().addBefore("packet_handler", HANDLER_NAME, this);
|
||||||
|
|||||||
Reference in New Issue
Block a user