Implement System properties to set the udp port and address #3597 (#3689)

* System property stuff

* Add geyserUdpPort/Address system properties as overrides for pluginUdpPort/Address

* Fix formatting for if-else statements

---------

Co-authored-by: Camotoy <20743703+Camotoy@users.noreply.github.com>
This commit is contained in:
Julian Vennen 2023-04-23 03:33:23 +02:00 committed by GitHub
parent cb440b65ad
commit f39e689b83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 160 additions and 129 deletions

View file

@ -50,12 +50,12 @@ import org.geysermc.geyser.ping.IGeyserPingPassthrough;
import org.geysermc.geyser.platform.velocity.command.GeyserVelocityCommandExecutor;
import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.FileUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -111,22 +111,6 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
return;
}
InetSocketAddress javaAddr = proxyServer.getBoundAddress();
// By default this should be localhost but may need to be changed in some circumstances
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
this.geyserConfig.setAutoconfiguredRemote(true);
// Don't use localhost if not listening on all interfaces
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
this.geyserConfig.getRemote().setAddress(javaAddr.getHostString());
}
geyserConfig.getRemote().setPort(javaAddr.getPort());
}
if (geyserConfig.getBedrock().isCloneRemotePort()) {
geyserConfig.getBedrock().setPort(javaAddr.getPort());
}
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
@ -247,4 +231,15 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
public SocketAddress getSocketAddress() {
return this.geyserInjector.getServerSocketAddress();
}
@NotNull
@Override
public String getServerBindAddress() {
return proxyServer.getBoundAddress().getHostString();
}
@Override
public int getServerPort() {
return proxyServer.getBoundAddress().getPort();
}
}