Merge branch 'refs/heads/master' into dev

This commit is contained in:
2024-08-08 03:42:06 +08:00
7 changed files with 25 additions and 7 deletions

View File

@@ -49,9 +49,9 @@ repositories {
dependencies { dependencies {
// 对于 Bukkit 插件 // 对于 Bukkit 插件
compileOnly("cn.hamster3.mc.plugin:ball-bukkit:1.6.3") compileOnly("cn.hamster3.mc.plugin:ball-bukkit:1.6.4")
// 对于 BungeeCord 插件 // 对于 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 {
<dependency> <dependency>
<groupId>cn.hamster3.mc.plugin</groupId> <groupId>cn.hamster3.mc.plugin</groupId>
<artifactId>ball-bukkit</artifactId> <artifactId>ball-bukkit</artifactId>
<version>1.6.3</version> <version>1.6.4</version>
</dependency> </dependency>
<!--对于 BungeeCord 插件--> <!--对于 BungeeCord 插件-->
<dependency> <dependency>
<groupId>cn.hamster3.mc.plugin</groupId> <groupId>cn.hamster3.mc.plugin</groupId>
<artifactId>ball-bungee</artifactId> <artifactId>ball-bungee</artifactId>
<version>1.6.3</version> <version>1.6.4</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -1,6 +1,13 @@
# 是否允许在控制台输出调试信息 # 是否允许在控制台输出调试信息
debug: false debug: false
# 是否启用服务器 ID 单例模式
# 启用后,当一个服务器启动后将会占用 服务器唯一识别码
# 其他使用相同 服务器唯一识别码 的服务器将无法启动
# 测试端中可关闭该功能
# 推荐在正式服中开启该功能以防止服务器 ID 重复
singleton-server-id: false
# 频道名前缀 # 频道名前缀
# 使用这个配置选项可以划分子服消息通信分组 # 使用这个配置选项可以划分子服消息通信分组
# 只有在同一个频道名的子服才能互相通信 # 只有在同一个频道名的子服才能互相通信

View File

@@ -1,6 +1,10 @@
# 是否允许在控制台输出调试信息 # 是否允许在控制台输出调试信息
debug: false debug: false
# 是否启用服务器 ID 单例模式
# 启用后,服务器唯一识别码 相同的服务器将无法启动
singleton-server-id: false
# 频道名前缀 # 频道名前缀
# 使用这个配置选项可以划分子服消息通信分组 # 使用这个配置选项可以划分子服消息通信分组
# 只有在同一个频道名的子服才能互相通信 # 只有在同一个频道名的子服才能互相通信

View File

@@ -102,13 +102,13 @@ public abstract class BallAPI {
getLogger().warning("已启用调试模式"); getLogger().warning("已启用调试模式");
eventBus.register(BallDebugListener.INSTANCE); eventBus.register(BallDebugListener.INSTANCE);
} }
CoreAPI.getInstance().getExecutorService().submit(() -> redisSub.subscribe(BallRedisListener.INSTANCE, BALL_CHANNEL));
} }
protected void enable() throws SQLException, InterruptedException { protected void enable() throws SQLException, InterruptedException {
CoreAPI.getInstance().getExecutorService().submit(() -> redisSub.subscribe(BallRedisListener.INSTANCE, BALL_CHANNEL));
try (Jedis jedis = CoreAPI.getInstance().getJedisPool().getResource()) { try (Jedis jedis = CoreAPI.getInstance().getJedisPool().getResource()) {
String key = "HamsterBall:ServerInfo:" + localServerInfo.getId(); String key = "HamsterBall:ServerInfo:" + localServerInfo.getId();
if (jedis.exists(key)) { if (jedis.exists(key) && ballConfig.isSingletonServerID()) {
throw new IllegalStateException("已经有一个服务器占用了该 ID"); throw new IllegalStateException("已经有一个服务器占用了该 ID");
} }
jedis.hset(key, "id", localServerInfo.getId()); jedis.hset(key, "id", localServerInfo.getId());

View File

@@ -11,13 +11,16 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
public class BallConfig { public class BallConfig {
private boolean debug; private boolean debug;
private boolean singletonServerID;
@NotNull @NotNull
private String channelPrefix; private String channelPrefix;
private boolean gameServerUpdatePlayerInfo; private boolean gameServerUpdatePlayerInfo;
@NotNull
private List<String> loadPlayerInfoFilter; private List<String> loadPlayerInfoFilter;
public BallConfig(@NotNull ConfigSection config) { public BallConfig(@NotNull ConfigSection config) {
debug = config.getBoolean("debug", false); debug = config.getBoolean("debug", false);
singletonServerID = config.getBoolean("singleton-server-id", false);
channelPrefix = config.getString("channel-prefix", ""); channelPrefix = config.getString("channel-prefix", "");
channelPrefix = channelPrefix.isEmpty() ? channelPrefix : channelPrefix + ":"; channelPrefix = channelPrefix.isEmpty() ? channelPrefix : channelPrefix + ":";
gameServerUpdatePlayerInfo = config.getBoolean("game-server-update-player-info", false); gameServerUpdatePlayerInfo = config.getBoolean("game-server-update-player-info", false);

View File

@@ -1,6 +1,10 @@
# 是否允许在控制台输出调试信息 # 是否允许在控制台输出调试信息
debug: false debug: false
# 是否启用服务器 ID 单例模式
# 启用后,服务器唯一识别码 相同的服务器将无法启动
singleton-server-id: false
# 频道名前缀 # 频道名前缀
# 使用这个配置选项可以划分子服消息通信分组 # 使用这个配置选项可以划分子服消息通信分组
# 只有在同一个频道名的子服才能互相通信 # 只有在同一个频道名的子服才能互相通信

View File

@@ -5,7 +5,7 @@ plugins {
} }
group = "cn.hamster3.mc.plugin" group = "cn.hamster3.mc.plugin"
version = "1.6.3" version = "1.6.5-SNAPSHOT"
description = "基于 Redis 的 Minecraft 服务端通用消息中间件" description = "基于 Redis 的 Minecraft 服务端通用消息中间件"
subprojects { subprojects {