mirror of
https://github.com/CarmJos/MineSQL.git
synced 2026-06-04 16:43:03 +08:00
chore(deps): 适配上游更新。
This commit is contained in:
+43
-2
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>minesql-parent</artifactId>
|
||||
<groupId>cc.carm.plugin</groupId>
|
||||
<version>1.4.2</version>
|
||||
<version>1.4.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
@@ -114,7 +114,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-yaml</artifactId>
|
||||
<artifactId>configured-yaml</artifactId>
|
||||
<version>${deps.easyconf.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
@@ -127,6 +127,47 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>filter-version</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/templates</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${project.build.directory}/generated-sources/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cc.carm.plugin.minesql;
|
||||
|
||||
import cc.carm.lib.configuration.EasyConfiguration;
|
||||
import cc.carm.lib.configuration.yaml.YAMLConfigProvider;
|
||||
import cc.carm.lib.configuration.source.ConfigurationHolder;
|
||||
import cc.carm.lib.configuration.source.yaml.YAMLConfigFactory;
|
||||
import cc.carm.lib.easyplugin.utils.JarResourceUtils;
|
||||
import cc.carm.lib.easysql.api.SQLManager;
|
||||
import cc.carm.lib.easysql.api.SQLQuery;
|
||||
@@ -35,13 +35,11 @@ public class MineSQLCore implements IMineSQL {
|
||||
|
||||
protected static MineSQLCore instance;
|
||||
|
||||
public static final String REPO_OWNER = "CarmJos";
|
||||
public static final String REPO_NAME = "MineSQL";
|
||||
|
||||
protected final MineSQLPlatform platform;
|
||||
|
||||
protected final MineSQLRegistry registry;
|
||||
protected final YAMLConfigProvider configProvider;
|
||||
protected final ConfigurationHolder<?> configProvider;
|
||||
protected final PluginConfiguration config;
|
||||
|
||||
public MineSQLCore(MineSQLPlatform platform) {
|
||||
@@ -49,7 +47,7 @@ public class MineSQLCore implements IMineSQL {
|
||||
this.platform = platform;
|
||||
|
||||
getLogger().info("加载配置文件...");
|
||||
this.configProvider = EasyConfiguration.from(new File(platform.getPluginFolder(), "config.yml"));
|
||||
this.configProvider = YAMLConfigFactory.from(new File(platform.getPluginFolder(), "config.yml")).build();
|
||||
this.config = new PluginConfiguration();
|
||||
this.configProvider.initialize(this.config);
|
||||
|
||||
@@ -239,7 +237,7 @@ public class MineSQLCore implements IMineSQL {
|
||||
return config;
|
||||
}
|
||||
|
||||
public YAMLConfigProvider getConfigProvider() {
|
||||
public ConfigurationHolder<?> getConfigProvider() {
|
||||
return configProvider;
|
||||
}
|
||||
|
||||
@@ -300,8 +298,8 @@ public class MineSQLCore implements IMineSQL {
|
||||
public void checkUpdate(String currentVersion) {
|
||||
Logger logger = getLogger();
|
||||
|
||||
Integer behindVersions = GithubReleases4J.getVersionBehind(REPO_OWNER, REPO_NAME, currentVersion);
|
||||
String downloadURL = GithubReleases4J.getReleasesURL(REPO_OWNER, REPO_NAME);
|
||||
Integer behindVersions = GithubReleases4J.getVersionBehind(References.REPO_OWNER, References.REPO_NAME, currentVersion);
|
||||
String downloadURL = GithubReleases4J.getReleasesURL(References.REPO_OWNER, References.REPO_NAME);
|
||||
if (behindVersions == null) {
|
||||
logger.severe("检查更新失败,请您定期查看插件是否更新,避免安全问题。");
|
||||
logger.severe("下载地址 " + downloadURL);
|
||||
|
||||
@@ -1,69 +1,70 @@
|
||||
package cc.carm.plugin.minesql.conf;
|
||||
|
||||
import cc.carm.lib.configuration.core.ConfigurationRoot;
|
||||
import cc.carm.lib.configuration.core.annotation.HeaderComment;
|
||||
import cc.carm.lib.configuration.core.value.ConfigValue;
|
||||
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
|
||||
import cc.carm.lib.configuration.Configuration;
|
||||
import cc.carm.lib.configuration.annotation.ConfigPath;
|
||||
import cc.carm.lib.configuration.annotation.HeaderComments;
|
||||
import cc.carm.lib.configuration.value.standard.ConfiguredValue;
|
||||
|
||||
public class PluginConfiguration extends ConfigurationRoot {
|
||||
@ConfigPath(root = true)
|
||||
public class PluginConfiguration implements Configuration {
|
||||
|
||||
@HeaderComment("排错模式,一般留给开发者检查问题,平常使用无需开启。")
|
||||
public final ConfigValue<Boolean> DEBUG = ConfiguredValue.of(Boolean.class, false);
|
||||
@HeaderComments("排错模式,一般留给开发者检查问题,平常使用无需开启。")
|
||||
public final ConfiguredValue<Boolean> DEBUG = ConfiguredValue.of(Boolean.class, false);
|
||||
|
||||
@HeaderComment({"",
|
||||
@HeaderComments({"",
|
||||
"统计数据设定",
|
||||
"该选项用于帮助开发者统计插件版本与使用情况,且绝不会影响性能与使用体验。",
|
||||
"当然,您也可以选择在这里关闭,或在plugins/bStats下的配置文件中关闭所有插件的统计信息。"
|
||||
})
|
||||
public final ConfigValue<Boolean> METRICS = ConfiguredValue.of(Boolean.class, true);
|
||||
public final ConfiguredValue<Boolean> METRICS = ConfiguredValue.of(Boolean.class, true);
|
||||
|
||||
@HeaderComment({"",
|
||||
@HeaderComments({"",
|
||||
"检查更新设定",
|
||||
"该选项用于插件判断是否要检查更新,若您不希望插件检查更新并提示您,可以选择关闭。",
|
||||
"检查更新为异步操作,绝不会影响性能与使用体验。"
|
||||
})
|
||||
public ConfigValue<Boolean> UPDATE_CHECKER = ConfiguredValue.of(Boolean.class, true);
|
||||
public final ConfiguredValue<Boolean> UPDATE_CHECKER = ConfiguredValue.of(Boolean.class, true);
|
||||
|
||||
@HeaderComment({"插件注册池配置"})
|
||||
@HeaderComments({"插件注册池配置"})
|
||||
public final SettingsConfig SETTINGS = new SettingsConfig();
|
||||
|
||||
@HeaderComment({"",
|
||||
@HeaderComments({"",
|
||||
"Properties 数据库配置文件配置",
|
||||
"相关配置介绍(BeeCP) https://github.com/Chris2018998/BeeCP/wiki/Configuration--List#配置列表"
|
||||
})
|
||||
public final PropertiesConfig PROPERTIES = new PropertiesConfig();
|
||||
|
||||
@HeaderComment({"",
|
||||
@HeaderComments({"",
|
||||
"数据库源配置",
|
||||
"目前支持的驱动类型(type)有 mariadb、mysql、h2-file(文件数据库) 与 h2-mem(内存临时数据库)。",
|
||||
"详细配置介绍请查看 https://github.com/CarmJos/MineSQL/.doc/README.md"
|
||||
})
|
||||
public ConfigValue<SQLSourceGroup> SOURCES = ConfigValue.builder()
|
||||
.asValue(SQLSourceGroup.class).fromSection()
|
||||
.parseValue((w, d) -> SQLSourceGroup.parse(w))
|
||||
.serializeValue(SQLSourceGroup::serialize)
|
||||
public final ConfiguredValue<SQLSourceGroup> SOURCES = ConfiguredValue.builderOf(SQLSourceGroup.class)
|
||||
.fromSection()
|
||||
.parse((w, sec) -> SQLSourceGroup.parse(sec))
|
||||
.serialize(SQLSourceGroup::serialize)
|
||||
.defaults(SQLSourceGroup.defaults())
|
||||
.build();
|
||||
|
||||
public static class PropertiesConfig extends ConfigurationRoot {
|
||||
public static class PropertiesConfig implements Configuration {
|
||||
|
||||
@HeaderComment({"该选项用于启用 Properties 配置读取。", "若您不希望插件启用 Properties 文件配置功能,可以选择关闭。"})
|
||||
public ConfigValue<Boolean> ENABLE = ConfiguredValue.of(Boolean.class, true);
|
||||
@HeaderComments({"该选项用于启用 Properties 配置读取。", "若您不希望插件启用 Properties 文件配置功能,可以选择关闭。"})
|
||||
public ConfiguredValue<Boolean> ENABLE = ConfiguredValue.of(Boolean.class, true);
|
||||
|
||||
@HeaderComment({
|
||||
@HeaderComments({
|
||||
"文件夹路径,将读取该文件夹下的所有 .properties 文件,并以文件名为数据管理器名称。",
|
||||
"读取时,将排除以 “.” 开头的文件与非 .properties 文件。",
|
||||
"默认为 \"db-properties/\" 相对路径,指向“plugins/MineSQL/db-properties/”;",
|
||||
"该选项也支持绝对路径,但使用绝对路径时,请务必注意权限问题。"
|
||||
})
|
||||
public ConfigValue<String> FOLDER = ConfiguredValue.of(String.class, "db-properties/");
|
||||
public ConfiguredValue<String> FOLDER = ConfiguredValue.of(String.class, "db-properties/");
|
||||
|
||||
}
|
||||
|
||||
public static class SettingsConfig extends ConfigurationRoot {
|
||||
public static class SettingsConfig implements Configuration {
|
||||
|
||||
@HeaderComment({"在插件卸载时是否强制关闭活跃链接"})
|
||||
public ConfigValue<Boolean> FORCE_CLOSE = ConfiguredValue.of(Boolean.class, true);
|
||||
@HeaderComments({"在插件卸载时是否强制关闭活跃链接"})
|
||||
public ConfiguredValue<Boolean> FORCE_CLOSE = ConfiguredValue.of(Boolean.class, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cc.carm.plugin.minesql.conf;
|
||||
|
||||
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
|
||||
import cc.carm.lib.configuration.source.section.ConfigureSection;
|
||||
import cc.carm.plugin.minesql.MineSQL;
|
||||
import cc.carm.plugin.minesql.api.SQLDriverType;
|
||||
import cc.carm.plugin.minesql.api.conf.SQLDriverConfig;
|
||||
@@ -44,11 +44,11 @@ public class SQLSourceGroup {
|
||||
return new SQLSourceGroup(configs);
|
||||
}
|
||||
|
||||
public static @NotNull SQLSourceGroup parse(ConfigurationWrapper<?> rootSection) {
|
||||
public static @NotNull SQLSourceGroup parse(ConfigureSection rootSection) {
|
||||
LinkedHashMap<String, SQLDriverConfig> configs = new LinkedHashMap<>();
|
||||
for (String name : rootSection.getKeys(false)) {
|
||||
if (!rootSection.isConfigurationSection(name)) continue;
|
||||
ConfigurationWrapper<?> section = rootSection.getConfigurationSection(name);
|
||||
if (!rootSection.isSection(name)) continue;
|
||||
ConfigureSection section = rootSection.getSection(name);
|
||||
if (section == null) continue;
|
||||
SQLDriverConfig conf = parse(name, section);
|
||||
if (conf != null) configs.put(name, conf);
|
||||
@@ -56,7 +56,7 @@ public class SQLSourceGroup {
|
||||
return new SQLSourceGroup(configs);
|
||||
}
|
||||
|
||||
public static @Nullable SQLDriverConfig parse(String name, ConfigurationWrapper<?> section) {
|
||||
public static @Nullable SQLDriverConfig parse(String name, ConfigureSection section) {
|
||||
@Nullable String driverString = section.getString("type");
|
||||
@Nullable SQLDriverType driverType = SQLDriverType.parse(driverString);
|
||||
if (driverType == null) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package cc.carm.plugin.minesql;
|
||||
|
||||
public interface References {
|
||||
|
||||
String REPO_OWNER = "CarmJos";
|
||||
String REPO_NAME = "MineSQL";
|
||||
String VERSION = "${project.version}";
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user