mirror of
https://github.com/CarmJos/MineSQL.git
synced 2026-06-05 00:48:16 +08:00
添加 PluginConfiguration 接口类
This commit is contained in:
@@ -37,14 +37,25 @@ public class EasySQLRegistryImpl implements EasySQLRegistry {
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
});
|
||||
Map<String, DBConfiguration> configurations = platform.readConfigurations();
|
||||
Map<String, Properties> dbProperties = platform.readProperties();
|
||||
Map<String, DBConfiguration> dbConfigurations = platform.readConfigurations();
|
||||
|
||||
if (configurations.isEmpty()) {
|
||||
if (dbProperties.isEmpty() && dbConfigurations.isEmpty()) {
|
||||
platform.getLogger().warning("未检测到任何数据库配置,将不会创建任何SQLManager。");
|
||||
return;
|
||||
}
|
||||
|
||||
configurations.forEach((id, configuration) -> {
|
||||
dbProperties.forEach((id, properties) -> {
|
||||
try {
|
||||
SQLManagerImpl sqlManager = create(id, properties);
|
||||
this.sqlManagerRegistry.put(id, sqlManager);
|
||||
} catch (Exception exception) {
|
||||
platform.getLogger().warning("初始化SQLManager(#" + id + ") 出错,请检查配置文件.");
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
dbConfigurations.forEach((id, configuration) -> {
|
||||
try {
|
||||
SQLManagerImpl sqlManager = create(id, configuration);
|
||||
this.sqlManagerRegistry.put(id, sqlManager);
|
||||
@@ -130,6 +141,10 @@ public class EasySQLRegistryImpl implements EasySQLRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
protected HashMap<String, SQLManagerImpl> getManagers() {
|
||||
return sqlManagerRegistry;
|
||||
}
|
||||
|
||||
public ExecutorService getExecutor() {
|
||||
return executorPool;
|
||||
}
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package cc.carm.plugin.easysql.configuration;
|
||||
|
||||
import cc.carm.plugin.easysql.api.DBConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface PluginConfiguration {
|
||||
|
||||
boolean isDebugEnabled();
|
||||
|
||||
boolean isMetricsEnabled();
|
||||
|
||||
boolean isUpdateCheckerEnabled();
|
||||
|
||||
boolean isPropertiesEnabled();
|
||||
|
||||
String getPropertiesFolder();
|
||||
|
||||
@NotNull Map<String, DBConfiguration> getDBConfigurations();
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package cc.carm.plugin.easysql.util;
|
||||
|
||||
import cc.carm.lib.githubreleases4j.GithubReleases4J;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class UpdateCheckUtil {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -23,11 +23,22 @@ properties:
|
||||
# 该选项也支持绝对路径,但使用绝对路径时,请务必注意权限问题。
|
||||
folder: "db-properties/"
|
||||
|
||||
configurations:
|
||||
"example-mariadb": # database id
|
||||
# 数据库源配置
|
||||
# 目前支持的驱动类型(driver-type)有 mariadb、mysql 与 h2(文件数据库) 。
|
||||
|
||||
databases:
|
||||
|
||||
"example-mariadb": # 数据库源名称 不可包含“.” 以“example-”开头的数据源不会被加载
|
||||
driver-type: mariadb
|
||||
url: 127.0.0.1 # 数据库地址
|
||||
host: 127.0.0.1 # 数据库地址
|
||||
port: 3306 # 数据库端口
|
||||
username: minecraft # 数据库用户名
|
||||
password: password #数据库连接密码
|
||||
database: minecraft #数据库名
|
||||
|
||||
"example-h2": # 数据库源名称 不可包含“.” 以“example-”开头的数据源不会被加载
|
||||
driver-type: h2 #数据库驱动类型,目前支持 mariadb, mysql, h2
|
||||
file: "example.db" #数据库文件路径,相对于“plugins/EasySQL-Plugin/db-files/”
|
||||
username: minecraft # 数据库用户名
|
||||
password: password #数据库连接密码
|
||||
database: minecraft #数据库名
|
||||
Reference in New Issue
Block a user