数据库新增自动重连机制,允许修改配置文件后直接重连不必再重启服务器

This commit is contained in:
zhangyuheng 2024-08-14 10:04:20 +08:00
parent 0e638e00b2
commit a321e39fe5
2 changed files with 11 additions and 1 deletions

View File

@ -4,7 +4,7 @@ plugins {
}
group = "cn.lunadeer"
version = "2.1.18-beta"
version = "2.1.19-beta"
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))

View File

@ -7,6 +7,8 @@ import cn.lunadeer.dominion.utils.MapRender;
import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.minecraftpluginutils.Scheduler;
import cn.lunadeer.minecraftpluginutils.XLogger;
import cn.lunadeer.minecraftpluginutils.databse.DatabaseManager;
import cn.lunadeer.minecraftpluginutils.databse.DatabaseType;
import org.bukkit.command.CommandSender;
import java.io.File;
@ -121,6 +123,14 @@ public class Operator {
Scheduler.runTaskAsync(() -> {
Notification.info(sender, "正在重新加载配置文件...");
Dominion.config.reload();
DatabaseManager.instance.reConnection(
DatabaseType.valueOf(Dominion.config.getDbType().toUpperCase()),
Dominion.config.getDbHost(),
Dominion.config.getDbPort(),
Dominion.config.getDbName(),
Dominion.config.getDbUser(),
Dominion.config.getDbPass()
);
Notification.info(sender, "配置文件已重新加载");
});
}