Gatekeep RequestAbilityPackets to 1.19.30+

This commit is contained in:
Camotoy 2022-09-18 12:20:54 -04:00
parent 64c03b9610
commit 4e2d750791
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
2 changed files with 10 additions and 0 deletions

View file

@ -95,6 +95,10 @@ public final class GameProtocol {
return session.getUpstream().getProtocolVersion() >= Bedrock_v534.V534_CODEC.getProtocolVersion();
}
public static boolean supports1_19_30(GeyserSession session) {
return session.getUpstream().getProtocolVersion() >= Bedrock_v554.V554_CODEC.getProtocolVersion();
}
/**
* Gets the {@link PacketCodec} for Minecraft: Java Edition.
*

View file

@ -30,6 +30,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.Server
import com.nukkitx.protocol.bedrock.data.Ability;
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
import com.nukkitx.protocol.bedrock.packet.RequestAbilityPacket;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
@ -42,6 +43,11 @@ public class BedrockRequestAbilityTranslator extends PacketTranslator<RequestAbi
@Override
public void translate(GeyserSession session, RequestAbilityPacket packet) {
// Gatekeep to 1.19.30 so older versions don't fire twice
if (!GameProtocol.supports1_19_30(session)) {
return;
}
if (packet.getAbility() == Ability.FLYING) {
handle(session, packet.isBoolValue());
}