3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-05 07:40:11 +01:00

Fix: Broadcast port system property not being read on Geyser-Standalone (#4942)

* this is supposed to work on standalone aswell

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

Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>

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

Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>

* address review

---------

Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>
Dieser Commit ist enthalten in:
chris 2024-09-03 01:04:44 +02:00 committet von GitHub
Ursprung 74034f0783
Commit 65cb15400a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
2 geänderte Dateien mit 20 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -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,26 @@ 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() + ")"));
}
}
// It's set to 0 only if no system property or manual config value was set
if (config.getBedrock().broadcastPort() == 0) {
config.getBedrock().setBroadcastPort(config.getBedrock().port());
}
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")) {

Datei anzeigen

@ -144,11 +144,6 @@ public final class GeyserServer {
this.proxiedAddresses = null;
}
// It's set to 0 only if no system property or manual config value was set
if (geyser.getConfig().getBedrock().broadcastPort() == 0) {
geyser.getConfig().getBedrock().setBroadcastPort(geyser.getConfig().getBedrock().port());
}
this.broadcastPort = geyser.getConfig().getBedrock().broadcastPort();
}