This commit is contained in:
chris 2024-08-14 18:15:45 -04:00 committed by GitHub
commit a3f0d51c91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -363,22 +363,6 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
}
}
String broadcastPort = System.getProperty("geyserBroadcastPort", "");
if (!broadcastPort.isEmpty()) {
int parsedPort;
try {
parsedPort = Integer.parseInt(broadcastPort);
if (parsedPort < 1 || parsedPort > 65535) {
throw new NumberFormatException("The broadcast port must be between 1 and 65535 inclusive!");
}
} catch (NumberFormatException e) {
logger.error(String.format("Invalid broadcast port: %s! Defaulting to configured port.", broadcastPort + " (" + e.getMessage() + ")"));
parsedPort = config.getBedrock().port();
}
config.getBedrock().setBroadcastPort(parsedPort);
logger.info("Broadcast port set from system property: " + parsedPort);
}
if (platformType != PlatformType.VIAPROXY) {
boolean floodgatePresent = bootstrap.testFloodgatePluginPresent();
if (config.getRemote().authType() == AuthType.FLOODGATE && !floodgatePresent) {
@ -393,6 +377,21 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
}
}
// Now that the Bedrock port may have been changed, also check the broadcast port (configurable on all platforms)
String broadcastPort = System.getProperty("geyserBroadcastPort", "");
if (!broadcastPort.isEmpty()) {
try {
int parsedPort = Integer.parseInt(broadcastPort);
if (parsedPort < 1 || parsedPort > 65535) {
throw new NumberFormatException("The broadcast port must be between 1 and 65535 inclusive!");
}
config.getBedrock().setBroadcastPort(parsedPort);
logger.info("Broadcast port set from system property: " + parsedPort);
} catch (NumberFormatException e) {
logger.error(String.format("Invalid broadcast port from system property: %s! Defaulting to configured port.", broadcastPort + " (" + e.getMessage() + ")"));
}
}
String remoteAddress = config.getRemote().address();
// Filters whether it is not an IP address or localhost, because otherwise it is not possible to find out an SRV entry.
if (!remoteAddress.matches(IP_REGEX) && !remoteAddress.equalsIgnoreCase("localhost")) {