This commit is contained in:
LOOHP 2025-12-18 16:56:44 +00:00
parent 28d735c912
commit 952adcfe87
1 changed files with 11 additions and 6 deletions

View File

@ -250,6 +250,9 @@ public class ClientConnection extends Thread {
} catch (IOException ignored) { } catch (IOException ignored) {
} }
try { try {
ServerProperties properties = Limbo.getInstance().getServerProperties();
String str = (properties.isLogPlayerIPAddresses() ? inetAddress.getHostName() : "<ip address withheld>") + ":" + clientSocket.getPort();
Limbo.getInstance().getConsole().sendMessage("[/" + str + "] <-> Player disconnected with the reason " + PlainTextComponentSerializer.plainText().serialize(reason));
clientSocket.close(); clientSocket.close();
} catch (IOException ignored) { } catch (IOException ignored) {
} }
@ -649,19 +652,21 @@ public class ClientConnection extends Thread {
keepAliveTask = new TimerTask() { keepAliveTask = new TimerTask() {
@Override @Override
public void run() { public void run() {
if (state != ClientState.PLAY || !ready) this.cancel(); if (state != ClientState.PLAY || !ready) {
this.cancel();
}
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
PacketPlayOutKeepAlive keepAlive = new PacketPlayOutKeepAlive(now); PacketPlayOutKeepAlive keepAlive = new PacketPlayOutKeepAlive(now);
try { try {
sendPacket(keepAlive); sendPacket(keepAlive);
setLastKeepAlivePayLoad(now); setLastKeepAlivePayLoad(now);
} catch (IOException ignored) {cancel();} } catch (IOException e) {
cancel();
}
} }
}; };
new Timer().schedule(keepAliveTask, 0, 10000);
new Timer().schedule(keepAliveTask, 0, 10_000);
while (clientSocket.isConnected()) { while (clientSocket.isConnected()) {
try { try {
@ -718,7 +723,7 @@ public class ClientConnection extends Thread {
if (alive.getPayload() == getLastKeepAlivePayLoad()) { if (alive.getPayload() == getLastKeepAlivePayLoad()) {
lastKeepAliveResponse.set(System.currentTimeMillis()); lastKeepAliveResponse.set(System.currentTimeMillis());
} else { } else {
disconnect(Component.text("Bad keepalive payload")); disconnect(Component.text("Bad Keepalive Payload"));
break; break;
} }
} else if (packetIn instanceof PacketPlayInTabComplete) { } else if (packetIn instanceof PacketPlayInTabComplete) {