improve logging

This commit is contained in:
1e99 2025-04-05 11:45:21 +02:00
parent 353e94899b
commit e05e5c35d8

View file

@ -44,9 +44,10 @@ public class Server {
GameProfile profile = this.handleClient(client); GameProfile profile = this.handleClient(client);
if (profile != null) { if (profile != null) {
this.clients.remove(profile.uuid()); this.clients.remove(profile.uuid());
} System.out.printf("Closed client %s (%s)%n", client.getInetAddress(), profile.username());
} else {
System.out.printf("Closed client %s%n", client.getInetAddress()); System.out.printf("Closed client %s%n", client.getInetAddress());
}
} catch (Exception e) { } catch (Exception e) {
System.err.printf("Failed to handle client:%n"); System.err.printf("Failed to handle client:%n");
e.printStackTrace(System.err); e.printStackTrace(System.err);
@ -123,11 +124,14 @@ public class Server {
return profile; return profile;
} }
System.out.printf("Client %s authenticated as %s (%s)%n", client.getInetAddress(), profile.username(), profile.uuid());
boolean alreadyConnected = this.clients.containsKey(profile.uuid()); boolean alreadyConnected = this.clients.containsKey(profile.uuid());
if (alreadyConnected) { if (alreadyConnected) {
DisconnectPacket disconnect = new DisconnectPacket(); DisconnectPacket disconnect = new DisconnectPacket();
disconnect.reason = "You are already connected."; disconnect.reason = "You are already connected.";
Packets.write(disconnect, out); Packets.write(disconnect, out);
System.out.printf("Client %s (%s) disconnected because they had another connection open%n", client.getInetAddress(), profile.username());
return profile; return profile;
} }