forked from SteamWar/SteamWar
Add error handling and logging to Techhider and TinyProtocol
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user