Remove legacy 1.19.2x Bedrock code

This commit is contained in:
Camotoy 2023-03-17 13:41:01 -04:00
parent d7c6865912
commit acb25b0c99
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
5 changed files with 19 additions and 77 deletions

View file

@ -96,10 +96,6 @@ public final class GameProtocol {
/* Bedrock convenience methods to gatekeep features and easily remove the check on version removal */ /* Bedrock convenience methods to gatekeep features and easily remove the check on version removal */
public static boolean supports1_19_30(GeyserSession session) {
return session.getUpstream().getProtocolVersion() >= Bedrock_v554.V554_CODEC.getProtocolVersion();
}
public static boolean supports1_19_50(GeyserSession session) { public static boolean supports1_19_50(GeyserSession session) {
return session.getUpstream().getProtocolVersion() >= Bedrock_v560.V560_CODEC.getProtocolVersion(); return session.getUpstream().getProtocolVersion() >= Bedrock_v560.V560_CODEC.getProtocolVersion();
} }

View file

@ -1,42 +0,0 @@
/*
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.translator.protocol.bedrock;
import com.nukkitx.protocol.bedrock.data.AdventureSetting;
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
@Translator(packet = AdventureSettingsPacket.class)
public class BedrockAdventureSettingsTranslator extends PacketTranslator<AdventureSettingsPacket> {
@Override
public void translate(GeyserSession session, AdventureSettingsPacket packet) {
boolean isFlying = packet.getSettings().contains(AdventureSetting.FLYING);
BedrockRequestAbilityTranslator.handle(session, isFlying);
}
}

View file

@ -30,7 +30,6 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.Server
import com.nukkitx.protocol.bedrock.data.Ability; import com.nukkitx.protocol.bedrock.data.Ability;
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
import com.nukkitx.protocol.bedrock.packet.RequestAbilityPacket; import com.nukkitx.protocol.bedrock.packet.RequestAbilityPacket;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;
@ -43,18 +42,8 @@ public class BedrockRequestAbilityTranslator extends PacketTranslator<RequestAbi
@Override @Override
public void translate(GeyserSession session, RequestAbilityPacket packet) { 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) { if (packet.getAbility() == Ability.FLYING) {
handle(session, packet.isBoolValue()); boolean isFlying = packet.isBoolValue();
}
}
//FIXME remove after pre-1.19.30 support is dropped and merge into main method
static void handle(GeyserSession session, boolean isFlying) {
if (!isFlying && session.getGameMode() == GameMode.SPECTATOR) { if (!isFlying && session.getGameMode() == GameMode.SPECTATOR) {
// We should always be flying in spectator mode // We should always be flying in spectator mode
session.sendAdventureSettings(); session.sendAdventureSettings();
@ -70,4 +59,5 @@ public class BedrockRequestAbilityTranslator extends PacketTranslator<RequestAbi
ServerboundPlayerAbilitiesPacket abilitiesPacket = new ServerboundPlayerAbilitiesPacket(isFlying); ServerboundPlayerAbilitiesPacket abilitiesPacket = new ServerboundPlayerAbilitiesPacket(isFlying);
session.sendDownstreamPacket(abilitiesPacket); session.sendDownstreamPacket(abilitiesPacket);
} }
}
} }

View file

@ -47,4 +47,9 @@ public class JavaKeepAliveTranslator extends PacketTranslator<ClientboundKeepAli
latencyPacket.setTimestamp(packet.getPingId() * 1000); latencyPacket.setTimestamp(packet.getPingId() * 1000);
session.sendUpstreamPacket(latencyPacket); session.sendUpstreamPacket(latencyPacket);
} }
@Override
public boolean shouldExecuteInEventLoop() {
return false;
}
} }

View file

@ -30,8 +30,6 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCu
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.nukkitx.protocol.bedrock.data.GameRuleData; import com.nukkitx.protocol.bedrock.data.GameRuleData;
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket; import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket;
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket; import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
@ -107,11 +105,6 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
session.getUpstream().sendPostStartGamePackets(); session.getUpstream().sendPostStartGamePackets();
} }
AdventureSettingsPacket bedrockPacket = new AdventureSettingsPacket();
bedrockPacket.setUniqueEntityId(session.getPlayerEntity().getGeyserId());
bedrockPacket.setPlayerPermission(PlayerPermission.MEMBER);
session.sendUpstreamPacket(bedrockPacket);
if (!needsSpawnPacket) { if (!needsSpawnPacket) {
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket(); SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
playerGameTypePacket.setGamemode(packet.getGameMode().ordinal()); playerGameTypePacket.setGamemode(packet.getGameMode().ordinal());