1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-27 02:39:15 +00:00

Resolve issue with querying session ping after it disconnected

This commit is contained in:
onebeastchris
2025-06-16 02:40:58 +02:00
parent 17baaf6721
commit f531a3624c

View File

@@ -2187,6 +2187,11 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
@Override
public int ping() {
// Can otherwise cause issues if the player isn't logged in yet / already left
if (getUpstream().isInitialized() || getUpstream().isClosed()) {
return 0;
}
RakSessionCodec rakSessionCodec = ((RakChildChannel) getUpstream().getSession().getPeer().getChannel()).rakPipeline().get(RakSessionCodec.class);
return (int) Math.floor(rakSessionCodec.getPing());
}