Kick pre-1.19.30 players for not sending a RequestNetworkSettingsPacket

This commit is contained in:
Camotoy 2023-06-09 12:10:59 -04:00
parent 53d002656f
commit 3ec0d82d46
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F

View file

@ -69,6 +69,7 @@ import java.util.OptionalInt;
public class UpstreamPacketHandler extends LoggingPacketHandler { public class UpstreamPacketHandler extends LoggingPacketHandler {
private boolean networkSettingsRequested = false;
private Deque<String> packsToSent = new ArrayDeque<>(); private Deque<String> packsToSent = new ArrayDeque<>();
public UpstreamPacketHandler(GeyserImpl geyser, GeyserSession session) { public UpstreamPacketHandler(GeyserImpl geyser, GeyserSession session) {
@ -137,6 +138,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
session.getUpstream().getSession().setCompression(algorithm); session.getUpstream().getSession().setCompression(algorithm);
session.getUpstream().getSession().setCompressionLevel(this.geyser.getConfig().getBedrock().getCompressionLevel()); session.getUpstream().getSession().setCompressionLevel(this.geyser.getConfig().getBedrock().getCompressionLevel());
networkSettingsRequested = true;
return PacketSignal.HANDLED; return PacketSignal.HANDLED;
} }
@ -148,6 +150,11 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
return PacketSignal.HANDLED; return PacketSignal.HANDLED;
} }
if (!networkSettingsRequested) {
session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.client", GameProtocol.getAllSupportedBedrockVersions()));
return PacketSignal.HANDLED;
}
// Set the block translation based off of version // Set the block translation based off of version
session.setBlockMappings(BlockRegistries.BLOCKS.forVersion(loginPacket.getProtocolVersion())); session.setBlockMappings(BlockRegistries.BLOCKS.forVersion(loginPacket.getProtocolVersion()));
session.setItemMappings(Registries.ITEMS.forVersion(loginPacket.getProtocolVersion())); session.setItemMappings(Registries.ITEMS.forVersion(loginPacket.getProtocolVersion()));