From 824235393461f447a15ea9051fbe6ebe62210760 Mon Sep 17 00:00:00 2001 From: DoNotSpamPls <7570108+DoNotSpamPls@users.noreply.github.com> Date: Mon, 24 Sep 2018 11:34:17 +0300 Subject: [PATCH] Add an option in the config to change the query map --- .../proxy/config/VelocityConfiguration.java | 14 ++++++++++++++ .../proxy/protocol/netty/GS4QueryHandler.java | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java b/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java index 303dbcd3f..3be6d2eb1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java @@ -208,6 +208,10 @@ public class VelocityConfiguration extends AnnotatedConfig { return query.getQueryPort(); } + public String getQueryMap() { + return query.getQueryMap(); + } + public String getMotd() { return motd; } @@ -482,6 +486,9 @@ public class VelocityConfiguration extends AnnotatedConfig { @Comment("If query responding is enabled, on what port should query response listener listen on?") @ConfigKey("port") private int queryPort = 25577; + @Comment("This is the map name that is reported to the query services.") + @ConfigKey("map") + private String queryMap = "Velocity"; private Query() { } @@ -489,12 +496,14 @@ public class VelocityConfiguration extends AnnotatedConfig { private Query(boolean queryEnabled, int queryPort) { this.queryEnabled = queryEnabled; this.queryPort = queryPort; + this.queryMap = queryMap; } private Query(Toml toml) { if (toml != null) { this.queryEnabled = toml.getBoolean("enabled", false); this.queryPort = toml.getLong("port", 25577L).intValue(); + this.queryMap = toml.getString("map", "Velocity"); } } @@ -506,11 +515,16 @@ public class VelocityConfiguration extends AnnotatedConfig { return queryPort; } + public String getQueryMap() { + return queryMap; + } + @Override public String toString() { return "Query{" + "queryEnabled=" + queryEnabled + ", queryPort=" + queryPort + + ", queryMap=" + queryMap + '}'; } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GS4QueryHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GS4QueryHandler.java index 2628bc445..79c7e6b08 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GS4QueryHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GS4QueryHandler.java @@ -110,7 +110,7 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler responseWriter.write("version", ProtocolConstants.SUPPORTED_GENERIC_VERSION_STRING); responseWriter.write("plugins", ""); - responseWriter.write("map", "Velocity"); + responseWriter.write("map", server.getConfiguration().getQueryMap()); responseWriter.write("numplayers", server.getPlayerCount()); responseWriter.write("maxplayers", server.getConfiguration().getShowMaxPlayers()); responseWriter.write("hostport", server.getConfiguration().getBind().getPort());