mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 22:45:04 +01:00
Only check for correct protocol version once
This commit is contained in:
parent
bb2f4644be
commit
f71fa9ccac
2 changed files with 31 additions and 11 deletions
|
@ -62,8 +62,34 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
|||
return translateAndDefault(packet);
|
||||
}
|
||||
|
||||
private boolean newProtocol = false; // TEMPORARY
|
||||
|
||||
private boolean setCorrectCodec(int protocolVersion) {
|
||||
BedrockPacketCodec packetCodec = GameProtocol.getBedrockCodec(protocolVersion);
|
||||
if (packetCodec == null) {
|
||||
String supportedVersions = GameProtocol.getAllSupportedBedrockVersions();
|
||||
if (protocolVersion > GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
|
||||
// Too early to determine session locale
|
||||
session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.server", supportedVersions));
|
||||
return false;
|
||||
} else if (protocolVersion < GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
|
||||
session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.client", supportedVersions));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
session.getUpstream().getSession().setPacketCodec(packetCodec);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(RequestNetworkSettingsPacket packet) {
|
||||
if (setCorrectCodec(packet.getProtocolVersion())) {
|
||||
newProtocol = true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
// New since 1.19.30 - sent before login packet
|
||||
PacketCompressionAlgorithm algorithm = PacketCompressionAlgorithm.ZLIB;
|
||||
|
||||
|
@ -84,21 +110,12 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
BedrockPacketCodec packetCodec = GameProtocol.getBedrockCodec(loginPacket.getProtocolVersion());
|
||||
if (packetCodec == null) {
|
||||
String supportedVersions = GameProtocol.getAllSupportedBedrockVersions();
|
||||
if (loginPacket.getProtocolVersion() > GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
|
||||
// Too early to determine session locale
|
||||
session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.server", supportedVersions));
|
||||
return true;
|
||||
} else if (loginPacket.getProtocolVersion() < GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
|
||||
session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.client", supportedVersions));
|
||||
if (!newProtocol) {
|
||||
if (!setCorrectCodec(loginPacket.getProtocolVersion())) { // REMOVE WHEN ONLY 1.19.30 IS SUPPORTED OR 1.20
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
session.getUpstream().getSession().setPacketCodec(packetCodec);
|
||||
|
||||
// Set the block translation based off of version
|
||||
session.setBlockMappings(BlockRegistries.BLOCKS.forVersion(loginPacket.getProtocolVersion()));
|
||||
session.setItemMappings(Registries.ITEMS.forVersion(loginPacket.getProtocolVersion()));
|
||||
|
|
|
@ -38,6 +38,9 @@ dependencyResolutionManagement {
|
|||
maven("https://jitpack.io") {
|
||||
content { includeGroupByRegex("com\\.github\\..*") }
|
||||
}
|
||||
|
||||
// For Adventure snapshots
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue