From ff9658a50b9374791455a8301c6039f7c8bc2d5a Mon Sep 17 00:00:00 2001
From: voruti <45130096+voruti@users.noreply.github.com>
Date: Sat, 22 Jul 2023 10:45:56 +0200
Subject: [PATCH] Renaming/refactoring
---
.../VelocityPlayerListQuery.java | 10 ++---
.../velocityplayerlistquery/model/Config.java | 38 +++++++++++--------
2 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/src/main/java/voruti/velocityplayerlistquery/VelocityPlayerListQuery.java b/src/main/java/voruti/velocityplayerlistquery/VelocityPlayerListQuery.java
index 1eeca9f..0a342bc 100644
--- a/src/main/java/voruti/velocityplayerlistquery/VelocityPlayerListQuery.java
+++ b/src/main/java/voruti/velocityplayerlistquery/VelocityPlayerListQuery.java
@@ -53,16 +53,16 @@ public class VelocityPlayerListQuery {
@Subscribe
- public void onProxyInitialization(ProxyInitializeEvent event) {
- reloadPlugin();
+ public void onProxyInitialization(ProxyInitializeEvent ignored) {
+ this.loadConfig();
}
@Subscribe
- public void onVelocityReload(ProxyReloadEvent event) {
- reloadPlugin();
+ public void onVelocityReload(ProxyReloadEvent ignored) {
+ this.loadConfig();
}
- private void reloadPlugin() {
+ private void loadConfig() {
this.config = new PersistenceService(logger, dataDirectory)
.loadConfig();
this.serverListEntryBuilder = new ServerListEntryBuilder(logger, config);
diff --git a/src/main/java/voruti/velocityplayerlistquery/model/Config.java b/src/main/java/voruti/velocityplayerlistquery/model/Config.java
index 7da05d8..be908f3 100644
--- a/src/main/java/voruti/velocityplayerlistquery/model/Config.java
+++ b/src/main/java/voruti/velocityplayerlistquery/model/Config.java
@@ -1,24 +1,26 @@
package voruti.velocityplayerlistquery.model;
+import lombok.Builder;
import lombok.Value;
import lombok.experimental.Accessors;
@Value
+@Builder
@Accessors(fluent = true)
public class Config {
public static final String FILE_NAME = "config.json";
- public static final Config DEFAULT_CONFIG = new Config(
- "%1$s",
- 16,
- false,
- false,
- false,
- false,
- "Unknown",
- 0
- );
+ public static final Config DEFAULT_CONFIG = new ConfigBuilder()
+ .serverListEntryFormat("%1$s")
+ .maxListEntries(16)
+ .setOnlinePlayers(false)
+ .setMaxPlayers(false)
+ .setVersion(false)
+ .onlySetUnsetVersion(false)
+ .versionName("Unknown")
+ .versionProtocol(0)
+ .build();
/**
@@ -31,17 +33,22 @@ public class Config {
String serverListEntryFormat;
/**
- * Configure how many players are shown in the server list. {@code <= 0} for unlimited (for backwards compatibility).
+ * Configure how many players are shown in the server list.
+ * {@code <= 0} for unlimited (for backwards compatibility).
*/
int maxListEntries;
+
/**
- * Should the online Players be replaced with Velocity Players?
+ * Should the online players be replaced with Velocity players?
+ * Useful when using ping-passthrough = "all"
.
*/
boolean setOnlinePlayers;
/**
- * Should the maximum Player count be replaced with the Velocity configured amount?
+ * Should the maximum player count be replaced with the Velocity configured amount?
+ * Useful when using ping-passthrough = "all"
.
*/
boolean setMaxPlayers;
+
/**
* Should version information be set?
*/
@@ -50,12 +57,13 @@ public class Config {
* Will only set version information, if the version information is undefined.
*/
boolean onlySetUnsetVersion;
+
/**
- * The version Name to be set
+ * The version name to be set.
*/
String versionName;
/**
- * The protocol to be set
+ * The protocol number to be set.
*/
int versionProtocol;
}