mirror of https://github.com/GeyserMC/Geyser.git
Add ping() method to GeyserConnection in api
This commit is contained in:
parent
7c194a0b74
commit
21f596b52e
|
@ -95,4 +95,9 @@ public interface GeyserConnection extends Connection, CommandSource {
|
|||
*/
|
||||
@NonNull
|
||||
Set<String> fogEffects();
|
||||
|
||||
/**
|
||||
* Returns the current ping of the connection.
|
||||
*/
|
||||
int ping();
|
||||
}
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import org.cloudburstmc.netty.channel.raknet.RakChildChannel;
|
||||
import org.cloudburstmc.netty.handler.codec.raknet.common.RakSessionCodec;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
@ -40,8 +38,7 @@ public class PingCommand extends GeyserCommand {
|
|||
@Override
|
||||
public void execute(GeyserSession session, GeyserCommandSource sender, String[] args) {
|
||||
if (session == null) return;
|
||||
RakSessionCodec rakSessionCodec = ((RakChildChannel) session.getUpstream().getSession().getPeer().getChannel()).rakPipeline().get(RakSessionCodec.class);
|
||||
sender.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.ping.message", sender.locale(), (int) Math.floor(rakSessionCodec.getPing())));
|
||||
sender.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.ping.message", sender.locale(), session.ping()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -85,6 +85,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||
import org.checkerframework.common.value.qual.IntRange;
|
||||
import org.cloudburstmc.math.vector.*;
|
||||
import org.cloudburstmc.nbt.NbtMap;
|
||||
import org.cloudburstmc.netty.channel.raknet.RakChildChannel;
|
||||
import org.cloudburstmc.netty.handler.codec.raknet.common.RakSessionCodec;
|
||||
import org.cloudburstmc.protocol.bedrock.BedrockDisconnectReasons;
|
||||
import org.cloudburstmc.protocol.bedrock.BedrockServerSession;
|
||||
import org.cloudburstmc.protocol.bedrock.data.*;
|
||||
|
@ -2032,6 +2034,12 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||
return Set.copyOf(this.appliedFog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int ping() {
|
||||
RakSessionCodec rakSessionCodec = ((RakChildChannel) getUpstream().getSession().getPeer().getChannel()).rakPipeline().get(RakSessionCodec.class);
|
||||
return (int) Math.floor(rakSessionCodec.getPing());
|
||||
}
|
||||
|
||||
public void addCommandEnum(String name, String enums) {
|
||||
softEnumPacket(name, SoftEnumUpdateType.ADD, enums);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue