mirror of
https://github.com/CarmJos/MineSQL.git
synced 2026-06-04 16:43:03 +08:00
feat(proj): 项目完成,测试使用。
This commit is contained in:
@@ -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-velocity</artifactId>
|
||||
<artifactId>minesql-velocity</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EasySQL-Plugin-Velocity</name>
|
||||
<name>MineSQL-Velocity</name>
|
||||
<description>轻松(用)SQL的独立运行库Velocity版本插件。</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>
|
||||
@@ -68,7 +68,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>
|
||||
@@ -97,9 +97,9 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -114,37 +114,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>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package cc.carm.plugin.minesql;
|
||||
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
@Plugin(id = "easysql-plugin", name = "EasySQL-Plugin",
|
||||
version = "1.0.0",
|
||||
description = "EasySQL Plugin For Velocity",
|
||||
url = "https://github.com/CarmJos/EasySQL-Plugin",
|
||||
authors = {"CarmJos", "GhostChu"}
|
||||
)
|
||||
public class EasySQLVelocity {
|
||||
|
||||
private static EasySQLVelocity instance;
|
||||
|
||||
private final ProxyServer server;
|
||||
private final Logger logger;
|
||||
|
||||
@Inject
|
||||
public EasySQLVelocity(ProxyServer server, Logger logger) {
|
||||
instance = this;
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
// register listeners
|
||||
server.getEventManager().register(this, this);
|
||||
}
|
||||
|
||||
public static EasySQLVelocity getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ProxyServer getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onInitialize(ProxyInitializeEvent event) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package cc.carm.plugin.minesql;
|
||||
|
||||
|
||||
import cc.carm.plugin.minesql.conf.PluginConfiguration;
|
||||
import co.aikar.commands.CommandManager;
|
||||
import co.aikar.commands.VelocityCommandManager;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.PostOrder;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
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 org.bstats.charts.SimplePie;
|
||||
import org.bstats.velocity.Metrics;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
@Plugin(id = "minesql", name = "MineSQL (EasySQL-Plugin)", version = "1.0.0",
|
||||
description = "EasySQL Plugin For Velocity",
|
||||
url = "https://github.com/CarmJos/MineSQL",
|
||||
authors = {"CarmJos", "GhostChu"}
|
||||
)
|
||||
public class MineSQLVelocity implements MineSQLPlatform {
|
||||
|
||||
private static MineSQLVelocity instance;
|
||||
|
||||
private final ProxyServer server;
|
||||
private final Logger logger;
|
||||
private final File dataFolder;
|
||||
|
||||
private final Metrics.Factory metricsFactory;
|
||||
|
||||
protected MineSQLCore core;
|
||||
protected VelocityCommandManager commandManager;
|
||||
|
||||
@Inject
|
||||
public MineSQLVelocity(ProxyServer server, Logger logger,
|
||||
@DataDirectory Path dataDirectory,
|
||||
Metrics.Factory metricsFactory) {
|
||||
instance = this;
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
this.dataFolder = dataDirectory.toFile();
|
||||
this.metricsFactory = metricsFactory;
|
||||
|
||||
getLogger().info("加载基础核心...");
|
||||
this.core = new MineSQLCore(this);
|
||||
|
||||
getLogger().info("初始化MineSQL API...");
|
||||
MineSQL.initializeAPI(this.core);
|
||||
}
|
||||
|
||||
@Subscribe(order = PostOrder.FIRST)
|
||||
public void onInitialize(ProxyInitializeEvent event) {
|
||||
|
||||
getLogger().info("初始化指令管理器...");
|
||||
this.commandManager = new VelocityCommandManager(server, this);
|
||||
|
||||
getLogger().info("注册相关指令...");
|
||||
this.core.initializeCommands(getCommandManager());
|
||||
|
||||
if (getConfiguration().METRICS.getNotNull()) {
|
||||
getLogger().info("启用统计数据...");
|
||||
Metrics metrics = this.metricsFactory.make(this, 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().PROPERTIES.ENABLE.getNotNull()) {
|
||||
getLogger().info("开始检查更新,可能需要一小段时间...");
|
||||
getLogger().info(" 如不希望检查更新,可在配置文件中关闭。");
|
||||
server.getScheduler().buildTask(this, () -> this.core.checkUpdate(getVersion())).schedule();
|
||||
} else {
|
||||
getLogger().info("已禁用检查更新,跳过。");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(order = PostOrder.LAST)
|
||||
public void onShutdown(ProxyShutdownEvent event) {
|
||||
getLogger().info("终止全部数据库连接...");
|
||||
this.core.getRegistry().shutdownAll();
|
||||
}
|
||||
|
||||
public static MineSQLVelocity getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ProxyServer getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return this.server.getPluginManager().getPlugin("minesql")
|
||||
.map(PluginContainer::getDescription)
|
||||
.flatMap(PluginDescription::getVersion).orElse("1.0.0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull File getPluginFolder() {
|
||||
return this.dataFolder;
|
||||
}
|
||||
|
||||
public @NotNull Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public @NotNull PluginConfiguration getConfiguration() {
|
||||
return this.core.getConfig();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user