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

feat(proj): 项目完成,测试使用。

This commit is contained in:
2022-12-18 02:57:08 +08:00
parent 1557c14116
commit 5c30bea7eb
46 changed files with 1501 additions and 1497 deletions
+7 -62
View File
@@ -3,7 +3,7 @@
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>easysql-plugin</artifactId>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>0.0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
@@ -19,12 +19,12 @@
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<artifactId>easysql-plugin-bungee</artifactId>
<artifactId>minesql-bungee</artifactId>
<packaging>jar</packaging>
<name>EasySQL-Plugin-Bungee</name>
<name>MineSQL-Bungee</name>
<description>轻松(用)SQL的独立运行库Bungee版本插件。</description>
<url>https://github.com/CarmJos/EasySQL-Plugin</url>
<url>https://github.com/CarmJos/MineSQL</url>
<developers>
<developer>
@@ -48,12 +48,12 @@
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/CarmJos/EasySQL-Plugin/issues</url>
<url>https://github.com/CarmJos/MineSQL/issues</url>
</issueManagement>
<ciManagement>
<system>GitHub Actions</system>
<url>https://github.com/CarmJos/EasySQL-Plugin/actions/workflows/maven.yml</url>
<url>https://github.com/CarmJos/MineSQL/actions/workflows/maven.yml</url>
</ciManagement>
<repositories>
@@ -69,7 +69,7 @@
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>easysql-plugin-core</artifactId>
<artifactId>minesql-core</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
@@ -108,7 +108,6 @@
</dependencies>
<build>
<plugins>
<plugin>
@@ -123,60 +122,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<finalName>${project.name}-${project.version}</finalName>
<outputDirectory>${project.parent.basedir}/asset/</outputDirectory>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/*.txt</exclude>
<exclude>acf-minecraft*.properties</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>org.json</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.json</shadedPattern>
</relocation>
<relocation>
<pattern>cc.carm.lib.githubreleases4j</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.githubreleases4j</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.acf</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>co.aikar.locales</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.locales</shadedPattern> <!-- Replace this -->
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
@@ -1,65 +0,0 @@
package cc.carm.plugin.minesql;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
public class EasySQLBungee extends Plugin {
private boolean setup = false;
private void saveDefaultConfig() {
if (!getDataFolder().exists())
getDataFolder().mkdir();
File file = new File(getDataFolder(), "config.yml");
if (!file.exists()) {
try (InputStream in = getResourceAsStream("config.yml")) {
Files.copy(in, file.toPath());
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void setup() {
if (setup) return;
saveDefaultConfig();
// 读取配置文件 - 预注册 instance
Configuration configuration;
try {
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
} catch (IOException e) {
e.printStackTrace();
return;
}
Configuration instancesConfig = configuration.getSection("instances");
if (instancesConfig != null) {
}
setup = true;
}
@Override
public void onLoad() {
setup();
}
@Override
public void onEnable() {
setup();
}
@Override
public void onDisable() {
getLogger().info("Shutting down...");
}
}
@@ -0,0 +1,93 @@
package cc.carm.plugin.minesql;
import cc.carm.plugin.minesql.conf.PluginConfiguration;
import co.aikar.commands.BungeeCommandManager;
import co.aikar.commands.CommandManager;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import org.bstats.bungeecord.Metrics;
import org.bstats.charts.SimplePie;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.logging.Logger;
public class MineSQLBungee extends Plugin implements MineSQLPlatform {
protected static MineSQLBungee instance;
protected MineSQLCore core;
protected BungeeCommandManager commandManager;
@Override
public void onLoad() {
MineSQLBungee.instance = this;
getLogger().info("加载基础核心...");
this.core = new MineSQLCore(this);
getLogger().info("初始化MineSQL API...");
MineSQL.initializeAPI(this.core);
}
@Override
public void onEnable() {
getLogger().info("初始化指令管理器...");
this.commandManager = new BungeeCommandManager(this);
getLogger().info("注册相关指令...");
this.core.initializeCommands(getCommandManager());
if (getConfiguration().METRICS.getNotNull()) {
getLogger().info("启用统计数据...");
Metrics metrics = new Metrics(this, 14076);
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().PROPERTIES.ENABLE.getNotNull()) {
getLogger().info("开始检查更新,可能需要一小段时间...");
getLogger().info(" 如不希望检查更新,可在配置文件中关闭。");
ProxyServer.getInstance().getScheduler().runAsync(
this, () -> this.core.checkUpdate(getDescription().getVersion())
);
} else {
getLogger().info("已禁用检查更新,跳过。");
}
}
@Override
public void onDisable() {
getLogger().info("终止全部数据库连接...");
this.core.getRegistry().shutdownAll();
}
public static MineSQLBungee getInstance() {
return instance;
}
@Override
public @NotNull Logger getLogger() {
return super.getLogger();
}
public @NotNull PluginConfiguration getConfiguration() {
return this.core.getConfig();
}
@Override
public @NotNull File getPluginFolder() {
return getDataFolder();
}
@Override
public @NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
return this.commandManager;
}
}
@@ -0,0 +1,8 @@
main: cc.carm.plugin.minesql.MineSQLBungee
name: MineSQL
version: ${project.version}
website: ${project.url}
description: ${project.description}
author: "CarmJos"