diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java index 38d319e1..4e3ad5b9 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java @@ -87,6 +87,10 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap { this.geyserConfig.getRemote().setAddress(javaAddr.getHostString()); } + if (geyserConfig.getBedrock().isCloneRemotePort()) { + geyserConfig.getBedrock().setPort(javaAddr.getPort()); + } + this.geyserConfig.getRemote().setPort(javaAddr.getPort()); } diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java index 38141c52..759246df 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java @@ -87,6 +87,10 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap { geyserConfig.getRemote().setAddress(Bukkit.getIp()); } + if (geyserConfig.getBedrock().isCloneRemotePort()) { + geyserConfig.getBedrock().setPort(Bukkit.getPort()); + } + geyserConfig.getRemote().setPort(Bukkit.getPort()); this.geyserLogger = new GeyserSpigotLogger(getLogger(), geyserConfig.isDebugMode()); diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java index d56abe09..27c54326 100644 --- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java +++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java @@ -174,6 +174,11 @@ public class GeyserSpongeConfiguration implements GeyserConfiguration { return node.getNode("port").getInt(19132); } + @Override + public boolean isCloneRemotePort() { + return node.getNode("clone-remote-port").getBoolean(false); + } + @Override public String getMotd1() { return node.getNode("motd1").getString("GeyserMC"); diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java index 3151e973..cfead6fd 100644 --- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java +++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java @@ -111,6 +111,11 @@ public class GeyserSpongePlugin implements GeyserBootstrap { serverPort.setValue(javaAddr.getPort()); } + ConfigurationNode bedrockPort = config.getNode("bedrock").getNode("port"); + if (geyserConfig.getBedrock().isCloneRemotePort()){ + bedrockPort.setValue(serverPort.getValue()); + } + this.geyserLogger = new GeyserSpongeLogger(logger, geyserConfig.isDebugMode()); GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger); this.connector = GeyserConnector.start(PlatformType.SPONGE, this); diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPlugin.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPlugin.java index 425aba18..974d4c4c 100644 --- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPlugin.java +++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPlugin.java @@ -98,6 +98,10 @@ public class GeyserVelocityPlugin implements GeyserBootstrap { geyserConfig.getRemote().setAddress(javaAddr.getHostString()); } + if (geyserConfig.getBedrock().isCloneRemotePort()) { + geyserConfig.getBedrock().setPort(javaAddr.getPort()); + } + geyserConfig.getRemote().setPort(javaAddr.getPort()); this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode()); diff --git a/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java b/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java index fd6916dc..54a7630b 100644 --- a/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java +++ b/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java @@ -86,6 +86,8 @@ public interface GeyserConfiguration { int getPort(); + boolean isCloneRemotePort(); + String getMotd1(); String getMotd2(); diff --git a/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java b/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java index 867de9ad..2c4a219b 100644 --- a/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java +++ b/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java @@ -97,7 +97,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration public static class BedrockConfiguration implements IBedrockConfiguration { private String address; + @Setter private int port; + private boolean isCloneRemotePort; private String motd1; private String motd2; diff --git a/connector/src/main/resources/config.yml b/connector/src/main/resources/config.yml index 91f95e6e..c587b21d 100644 --- a/connector/src/main/resources/config.yml +++ b/connector/src/main/resources/config.yml @@ -13,6 +13,10 @@ bedrock: address: 0.0.0.0 # The port that will listen for connections port: 19132 + # Some hosting services change your Java port everytime you open the server, and require the same port to be used for Bedrock. + # This option makes the Bedrock port the same as the Java port every time you start the server. + # This option is for the plugin version only. + clone-remote-port: false # The MOTD that will be broadcasted to Minecraft: Bedrock Edition clients. Irrelevant if "passthrough-motd" is set to true motd1: "GeyserMC" motd2: "Another GeyserMC forced host."