diff --git a/src/main/java/voruti/velocityplayerlistquery/VelocityPlayerListQuery.java b/src/main/java/voruti/velocityplayerlistquery/VelocityPlayerListQuery.java index ba4cc50..1389745 100644 --- a/src/main/java/voruti/velocityplayerlistquery/VelocityPlayerListQuery.java +++ b/src/main/java/voruti/velocityplayerlistquery/VelocityPlayerListQuery.java @@ -47,8 +47,8 @@ public class VelocityPlayerListQuery { @DataDirectory Path dataDirectory; - Config config; ServerListEntryBuilder serverListEntryBuilder; + Config config; @Subscribe @@ -66,9 +66,13 @@ public EventTask onServerPing(final ProxyPingEvent event) { return EventTask.async(() -> { final ServerPing serverPing = event.getPing(); - + final boolean versionUnset = serverPing.getVersion() == null || + serverPing.getVersion().getName().equals("Unknown") || + serverPing.getVersion().getProtocol() == 0 || + serverPing.getDescriptionComponent() == null; + final boolean setVersion = config.setVersion() || (config.onlySetUnsetVersion() && versionUnset); // check if server ping is invalid: - if (serverPing.getVersion() == null || serverPing.getDescriptionComponent() == null) { + if (versionUnset && !setVersion) { this.logger.info("Server ping is invalid, skipping"); return; } @@ -108,7 +112,7 @@ public EventTask onServerPing(final ProxyPingEvent event) { .samplePlayers(samplePlayers.toArray(new ServerPing.SamplePlayer[0])); if (config.setMaxPlayers()) ping.maximumPlayers(this.server.getConfiguration().getShowMaxPlayers()); if (config.setOnlinePlayers()) ping.onlinePlayers(players.size()); - + if (setVersion) ping.version(new ServerPing.Version(config.versionProtocol(), config.versionName())); event.setPing(ping.build()); } }); diff --git a/src/main/java/voruti/velocityplayerlistquery/model/Config.java b/src/main/java/voruti/velocityplayerlistquery/model/Config.java index 338d458..7da05d8 100644 --- a/src/main/java/voruti/velocityplayerlistquery/model/Config.java +++ b/src/main/java/voruti/velocityplayerlistquery/model/Config.java @@ -13,8 +13,12 @@ public class Config { "%1$s", 16, false, - false - ); + false, + false, + false, + "Unknown", + 0 + ); /** @@ -38,4 +42,20 @@ public class Config { * Should the maximum Player count be replaced with the Velocity configured amount? */ boolean setMaxPlayers; + /** + * Should version information be set? + */ + boolean setVersion; + /** + * Will only set version information, if the version information is undefined. + */ + boolean onlySetUnsetVersion; + /** + * The version Name to be set + */ + String versionName; + /** + * The protocol to be set + */ + int versionProtocol; }