feat: 优化代码,添加 auto-register-game-server 功能
This commit is contained in:
@@ -9,6 +9,7 @@ import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
||||
import cn.hamster3.mc.plugin.ball.common.entity.BallPlayerInfo;
|
||||
import cn.hamster3.mc.plugin.ball.common.event.BallActions;
|
||||
import cn.hamster3.mc.plugin.ball.common.event.server.ServerOnlineEvent;
|
||||
import cn.hamster3.mc.plugin.core.common.config.YamlConfig;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -55,7 +56,8 @@ public class HamsterBallPlugin extends JavaPlugin {
|
||||
StandardCopyOption.REPLACE_EXISTING
|
||||
);
|
||||
}
|
||||
BallBukkitAPI.init(configFile);
|
||||
YamlConfig config = YamlConfig.load(configFile);
|
||||
BallBukkitAPI.init(config);
|
||||
logger.info("已初始化 BallAPI");
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, "BallAPI 初始化失败", e);
|
||||
|
@@ -8,8 +8,6 @@ import cn.hamster3.mc.plugin.core.common.config.YamlConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -22,11 +20,10 @@ public class BallBukkitAPI extends BallAPI {
|
||||
return (BallBukkitAPI) instance;
|
||||
}
|
||||
|
||||
public static void init(@NotNull File configFile) throws IOException {
|
||||
public static void init(@NotNull YamlConfig config) {
|
||||
if (instance != null) {
|
||||
return;
|
||||
}
|
||||
YamlConfig config = YamlConfig.load(configFile);
|
||||
instance = new BallBukkitAPI(config);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ channel-prefix: ""
|
||||
# 如果一个群组服同时拥有多个 BC 入口
|
||||
# 且每个 BC 入口为不同的玩家名称分配不同的 UUID
|
||||
# (例如正版、盗版双入口,或网易多入口接同一个子服)
|
||||
# 则可以启用该功能以防止 UUID 紊乱的问题
|
||||
# 则可以启用该功能以防止同一个名称占用多个 UUID 的问题
|
||||
game-server-update-player-info: false
|
||||
|
||||
# 该选项仅在 game-server-update-player-info 为 true 时有效
|
||||
@@ -41,16 +41,18 @@ server-info:
|
||||
# 如果你需要让每个服务器单独存储仓鼠球信息
|
||||
# 这个选项就会很有用
|
||||
#datasource:
|
||||
# # 数据库链接驱动地址
|
||||
# driver: "com.mysql.jdbc.Driver"
|
||||
# # 数据库链接填写格式:
|
||||
# # 数据库链接驱动地址,旧版服务端(低于1.13)请使用:com.mysql.jdbc.Driver
|
||||
# driver: "com.mysql.cj.jdbc.Driver"
|
||||
# # MySQL数据库链接填写格式:
|
||||
# # jdbc:mysql://{数据库地址}:{数据库端口}/{使用的库名}?参数
|
||||
# # 除非你知道自己在做什么,否则不建议随意更改参数
|
||||
# url: "jdbc:mysql://localhost:3306/Test1?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
|
||||
# url: "jdbc:mysql://localhost:3306/Test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true"
|
||||
# # 如果你不需要做多端跨服,那么请使用 sqlite 作本地数据库 ↓
|
||||
# # driver: "org.sqlite.JDBC"
|
||||
# # url: "jdbc:sqlite:./plugins/HamsterCore/database.db"
|
||||
# # 用户名
|
||||
# username: "Test"
|
||||
# username: "root"
|
||||
# # 密码
|
||||
# password: "Test123.."
|
||||
# password: "Root123.."
|
||||
# # 最小闲置链接数
|
||||
# # 推荐值:1~3
|
||||
# minimum-idle: 0
|
||||
|
Reference in New Issue
Block a user