From e7363b4e9fb50743f7e8f5c9e71c0fa08ada3537 Mon Sep 17 00:00:00 2001 From: James Cahill Date: Tue, 18 Aug 2020 04:36:15 +0100 Subject: [PATCH] Add 'passthrough-protocol-name' config option (#1124) * Initial version (tested) * Don't bump config version * Misc changes * Add punctuation to config --- .../platform/sponge/GeyserSpongeConfiguration.java | 5 +++++ .../connector/configuration/GeyserConfiguration.java | 3 +++ .../configuration/GeyserJacksonConfiguration.java | 3 +++ .../geysermc/connector/network/QueryPacketHandler.java | 10 +++++++++- connector/src/main/resources/config.yml | 5 ++++- 5 files changed, 24 insertions(+), 2 deletions(-) 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 40fe106ce..7f08a0950 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 @@ -89,6 +89,11 @@ public class GeyserSpongeConfiguration implements GeyserConfiguration { return node.getNode("passthrough-motd").getBoolean(false); } + @Override + public boolean isPassthroughProtocolName() { + return node.getNode("passthrough-protocol-name").getBoolean(false); + } + @Override public boolean isPassthroughPlayerCounts() { return node.getNode("passthrough-player-counts").getBoolean(false); 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 be4182306..2cf9a181e 100644 --- a/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java +++ b/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java @@ -49,6 +49,9 @@ public interface GeyserConfiguration { @JsonIgnore boolean isPassthroughMotd(); + @JsonIgnore + boolean isPassthroughProtocolName(); + @JsonIgnore boolean isPassthroughPlayerCounts(); 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 1a22b0357..f322b4363 100644 --- a/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java +++ b/connector/src/main/java/org/geysermc/connector/configuration/GeyserJacksonConfiguration.java @@ -57,6 +57,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration @JsonProperty("passthrough-player-counts") private boolean isPassthroughPlayerCounts; + @JsonProperty("passthrough-protocol-name") + private boolean isPassthroughProtocolName; + @JsonProperty("legacy-ping-passthrough") private boolean isLegacyPingPassthrough; diff --git a/connector/src/main/java/org/geysermc/connector/network/QueryPacketHandler.java b/connector/src/main/java/org/geysermc/connector/network/QueryPacketHandler.java index bd67fd1b5..7faf36bdd 100644 --- a/connector/src/main/java/org/geysermc/connector/network/QueryPacketHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/QueryPacketHandler.java @@ -141,6 +141,7 @@ public class QueryPacketHandler { String motd; String currentPlayerCount; String maxPlayerCount; + String map; if (connector.getConfig().isPassthroughMotd() || connector.getConfig().isPassthroughPlayerCounts()) { pingInfo = connector.getBootstrap().getGeyserPingPassthrough().getPingInformation(); @@ -162,6 +163,13 @@ public class QueryPacketHandler { maxPlayerCount = String.valueOf(connector.getConfig().getMaxPlayers()); } + // If passthrough protocol name is enabled let's get the protocol name from the ping response. + if (connector.getConfig().isPassthroughProtocolName() && pingInfo != null) { + map = String.valueOf((pingInfo.getVersion().getName())); + } else { + map = GeyserConnector.NAME; + } + // Create a hashmap of all game data needed in the query Map gameData = new HashMap(); gameData.put("hostname", motd); @@ -169,7 +177,7 @@ public class QueryPacketHandler { gameData.put("game_id", "MINECRAFT"); gameData.put("version", BedrockProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion()); gameData.put("plugins", ""); - gameData.put("map", GeyserConnector.NAME); + gameData.put("map", map); gameData.put("numplayers", currentPlayerCount); gameData.put("maxplayers", maxPlayerCount); gameData.put("hostport", String.valueOf(connector.getConfig().getBedrock().getPort())); diff --git a/connector/src/main/resources/config.yml b/connector/src/main/resources/config.yml index d2bca8234..f59939b6a 100644 --- a/connector/src/main/resources/config.yml +++ b/connector/src/main/resources/config.yml @@ -53,9 +53,12 @@ floodgate-key-file: public-key.pem # Disabling this will prevent command suggestions from being sent and solve freezing for Bedrock clients. command-suggestions: true -# The following two options enable "ping passthrough" - the MOTD and/or player count gets retrieved from the Java server. +# The following three options enable "ping passthrough" -the MOTD, player count and/or protocol name gets retrieved from the Java server. # Relay the MOTD from the remote server to Bedrock players. passthrough-motd: false +# Relay the protocol name (e.g. BungeeCord [X.X], Paper 1.X) - only really useful when using a custom protocol name! +# This will also show up on sites like MCSrvStatus. +passthrough-protocol-name: false # Relay the player count and max players from the remote server to Bedrock players. passthrough-player-counts: false # Enable LEGACY ping passthrough. There is no need to enable this unless your MOTD or player count does not appear properly.