Add error handling and logging to Techhider and TinyProtocol

This commit is contained in:
2025-04-29 17:59:22 +02:00
parent 66d18e316b
commit d6a5caf95d
2 changed files with 42 additions and 15 deletions
@@ -71,6 +71,17 @@ public class TinyProtocol implements Listener {
@Getter
private final Map<Player, PacketInterceptor> playerInterceptors = new HashMap<>();
@Override
public String toString() {
return "TinyProtocol{" +
"plugin=" + plugin +
", connections=" + connections +
", closed=" + closed +
", packetFilters=" + packetFilters +
", playerInterceptors=" + playerInterceptors +
'}';
}
private TinyProtocol(final Plugin plugin) {
this.plugin = plugin;
this.connections = networkManagers.get(getServerConnection(plugin));
@@ -84,6 +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 + ")");
if(closed)
return;
new PacketInterceptor(e.getPlayer());
@@ -118,6 +130,8 @@ public class TinyProtocol implements Listener {
}
public final void close() {
plugin.getLogger().log(Level.INFO, "Closing Techhider", new Exception("Stacktrace"));
if(closed)
return;
closed = true;
@@ -155,6 +169,7 @@ public class TinyProtocol implements Listener {
return;
synchronized (playerInterceptors) {
plugin.getLogger().info("Adding Techhider for: " + player.getName());
playerInterceptors.put(player, this);
}