diff --git a/README.md b/README.md
index eb2c4e0..1f3167d 100644
--- a/README.md
+++ b/README.md
@@ -49,9 +49,9 @@ repositories {
dependencies {
// 对于 Bukkit 插件
- compileOnly("cn.hamster3.mc.plugin:ball-bukkit:1.6.3")
+ compileOnly("cn.hamster3.mc.plugin:ball-bukkit:1.6.4")
// 对于 BungeeCord 插件
- compileOnly("cn.hamster3.mc.plugin:ball-bungee:1.6.3")
+ compileOnly("cn.hamster3.mc.plugin:ball-bungee:1.6.4")
}
```
@@ -77,13 +77,13 @@ dependencies {
cn.hamster3.mc.plugin
ball-bukkit
- 1.6.3
+ 1.6.4
cn.hamster3.mc.plugin
ball-bungee
- 1.6.3
+ 1.6.4
diff --git a/ball-bukkit/src/main/resources/config.yml b/ball-bukkit/src/main/resources/config.yml
index 780aedb..61c4411 100644
--- a/ball-bukkit/src/main/resources/config.yml
+++ b/ball-bukkit/src/main/resources/config.yml
@@ -1,6 +1,13 @@
# 是否允许在控制台输出调试信息
debug: false
+# 是否启用服务器 ID 单例模式
+# 启用后,当一个服务器启动后将会占用 服务器唯一识别码
+# 其他使用相同 服务器唯一识别码 的服务器将无法启动
+# 测试端中可关闭该功能
+# 推荐在正式服中开启该功能以防止服务器 ID 重复
+singleton-server-id: false
+
# 频道名前缀
# 使用这个配置选项可以划分子服消息通信分组
# 只有在同一个频道名的子服才能互相通信
diff --git a/ball-bungee/src/main/resources/config.yml b/ball-bungee/src/main/resources/config.yml
index cdee594..907f391 100644
--- a/ball-bungee/src/main/resources/config.yml
+++ b/ball-bungee/src/main/resources/config.yml
@@ -1,6 +1,10 @@
# 是否允许在控制台输出调试信息
debug: false
+# 是否启用服务器 ID 单例模式
+# 启用后,服务器唯一识别码 相同的服务器将无法启动
+singleton-server-id: false
+
# 频道名前缀
# 使用这个配置选项可以划分子服消息通信分组
# 只有在同一个频道名的子服才能互相通信
diff --git a/ball-common/src/main/java/cn/hamster3/mc/plugin/ball/common/api/BallAPI.java b/ball-common/src/main/java/cn/hamster3/mc/plugin/ball/common/api/BallAPI.java
index 05bb698..0769349 100644
--- a/ball-common/src/main/java/cn/hamster3/mc/plugin/ball/common/api/BallAPI.java
+++ b/ball-common/src/main/java/cn/hamster3/mc/plugin/ball/common/api/BallAPI.java
@@ -102,13 +102,13 @@ public abstract class BallAPI {
getLogger().warning("已启用调试模式");
eventBus.register(BallDebugListener.INSTANCE);
}
+ CoreAPI.getInstance().getExecutorService().submit(() -> redisSub.subscribe(BallRedisListener.INSTANCE, BALL_CHANNEL));
}
protected void enable() throws SQLException, InterruptedException {
- CoreAPI.getInstance().getExecutorService().submit(() -> redisSub.subscribe(BallRedisListener.INSTANCE, BALL_CHANNEL));
try (Jedis jedis = CoreAPI.getInstance().getJedisPool().getResource()) {
String key = "HamsterBall:ServerInfo:" + localServerInfo.getId();
- if (jedis.exists(key)) {
+ if (jedis.exists(key) && ballConfig.isSingletonServerID()) {
throw new IllegalStateException("已经有一个服务器占用了该 ID");
}
jedis.hset(key, "id", localServerInfo.getId());
diff --git a/ball-common/src/main/java/cn/hamster3/mc/plugin/ball/common/config/BallConfig.java b/ball-common/src/main/java/cn/hamster3/mc/plugin/ball/common/config/BallConfig.java
index da31e33..7e61829 100644
--- a/ball-common/src/main/java/cn/hamster3/mc/plugin/ball/common/config/BallConfig.java
+++ b/ball-common/src/main/java/cn/hamster3/mc/plugin/ball/common/config/BallConfig.java
@@ -11,13 +11,16 @@ import java.util.List;
@AllArgsConstructor
public class BallConfig {
private boolean debug;
+ private boolean singletonServerID;
@NotNull
private String channelPrefix;
private boolean gameServerUpdatePlayerInfo;
+ @NotNull
private List loadPlayerInfoFilter;
public BallConfig(@NotNull ConfigSection config) {
debug = config.getBoolean("debug", false);
+ singletonServerID = config.getBoolean("singleton-server-id", false);
channelPrefix = config.getString("channel-prefix", "");
channelPrefix = channelPrefix.isEmpty() ? channelPrefix : channelPrefix + ":";
gameServerUpdatePlayerInfo = config.getBoolean("game-server-update-player-info", false);
diff --git a/ball-velocity/src/main/resources/config.yml b/ball-velocity/src/main/resources/config.yml
index ac69770..2f15707 100644
--- a/ball-velocity/src/main/resources/config.yml
+++ b/ball-velocity/src/main/resources/config.yml
@@ -1,6 +1,10 @@
# 是否允许在控制台输出调试信息
debug: false
+# 是否启用服务器 ID 单例模式
+# 启用后,服务器唯一识别码 相同的服务器将无法启动
+singleton-server-id: false
+
# 频道名前缀
# 使用这个配置选项可以划分子服消息通信分组
# 只有在同一个频道名的子服才能互相通信
diff --git a/build.gradle.kts b/build.gradle.kts
index 5a5dd75..215aa86 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -5,7 +5,7 @@ plugins {
}
group = "cn.hamster3.mc.plugin"
-version = "1.6.3"
+version = "1.6.5-SNAPSHOT"
description = "基于 Redis 的 Minecraft 服务端通用消息中间件"
subprojects {