From 4a4e6db36fc700d345a26e49881e1b2011adef57 Mon Sep 17 00:00:00 2001 From: Weihao Date: Sat, 8 May 2021 02:21:35 -0400 Subject: [PATCH] Allow random server id --- pom.xml | 2 +- .../imaginarycode/minecraft/redisbungee/RedisBungee.java | 3 +++ .../minecraft/redisbungee/RedisBungeeConfiguration.java | 8 +++++++- src/main/resources/example_config.yml | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 8905ce8..192a783 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.imaginarycode.minecraft RedisBungee - 0.6 + 0.6.1 diff --git a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java index 4c53fd2..0d9485e 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java @@ -415,6 +415,9 @@ public final class RedisBungee extends Plugin { final boolean useSSL = configuration.getBoolean("useSSL"); String redisPassword = configuration.getString("redis-password"); String serverId = configuration.getString("server-id"); + if (serverId == null || serverId.isEmpty()) { + serverId = UUID.randomUUID().toString(); + } if (redisPassword != null && (redisPassword.isEmpty() || redisPassword.equals("none"))) { redisPassword = null; diff --git a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeConfiguration.java b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeConfiguration.java index 8555133..474e4ab 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeConfiguration.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeConfiguration.java @@ -8,6 +8,7 @@ import redis.clients.jedis.JedisPool; import java.net.InetAddress; import java.util.List; +import java.util.UUID; public class RedisBungeeConfiguration { @Getter @@ -21,7 +22,12 @@ public class RedisBungeeConfiguration { public RedisBungeeConfiguration(JedisPool pool, Configuration configuration) { this.pool = pool; - this.serverId = configuration.getString("server-id"); + String serverId = configuration.getString("server-id"); + if (serverId == null || serverId.isEmpty()) { + serverId = UUID.randomUUID().toString(); + } + this.serverId = serverId; + this.registerBungeeCommands = configuration.getBoolean("register-bungee-commands", true); List stringified = configuration.getStringList("exempt-ip-addresses"); diff --git a/src/main/resources/example_config.yml b/src/main/resources/example_config.yml index b581a49..cd1649e 100644 --- a/src/main/resources/example_config.yml +++ b/src/main/resources/example_config.yml @@ -17,7 +17,7 @@ max-redis-connections: 8 useSSL: false # An identifier for this BungeeCord instance. -server-id: test1 +server-id: "" # Whether or not RedisBungee should install its version of regular BungeeCord commands. # Often, the RedisBungee commands are desired, but in some cases someone may wish to