fix(ball-common): 提前对服务器 id 和 name 进行空判断

This commit is contained in:
2025-01-26 15:01:15 +08:00
parent 2a4a3e9065
commit 00dbcba628
2 changed files with 7 additions and 1 deletions

View File

@@ -46,7 +46,13 @@ public class BallServerInfo {
public BallServerInfo(@NotNull ConfigSection config, @NotNull BallServerType type) { public BallServerInfo(@NotNull ConfigSection config, @NotNull BallServerType type) {
Map<String, String> env = System.getenv(); Map<String, String> env = System.getenv();
id = env.getOrDefault("BALL_SERVER_ID", config.getString("id")); id = env.getOrDefault("BALL_SERVER_ID", config.getString("id"));
if (id == null || id.isEmpty()) {
throw new IllegalArgumentException("id 不能为空");
}
name = env.getOrDefault("BALL_SERVER_NAME", config.getString("name")); name = env.getOrDefault("BALL_SERVER_NAME", config.getString("name"));
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("name 不能为空");
}
this.type = type; this.type = type;
host = "0.0.0.0"; host = "0.0.0.0";
port = 0; port = 0;

View File

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