Fixed crash when exit

This commit is contained in:
2025-04-25 23:52:37 +02:00
parent 486232623a
commit 32c1391336
@@ -117,17 +117,22 @@ public class Auth {
private static void startPingThread() {
pingThread = new Thread(() -> {
try {
while (running) {
while (running && !Thread.currentThread().isInterrupted()) {
try {
Thread.sleep(25000); // 25 seconds
if (running) {
Network.write("ping");
}
}
} catch (InterruptedException e) {
SaturnClient.LOGGER.warn("Ping thread interrupted", e);
Thread.currentThread().interrupt(); // Restore interrupt status
break; // Exit the loop on interruption
}
}
} catch (Exception e) {
if (!(e instanceof InterruptedException)) {
SaturnClient.LOGGER.error("Error in ping thread", e);
}
}
});
pingThread.setDaemon(true);