Update core/src/main/java/org/geysermc/geyser/GeyserImpl.java

Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>
This commit is contained in:
chris 2024-08-08 22:13:33 +02:00 committed by GitHub
parent d8fa73ec8e
commit c7de3fd8a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -380,18 +380,16 @@ 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()) {
int parsedPort;
try {
parsedPort = Integer.parseInt(broadcastPort);
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: %s! Defaulting to configured port.", broadcastPort + " (" + e.getMessage() + ")"));
parsedPort = config.getBedrock().port();
logger.error(String.format("Invalid broadcast port from system property: %s! Defaulting to configured port.", broadcastPort + " (" + e.getMessage() + ")"));
}
config.getBedrock().setBroadcastPort(parsedPort);
logger.info("Broadcast port set from system property: " + parsedPort);
}
String remoteAddress = config.getRemote().address();