diff --git a/api/pom.xml b/api/pom.xml
index 6b32c81..2c6967f 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -5,7 +5,7 @@
minesql-parent
cc.carm.plugin
- 1.2.2
+ 1.3.0
4.0.0
diff --git a/core/pom.xml b/core/pom.xml
index a870d51..c24fd1e 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -5,7 +5,7 @@
minesql-parent
cc.carm.plugin
- 1.2.2
+ 1.3.0
4.0.0
diff --git a/platforms/bukkit/pom.xml b/platforms/bukkit/pom.xml
index 7eb3b6f..9322dd3 100644
--- a/platforms/bukkit/pom.xml
+++ b/platforms/bukkit/pom.xml
@@ -5,7 +5,7 @@
minesql-parent
cc.carm.plugin
- 1.2.2
+ 1.3.0
../../pom.xml
4.0.0
diff --git a/platforms/bungee/pom.xml b/platforms/bungee/pom.xml
index 83e6bb0..2724127 100644
--- a/platforms/bungee/pom.xml
+++ b/platforms/bungee/pom.xml
@@ -5,7 +5,7 @@
minesql-parent
cc.carm.plugin
- 1.2.2
+ 1.3.0
../../pom.xml
4.0.0
diff --git a/platforms/sponge8/pom.xml b/platforms/sponge8/pom.xml
index e825cd7..88ba901 100644
--- a/platforms/sponge8/pom.xml
+++ b/platforms/sponge8/pom.xml
@@ -5,7 +5,7 @@
minesql-parent
cc.carm.plugin
- 1.2.2
+ 1.3.0
../../pom.xml
4.0.0
@@ -94,7 +94,7 @@
co.aikar
- acf-core
+ acf-sponge
0.5.1-SNAPSHOT
compile
diff --git a/platforms/sponge8/src/main/java/cc/carm/plugin/minesql/MineSQLSponge.java b/platforms/sponge8/src/main/java/cc/carm/plugin/minesql/MineSQLSponge.java
index 7b37e6f..23a288c 100644
--- a/platforms/sponge8/src/main/java/cc/carm/plugin/minesql/MineSQLSponge.java
+++ b/platforms/sponge8/src/main/java/cc/carm/plugin/minesql/MineSQLSponge.java
@@ -1,9 +1,11 @@
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 org.apache.logging.log4j.Logger;
+import net.kyori.adventure.text.Component;
import org.bstats.charts.SimplePie;
import org.bstats.sponge.Metrics;
import org.jetbrains.annotations.NotNull;
@@ -12,6 +14,7 @@ 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;
@@ -19,50 +22,50 @@ import org.spongepowered.plugin.builtin.jvm.Plugin;
import java.io.File;
import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Optional;
/**
- * 2022/6/20
- * MineSQL
- *
- * @author huanmeng_qwq
+ * @author huanmeng_qwq, CarmJos
*/
@Plugin("minesql")
public class MineSQLSponge implements MineSQLPlatform {
- private static MineSQLSponge instance;
+ @Inject
@ConfigDir(sharedRoot = false)
private Path configDirectory;
+
@Inject
private org.apache.logging.log4j.Logger logger;
private final PluginContainer pluginContainer;
- private final Metrics metrics;
+ private final Metrics.Factory metricsFactory;
- protected MineSQLCore core;
+ protected final MineSQLCore core;
+// protected SpongeCommandManager commandManager;
@Inject
- public MineSQLSponge(Metrics.Factory factory, PluginContainer pluginContainer) {
- this.metrics = factory.make(14075);
- instance = this;
- this.core = new MineSQLCore(this);
+ public MineSQLSponge(Metrics.Factory factory,
+ PluginContainer pluginContainer) {
this.pluginContainer = pluginContainer;
+ this.metricsFactory = factory;
+
+ getLogger().info("加载基础核心...");
+ this.core = new MineSQLCore(this);
}
- @Listener
+ @Listener(order = Order.PRE)
public void starting(StartingEngineEvent e) {
- enable();
- }
+ outputInfo();
+// getLogger().info("初始化指令管理器...");
+// this.commandManager = new SpongeCommandManager(pluginContainer);
+//
+// getLogger().info("注册相关指令...");
+// this.core.initializeCommands(getCommandManager());
- @Listener
- public void disable(StoppingEngineEvent e) {
- logger.info("终止全部数据库连接...");
- this.core.shutdownAll();
- }
-
-
- public void enable() {
if (getConfiguration().METRICS.getNotNull()) {
- getLog().info("启用统计数据...");
+ getLogger().info("启用统计数据...");
+ Metrics metrics = this.metricsFactory.make(14078);
metrics.addCustomChart(new SimplePie("update_check",
() -> getConfiguration().UPDATE_CHECKER.getNotNull() ? "ENABLED" : "DISABLED")
);
@@ -72,25 +75,27 @@ public class MineSQLSponge implements MineSQLPlatform {
}
if (getConfiguration().PROPERTIES.ENABLE.getNotNull()) {
- logger.info("开始检查更新,可能需要一小段时间...");
- logger.info(" 如不希望检查更新,可在配置文件中关闭。");
+ getLogger().info("开始检查更新,可能需要一小段时间...");
+ getLogger().info(" 如不希望检查更新,可在配置文件中关闭。");
Sponge.asyncScheduler().executor(pluginContainer)
- .execute(() -> this.core.checkUpdate(pluginContainer.metadata().version().getQualifier()))
- ;
+ .execute(() -> this.core.checkUpdate(getVersion()));
} else {
- logger.info("已禁用检查更新,跳过。");
+ getLogger().info("已禁用检查更新,跳过。");
}
}
+ @Listener
+ public void disable(StoppingEngineEvent e) {
+ outputInfo();
+ logger.info("终止全部数据库连接...");
+ this.core.shutdownAll();
+ }
+
@Override
public @NotNull File getPluginFolder() {
return configDirectory.toFile();
}
- public static @NotNull MineSQLSponge getInstance() {
- return instance;
- }
-
public @NotNull PluginConfiguration getConfiguration() {
return this.core.getConfig();
}
@@ -105,8 +110,14 @@ public class MineSQLSponge implements MineSQLPlatform {
return null;
}
-
- private Logger getLog() {
- return logger;
+ 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))));
+ }
+
}
diff --git a/platforms/sponge8/src/main/resource/easysql.conf b/platforms/sponge8/src/main/resource/easysql.conf
deleted file mode 100644
index 291fa70..0000000
--- a/platforms/sponge8/src/main/resource/easysql.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-debug = false
-metrics = false
-check-update = true
-properties {
- enable = true
- folder = "db-properties/"
-}
-databases {
- example-test {
- driver-type = "MYSQL"
- host = "localhost"
- port = -1
- username = "root"
- password = "root"
- }
-}
-
diff --git a/platforms/sponge8/src/main/resources/META-INF/sponge_plugins.json b/platforms/sponge8/src/main/resources/META-INF/sponge_plugins.json
new file mode 100644
index 0000000..a4d5522
--- /dev/null
+++ b/platforms/sponge8/src/main/resources/META-INF/sponge_plugins.json
@@ -0,0 +1,39 @@
+{
+ "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}"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/platforms/velocity/pom.xml b/platforms/velocity/pom.xml
index d1dc855..e7731fb 100644
--- a/platforms/velocity/pom.xml
+++ b/platforms/velocity/pom.xml
@@ -5,7 +5,7 @@
minesql-parent
cc.carm.plugin
- 1.2.2
+ 1.3.0
../../pom.xml
4.0.0
diff --git a/platforms/velocity/src/main/java/cc/carm/plugin/minesql/MineSQLVelocity.java b/platforms/velocity/src/main/java/cc/carm/plugin/minesql/MineSQLVelocity.java
index e4670af..f79bd03 100644
--- a/platforms/velocity/src/main/java/cc/carm/plugin/minesql/MineSQLVelocity.java
+++ b/platforms/velocity/src/main/java/cc/carm/plugin/minesql/MineSQLVelocity.java
@@ -1,6 +1,8 @@
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 co.aikar.commands.VelocityCommandManager;
@@ -14,6 +16,7 @@ import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.plugin.PluginDescription;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
+import net.kyori.adventure.text.Component;
import org.bstats.charts.SimplePie;
import org.bstats.velocity.Metrics;
import org.jetbrains.annotations.NotNull;
@@ -21,6 +24,8 @@ import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Optional;
import java.util.logging.Logger;
@@ -120,6 +125,9 @@ public class MineSQLVelocity implements MineSQLPlatform {
}
public void outputInfo() {
-
+ Optional.ofNullable(JarResourceUtils.readResource(this.getClass().getResourceAsStream("PLUGIN_INFO")))
+ .map(v -> ColorParser.parse(Arrays.asList(v)))
+ .ifPresent(list -> list.forEach(s -> getServer().getConsoleCommandSource().sendMessage(Component.text(s))));
}
+
}
diff --git a/plugin/pom.xml b/plugin/pom.xml
index 87c7a6c..d4ca10d 100644
--- a/plugin/pom.xml
+++ b/plugin/pom.xml
@@ -5,7 +5,7 @@
minesql-parent
cc.carm.plugin
- 1.2.2
+ 1.3.0
4.0.0
@@ -34,6 +34,13 @@
compile
+
+ ${project.parent.groupId}
+ minesql-sponge
+ ${project.parent.version}
+ compile
+
+
${project.parent.groupId}
minesql-velocity
@@ -137,11 +144,13 @@
com.google.protobuf
- cc.carm.plugin.minesql.lib.google.protobuf
+ cc.carm.plugin.minesql.lib.google.protobuf
+
com.google.errorprone
- cc.carm.plugin.minesql.lib.google.errorprone
+ cc.carm.plugin.minesql.lib.google.errorprone
+
com.github
@@ -149,7 +158,8 @@
org.checkerframework
- cc.carm.plugin.minesql.lib.checkerframework
+ cc.carm.plugin.minesql.lib.checkerframework
+
waffle
@@ -172,6 +182,8 @@
META-INF/MANIFEST.MF
META-INF/*.txt
+ LICENSE
+ README
diff --git a/pom.xml b/pom.xml
index 99ed595..f67e4ba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
cc.carm.plugin
minesql-parent
pom
- 1.2.2
+ 1.3.0
api
core
@@ -33,6 +33,7 @@
platforms/bungee
platforms/velocity
platforms/sponge8
+
plugin