API: Expose a GeyserConnection's protocol version (#5083)

* Add protocolVersion() to GeyserConnection

* specify which protocol
This commit is contained in:
chris 2024-10-23 03:49:04 +08:00 committed by GitHub
parent 264a914d41
commit d94c6ffcb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View file

@ -70,6 +70,11 @@ public interface GeyserConnection extends Connection, CommandSource {
*/ */
void closeForm(); void closeForm();
/**
* Gets the Bedrock protocol version of the player.
*/
int protocolVersion();
/** /**
* @param javaId the Java entity ID to look up. * @param javaId the Java entity ID to look up.
* @return a {@link GeyserEntity} if present in this connection's entity tracker. * @return a {@link GeyserEntity} if present in this connection's entity tracker.

View file

@ -2229,6 +2229,11 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
return (int) Math.floor(rakSessionCodec.getPing()); return (int) Math.floor(rakSessionCodec.getPing());
} }
@Override
public int protocolVersion() {
return upstream.getProtocolVersion();
}
@Override @Override
public void closeForm() { public void closeForm() {
if (!GameProtocol.isPre1_21_2(this)) { if (!GameProtocol.isPre1_21_2(this)) {

View file

@ -8,5 +8,5 @@ org.gradle.vfs.watch=false
group=org.geysermc group=org.geysermc
id=geyser id=geyser
version=2.4.3-SNAPSHOT version=2.4.4-SNAPSHOT
description=Allows for players from Minecraft: Bedrock Edition to join Minecraft: Java Edition servers. description=Allows for players from Minecraft: Bedrock Edition to join Minecraft: Java Edition servers.