1
mirror of https://github.com/CarmJos/MineSQL.git synced 2026-06-05 00:48:16 +08:00

chore(deps): 适配上游更新。

This commit is contained in:
2025-04-23 00:52:00 +08:00
parent 628de160a6
commit e877792fbf
18 changed files with 108 additions and 355 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>minesql-parent</artifactId> <artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId> <groupId>cc.carm.plugin</groupId>
<version>1.4.2</version> <version>1.4.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -11,7 +11,6 @@ import org.jetbrains.annotations.Nullable;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.io.File; import java.io.File;
import java.sql.SQLException;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.UUID; import java.util.UUID;
@@ -6,6 +6,7 @@ import cc.carm.plugin.minesql.api.SQLRegistry;
import cc.carm.plugin.minesql.api.source.SQLSourceConfig; import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
import cc.carm.plugin.minesql.api.table.SQLTablesRoot; import cc.carm.plugin.minesql.api.table.SQLTablesRoot;
import cc.carm.plugin.minesql.api.table.SimpleSQLTable; import cc.carm.plugin.minesql.api.table.SimpleSQLTable;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -19,9 +20,15 @@ import java.util.logging.Logger;
public class MineSQL { public class MineSQL {
private MineSQL() {
throw new UnsupportedOperationException("API Instance");
}
private static IMineSQL instance; private static IMineSQL instance;
protected static void initializeAPI(IMineSQL api) { @ApiStatus.Internal
@SuppressWarnings("ClassEscapesDefinedScope")
protected static void initializeAPI(@NotNull IMineSQL api) {
MineSQL.instance = api; MineSQL.instance = api;
} }
+43 -2
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>minesql-parent</artifactId> <artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId> <groupId>cc.carm.plugin</groupId>
<version>1.4.2</version> <version>1.4.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<properties> <properties>
@@ -114,7 +114,7 @@
<dependency> <dependency>
<groupId>cc.carm.lib</groupId> <groupId>cc.carm.lib</groupId>
<artifactId>easyconfiguration-yaml</artifactId> <artifactId>configured-yaml</artifactId>
<version>${deps.easyconf.version}</version> <version>${deps.easyconf.version}</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
@@ -127,6 +127,47 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
</plugin> </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> </plugins>
</build> </build>
@@ -1,7 +1,7 @@
package cc.carm.plugin.minesql; package cc.carm.plugin.minesql;
import cc.carm.lib.configuration.EasyConfiguration; import cc.carm.lib.configuration.source.ConfigurationHolder;
import cc.carm.lib.configuration.yaml.YAMLConfigProvider; import cc.carm.lib.configuration.source.yaml.YAMLConfigFactory;
import cc.carm.lib.easyplugin.utils.JarResourceUtils; import cc.carm.lib.easyplugin.utils.JarResourceUtils;
import cc.carm.lib.easysql.api.SQLManager; import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.SQLQuery; import cc.carm.lib.easysql.api.SQLQuery;
@@ -35,13 +35,11 @@ public class MineSQLCore implements IMineSQL {
protected static MineSQLCore instance; protected static MineSQLCore instance;
public static final String REPO_OWNER = "CarmJos";
public static final String REPO_NAME = "MineSQL";
protected final MineSQLPlatform platform; protected final MineSQLPlatform platform;
protected final MineSQLRegistry registry; protected final MineSQLRegistry registry;
protected final YAMLConfigProvider configProvider; protected final ConfigurationHolder<?> configProvider;
protected final PluginConfiguration config; protected final PluginConfiguration config;
public MineSQLCore(MineSQLPlatform platform) { public MineSQLCore(MineSQLPlatform platform) {
@@ -49,7 +47,7 @@ public class MineSQLCore implements IMineSQL {
this.platform = platform; this.platform = platform;
getLogger().info("加载配置文件..."); 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.config = new PluginConfiguration();
this.configProvider.initialize(this.config); this.configProvider.initialize(this.config);
@@ -239,7 +237,7 @@ public class MineSQLCore implements IMineSQL {
return config; return config;
} }
public YAMLConfigProvider getConfigProvider() { public ConfigurationHolder<?> getConfigProvider() {
return configProvider; return configProvider;
} }
@@ -300,8 +298,8 @@ public class MineSQLCore implements IMineSQL {
public void checkUpdate(String currentVersion) { public void checkUpdate(String currentVersion) {
Logger logger = getLogger(); Logger logger = getLogger();
Integer behindVersions = GithubReleases4J.getVersionBehind(REPO_OWNER, REPO_NAME, currentVersion); Integer behindVersions = GithubReleases4J.getVersionBehind(References.REPO_OWNER, References.REPO_NAME, currentVersion);
String downloadURL = GithubReleases4J.getReleasesURL(REPO_OWNER, REPO_NAME); String downloadURL = GithubReleases4J.getReleasesURL(References.REPO_OWNER, References.REPO_NAME);
if (behindVersions == null) { if (behindVersions == null) {
logger.severe("检查更新失败,请您定期查看插件是否更新,避免安全问题。"); logger.severe("检查更新失败,请您定期查看插件是否更新,避免安全问题。");
logger.severe("下载地址 " + downloadURL); logger.severe("下载地址 " + downloadURL);
@@ -1,69 +1,70 @@
package cc.carm.plugin.minesql.conf; package cc.carm.plugin.minesql.conf;
import cc.carm.lib.configuration.core.ConfigurationRoot; import cc.carm.lib.configuration.Configuration;
import cc.carm.lib.configuration.core.annotation.HeaderComment; import cc.carm.lib.configuration.annotation.ConfigPath;
import cc.carm.lib.configuration.core.value.ConfigValue; import cc.carm.lib.configuration.annotation.HeaderComments;
import cc.carm.lib.configuration.core.value.type.ConfiguredValue; import cc.carm.lib.configuration.value.standard.ConfiguredValue;
public class PluginConfiguration extends ConfigurationRoot { @ConfigPath(root = true)
public class PluginConfiguration implements Configuration {
@HeaderComment("排错模式,一般留给开发者检查问题,平常使用无需开启。") @HeaderComments("排错模式,一般留给开发者检查问题,平常使用无需开启。")
public final ConfigValue<Boolean> DEBUG = ConfiguredValue.of(Boolean.class, false); public final ConfiguredValue<Boolean> DEBUG = ConfiguredValue.of(Boolean.class, false);
@HeaderComment({"", @HeaderComments({"",
"统计数据设定", "统计数据设定",
"该选项用于帮助开发者统计插件版本与使用情况,且绝不会影响性能与使用体验。", "该选项用于帮助开发者统计插件版本与使用情况,且绝不会影响性能与使用体验。",
"当然,您也可以选择在这里关闭,或在plugins/bStats下的配置文件中关闭所有插件的统计信息。" "当然,您也可以选择在这里关闭,或在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(); public final SettingsConfig SETTINGS = new SettingsConfig();
@HeaderComment({"", @HeaderComments({"",
"Properties 数据库配置文件配置", "Properties 数据库配置文件配置",
"相关配置介绍(BeeCP) https://github.com/Chris2018998/BeeCP/wiki/Configuration--List#配置列表" "相关配置介绍(BeeCP) https://github.com/Chris2018998/BeeCP/wiki/Configuration--List#配置列表"
}) })
public final PropertiesConfig PROPERTIES = new PropertiesConfig(); public final PropertiesConfig PROPERTIES = new PropertiesConfig();
@HeaderComment({"", @HeaderComments({"",
"数据库源配置", "数据库源配置",
"目前支持的驱动类型(type)有 mariadb、mysql、h2-file(文件数据库) 与 h2-mem(内存临时数据库)。", "目前支持的驱动类型(type)有 mariadb、mysql、h2-file(文件数据库) 与 h2-mem(内存临时数据库)。",
"详细配置介绍请查看 https://github.com/CarmJos/MineSQL/.doc/README.md" "详细配置介绍请查看 https://github.com/CarmJos/MineSQL/.doc/README.md"
}) })
public ConfigValue<SQLSourceGroup> SOURCES = ConfigValue.builder() public final ConfiguredValue<SQLSourceGroup> SOURCES = ConfiguredValue.builderOf(SQLSourceGroup.class)
.asValue(SQLSourceGroup.class).fromSection() .fromSection()
.parseValue((w, d) -> SQLSourceGroup.parse(w)) .parse((w, sec) -> SQLSourceGroup.parse(sec))
.serializeValue(SQLSourceGroup::serialize) .serialize(SQLSourceGroup::serialize)
.defaults(SQLSourceGroup.defaults()) .defaults(SQLSourceGroup.defaults())
.build(); .build();
public static class PropertiesConfig extends ConfigurationRoot { public static class PropertiesConfig implements Configuration {
@HeaderComment({"该选项用于启用 Properties 配置读取。", "若您不希望插件启用 Properties 文件配置功能,可以选择关闭。"}) @HeaderComments({"该选项用于启用 Properties 配置读取。", "若您不希望插件启用 Properties 文件配置功能,可以选择关闭。"})
public ConfigValue<Boolean> ENABLE = ConfiguredValue.of(Boolean.class, true); public ConfiguredValue<Boolean> ENABLE = ConfiguredValue.of(Boolean.class, true);
@HeaderComment({ @HeaderComments({
"文件夹路径,将读取该文件夹下的所有 .properties 文件,并以文件名为数据管理器名称。", "文件夹路径,将读取该文件夹下的所有 .properties 文件,并以文件名为数据管理器名称。",
"读取时,将排除以 “.” 开头的文件与非 .properties 文件。", "读取时,将排除以 “.” 开头的文件与非 .properties 文件。",
"默认为 \"db-properties/\" 相对路径,指向“plugins/MineSQL/db-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({"在插件卸载时是否强制关闭活跃链接"}) @HeaderComments({"在插件卸载时是否强制关闭活跃链接"})
public ConfigValue<Boolean> FORCE_CLOSE = ConfiguredValue.of(Boolean.class, true); public ConfiguredValue<Boolean> FORCE_CLOSE = ConfiguredValue.of(Boolean.class, true);
} }
@@ -1,6 +1,6 @@
package cc.carm.plugin.minesql.conf; 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.MineSQL;
import cc.carm.plugin.minesql.api.SQLDriverType; import cc.carm.plugin.minesql.api.SQLDriverType;
import cc.carm.plugin.minesql.api.conf.SQLDriverConfig; import cc.carm.plugin.minesql.api.conf.SQLDriverConfig;
@@ -44,11 +44,11 @@ public class SQLSourceGroup {
return new SQLSourceGroup(configs); return new SQLSourceGroup(configs);
} }
public static @NotNull SQLSourceGroup parse(ConfigurationWrapper<?> rootSection) { public static @NotNull SQLSourceGroup parse(ConfigureSection rootSection) {
LinkedHashMap<String, SQLDriverConfig> configs = new LinkedHashMap<>(); LinkedHashMap<String, SQLDriverConfig> configs = new LinkedHashMap<>();
for (String name : rootSection.getKeys(false)) { for (String name : rootSection.getKeys(false)) {
if (!rootSection.isConfigurationSection(name)) continue; if (!rootSection.isSection(name)) continue;
ConfigurationWrapper<?> section = rootSection.getConfigurationSection(name); ConfigureSection section = rootSection.getSection(name);
if (section == null) continue; if (section == null) continue;
SQLDriverConfig conf = parse(name, section); SQLDriverConfig conf = parse(name, section);
if (conf != null) configs.put(name, conf); if (conf != null) configs.put(name, conf);
@@ -56,7 +56,7 @@ public class SQLSourceGroup {
return new SQLSourceGroup(configs); 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 String driverString = section.getString("type");
@Nullable SQLDriverType driverType = SQLDriverType.parse(driverString); @Nullable SQLDriverType driverType = SQLDriverType.parse(driverString);
if (driverType == null) { 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}";
}
+1 -8
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>minesql-parent</artifactId> <artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId> <groupId>cc.carm.plugin</groupId>
<version>1.4.2</version> <version>1.4.3</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -79,13 +79,6 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>net.byteflux</groupId>
<artifactId>libby-bukkit</artifactId>
<version>${deps.libby.version}</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.bstats</groupId> <groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId> <artifactId>bstats-bukkit</artifactId>
@@ -4,8 +4,6 @@ import cc.carm.lib.easyplugin.EasyPlugin;
import cc.carm.plugin.minesql.conf.PluginConfiguration; import cc.carm.plugin.minesql.conf.PluginConfiguration;
import co.aikar.commands.CommandManager; import co.aikar.commands.CommandManager;
import co.aikar.commands.PaperCommandManager; import co.aikar.commands.PaperCommandManager;
import net.byteflux.libby.BukkitLibraryManager;
import net.byteflux.libby.LibraryManager;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie; import org.bstats.charts.SimplePie;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -16,8 +14,6 @@ public class MineSQLBukkit extends EasyPlugin implements MineSQLPlatform {
protected static MineSQLBukkit instance; protected static MineSQLBukkit instance;
protected BukkitLibraryManager libraryManager;
protected MineSQLCore core; protected MineSQLCore core;
protected PaperCommandManager commandManager; protected PaperCommandManager commandManager;
@@ -25,9 +21,6 @@ public class MineSQLBukkit extends EasyPlugin implements MineSQLPlatform {
protected void load() { protected void load() {
MineSQLBukkit.instance = this; MineSQLBukkit.instance = this;
log("加载依赖管理器...");
this.libraryManager = new BukkitLibraryManager(this);
log("加载基础核心..."); log("加载基础核心...");
this.core = new MineSQLCore(this); this.core = new MineSQLCore(this);
} }
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>minesql-parent</artifactId> <artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId> <groupId>cc.carm.plugin</groupId>
<version>1.4.2</version> <version>1.4.3</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
-120
View File
@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.4.2</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<maven.javadoc.skip>true</maven.javadoc.skip>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<artifactId>minesql-platform-sponge</artifactId>
<name>MineSQL-Sponge</name>
<description>轻松(用)SQL的独立运行库Sponge版本插件。</description>
<url>https://github.com/CarmJos/MineSQL</url>
<developers>
<developer>
<id>huanmeng</id>
<name>huanmeng-qwq</name>
<email>huanmeng@huanmeng-qwq.com</email>
<roles>
<role>Contributor</role>
</roles>
</developer>
</developers>
<licenses>
<license>
<name>GNU General Public License v3.0</name>
<url>https://opensource.org/licenses/GPL-3.0</url>
</license>
</licenses>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/CarmJos/EasySQL-Plugin/issues</url>
</issueManagement>
<ciManagement>
<system>GitHub Actions</system>
<url>https://github.com/CarmJos/EasySQL-Plugin/actions/workflows/maven.yml</url>
</ciManagement>
<repositories>
<repository>
<id>sponge</id>
<url>https://repo.spongepowered.org/maven</url>
</repository>
</repositories>
<dependencies>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>minesql-core</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>ninja.leaping.configurate</groupId>
<artifactId>configurate-hocon</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-sponge</artifactId>
<version>${deps.bstats.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-sponge</artifactId>
<version>${deps.acf.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
@@ -1,122 +0,0 @@
package cc.carm.plugin.minesql;
import cc.carm.lib.easyplugin.utils.ColorParser;
import cc.carm.lib.easyplugin.utils.JarResourceUtils;
import cc.carm.plugin.minesql.conf.PluginConfiguration;
import co.aikar.commands.CommandManager;
import com.google.inject.Inject;
import net.kyori.adventure.text.Component;
import org.bstats.charts.SimplePie;
import org.bstats.sponge.Metrics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.api.Server;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.config.ConfigDir;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.Order;
import org.spongepowered.api.event.lifecycle.StartingEngineEvent;
import org.spongepowered.api.event.lifecycle.StoppingEngineEvent;
import org.spongepowered.plugin.PluginContainer;
import org.spongepowered.plugin.builtin.jvm.Plugin;
import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Optional;
/**
* @author huanmeng_qwq, CarmJos
*/
@Plugin("minesql")
public class MineSQLSponge implements MineSQLPlatform {
@Inject
@ConfigDir(sharedRoot = false)
private Path configDirectory;
@Inject
private org.apache.logging.log4j.Logger logger;
private final PluginContainer pluginContainer;
private final Metrics.Factory metricsFactory;
protected final MineSQLCore core;
// protected SpongeCommandManager commandManager;
@Inject
public MineSQLSponge(Metrics.Factory factory, PluginContainer pluginContainer) {
this.pluginContainer = pluginContainer;
this.metricsFactory = factory;
getLogger().info("加载基础核心...");
this.core = new MineSQLCore(this);
}
@Listener(order = Order.PRE)
public void starting(StartingEngineEvent<Server> e) {
outputInfo();
// getLogger().info("初始化指令管理器...");
// this.commandManager = new SpongeCommandManager(pluginContainer);
//
// getLogger().info("注册相关指令...");
// this.core.initializeCommands(getCommandManager());
if (getConfiguration().METRICS.getNotNull()) {
getLogger().info("启用统计数据...");
Metrics metrics = this.metricsFactory.make(14078);
metrics.addCustomChart(new SimplePie("update_check",
() -> getConfiguration().UPDATE_CHECKER.getNotNull() ? "ENABLED" : "DISABLED")
);
metrics.addCustomChart(new SimplePie("properties_configuration",
() -> getConfiguration().PROPERTIES.ENABLE.getNotNull() ? "ENABLED" : "DISABLED")
);
}
if (getConfiguration().UPDATE_CHECKER.getNotNull()) {
getLogger().info("开始检查更新,可能需要一小段时间...");
getLogger().info(" 如不希望检查更新,可在配置文件中关闭。");
Sponge.asyncScheduler().executor(pluginContainer)
.execute(() -> this.core.checkUpdate(getVersion()));
} else {
getLogger().info("已禁用检查更新,跳过。");
}
}
@Listener
public void disable(StoppingEngineEvent<Server> e) {
outputInfo();
logger.info("终止全部数据库连接...");
this.core.shutdownAll();
}
@Override
public @NotNull File getPluginFolder() {
return configDirectory.toFile();
}
public @NotNull PluginConfiguration getConfiguration() {
return this.core.getConfig();
}
public @NotNull java.util.logging.Logger getLogger() {
return java.util.logging.Logger.getLogger("MineSQL");
}
//fixme acf-sponge是基于sponge5编写的 无法使用
@Override
public @Nullable CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
return null;
}
public String getVersion() {
return pluginContainer.metadata().version().toString();
}
public void outputInfo() {
Optional.ofNullable(JarResourceUtils.readResource(this.getClass().getResourceAsStream("PLUGIN_INFO")))
.map(v -> ColorParser.parse(Arrays.asList(v)))
.ifPresent(list -> list.forEach(s -> Sponge.server().sendMessage(Component.text(s))));
}
}
@@ -1,39 +0,0 @@
{
"loader": {
"name": "java_plain",
"version": "1.0"
},
"license": "GPL-3.0-or-later",
"global": {
"version": "8.0.0",
"links": {
"homepage": "${project.url}",
"source": "${project.url}",
"issues": "${project.url}/issues"
},
"contributors": [
{
"name": "huanmeng",
"description": "ContributorContributor"
},
{
"name": "CarmJos",
"description": "Lead Developer"
}
],
"dependencies": [
{
"id": "spongeapi",
"version": "8.0.0"
}
]
},
"plugins": [
{
"id": "minesql",
"name": "MineSQL (EasySQL-Plugin)",
"entrypoint": "cc.carm.plugin.minesql.MineSQLSponge",
"description": "${project.description}"
}
]
}
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>minesql-parent</artifactId> <artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId> <groupId>cc.carm.plugin</groupId>
<version>1.4.2</version> <version>1.4.3</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -22,7 +22,8 @@ import java.nio.file.Path;
import java.util.logging.Logger; import java.util.logging.Logger;
@Plugin(id = "minesql", name = "MineSQL (EasySQL-Plugin)", version = "1.4.2", @Plugin(id = "minesql", name = "MineSQL (EasySQL-Plugin)",
version = References.VERSION,
description = "EasySQL Plugin For Velocity", description = "EasySQL Plugin For Velocity",
url = "https://github.com/CarmJos/MineSQL", url = "https://github.com/CarmJos/MineSQL",
authors = {"CarmJos", "GhostChu"} authors = {"CarmJos", "GhostChu"}
+1 -8
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>minesql-parent</artifactId> <artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId> <groupId>cc.carm.plugin</groupId>
<version>1.4.2</version> <version>1.4.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<properties> <properties>
@@ -34,13 +34,6 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>minesql-platform-sponge</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>${project.parent.groupId}</groupId> <groupId>${project.parent.groupId}</groupId>
<artifactId>minesql-platform-velocity</artifactId> <artifactId>minesql-platform-velocity</artifactId>
+2 -3
View File
@@ -12,7 +12,7 @@
<maven.compiler.encoding>UTF-8</maven.compiler.encoding> <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<deps.easysql.version>0.4.7</deps.easysql.version> <deps.easysql.version>0.4.7</deps.easysql.version>
<deps.easyconf.version>3.9.1</deps.easyconf.version> <deps.easyconf.version>4.1.4</deps.easyconf.version>
<deps.easyplugin.version>1.5.12</deps.easyplugin.version> <deps.easyplugin.version>1.5.12</deps.easyplugin.version>
<deps.beecp.version>4.1.7</deps.beecp.version> <deps.beecp.version>4.1.7</deps.beecp.version>
@@ -30,7 +30,7 @@
<groupId>cc.carm.plugin</groupId> <groupId>cc.carm.plugin</groupId>
<artifactId>minesql-parent</artifactId> <artifactId>minesql-parent</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>1.4.2</version> <version>1.4.3</version>
<modules> <modules>
<module>api</module> <module>api</module>
<module>core</module> <module>core</module>
@@ -38,7 +38,6 @@
<module>platforms/bukkit</module> <module>platforms/bukkit</module>
<module>platforms/bungee</module> <module>platforms/bungee</module>
<module>platforms/velocity</module> <module>platforms/velocity</module>
<module>platforms/sponge8</module>
<module>plugin</module> <module>plugin</module>
</modules> </modules>