Only replace port when version is forced

This commit is contained in:
FlorianMichael 2024-03-22 10:40:42 +01:00
parent de8a6f642c
commit 7bda76f004
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126

View File

@ -152,13 +152,11 @@ public class ClientsideFixes {
* @return The server address with the replaced default port * @return The server address with the replaced default port
*/ */
public static ServerAddress replaceDefaultPort(final ServerInfo info) { public static ServerAddress replaceDefaultPort(final ServerInfo info) {
ProtocolVersion targetVersion = ((IServerInfo) info).viaFabricPlus$forcedVersion(); final boolean isBedrock = Objects.equals(((IServerInfo) info).viaFabricPlus$forcedVersion(), BedrockProtocolVersion.bedrockLatest);
if (targetVersion == null) {
targetVersion = ProtocolTranslator.getTargetVersion();
}
// If the default port for this entry should be replaced, check if the address already contains a port // If the default port for this entry should be replaced, check if the address already contains a port
// We can't just replace vanilla's default port because a bedrock server might be running on the same port // We can't just replace vanilla's default port because a bedrock server might be running on the same port
if (BedrockSettings.global().replaceDefaultPort.getValue() && targetVersion.equals(BedrockProtocolVersion.bedrockLatest) && !info.address.contains(":")) { if (BedrockSettings.global().replaceDefaultPort.getValue() && isBedrock && !info.address.contains(":")) {
return ServerAddress.parse(info.address + ":" + 19132); return ServerAddress.parse(info.address + ":" + 19132);
} else { } else {
return ServerAddress.parse(info.address); return ServerAddress.parse(info.address);