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

fix(load): 修复插件加载时出现的问题

This commit is contained in:
2022-12-18 04:27:37 +08:00
parent 708d3f8f3f
commit fa30bdad81
7 changed files with 39 additions and 39 deletions
@@ -1,5 +1,7 @@
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.BungeeCommandManager;
import co.aikar.commands.CommandManager;
@@ -10,6 +12,8 @@ import org.bstats.charts.SimplePie;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.Arrays;
import java.util.Optional;
import java.util.logging.Logger;
public class MineSQLBungee extends Plugin implements MineSQLPlatform {
@@ -29,6 +33,7 @@ public class MineSQLBungee extends Plugin implements MineSQLPlatform {
@Override
public void onEnable() {
outputInfo();
getLogger().info("初始化指令管理器...");
this.commandManager = new BungeeCommandManager(this);
@@ -59,6 +64,7 @@ public class MineSQLBungee extends Plugin implements MineSQLPlatform {
@Override
public void onDisable() {
outputInfo();
getLogger().info("终止全部数据库连接...");
this.core.getRegistry().shutdownAll();
}
@@ -86,5 +92,11 @@ public class MineSQLBungee extends Plugin implements MineSQLPlatform {
return this.commandManager;
}
@SuppressWarnings("deprecation")
public void outputInfo() {
Optional.ofNullable(JarResourceUtils.readResource(this.getResourceAsStream("PLUGIN_INFO")))
.map(v -> ColorParser.parse(Arrays.asList(v)))
.ifPresent(list -> list.forEach(s -> ProxyServer.getInstance().getConsole().sendMessage(s)));
}
}
+8 -10
View File
@@ -66,6 +66,14 @@
<dependencies>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.1.1</version>
<scope>provided</scope>
</dependency>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>${project.parent.groupId}</groupId>
@@ -74,26 +82,16 @@
<scope>compile</scope>
</dependency>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-velocity</artifactId>
<version>3.0.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-velocity</artifactId>
<version>0.5.1-SNAPSHOT</version>
<optional>true</optional>
</dependency>
</dependencies>
@@ -30,8 +30,6 @@ import java.util.logging.Logger;
)
public class MineSQLVelocity implements MineSQLPlatform {
private static MineSQLVelocity instance;
private final ProxyServer server;
private final Logger logger;
private final File dataFolder;
@@ -45,7 +43,6 @@ public class MineSQLVelocity implements MineSQLPlatform {
public MineSQLVelocity(ProxyServer server, Logger logger,
@DataDirectory Path dataDirectory,
Metrics.Factory metricsFactory) {
instance = this;
this.server = server;
this.logger = logger;
this.dataFolder = dataDirectory.toFile();
@@ -57,7 +54,7 @@ public class MineSQLVelocity implements MineSQLPlatform {
@Subscribe(order = PostOrder.FIRST)
public void onInitialize(ProxyInitializeEvent event) {
outputInfo();
getLogger().info("初始化指令管理器...");
this.commandManager = new VelocityCommandManager(server, this);
@@ -87,18 +84,19 @@ public class MineSQLVelocity implements MineSQLPlatform {
@Subscribe(order = PostOrder.LAST)
public void onShutdown(ProxyShutdownEvent event) {
outputInfo();
getLogger().info("终止全部数据库连接...");
this.core.getRegistry().shutdownAll();
}
public static MineSQLVelocity getInstance() {
return instance;
}
public ProxyServer getServer() {
return server;
}
public @NotNull Logger getLogger() {
return logger;
}
public String getVersion() {
return this.server.getPluginManager().getPlugin("minesql")
.map(PluginContainer::getDescription)
@@ -110,9 +108,6 @@ public class MineSQLVelocity implements MineSQLPlatform {
return this.dataFolder;
}
public @NotNull Logger getLogger() {
return logger;
}
@Override
public @NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
@@ -123,5 +118,7 @@ public class MineSQLVelocity implements MineSQLPlatform {
return this.core.getConfig();
}
public void outputInfo() {
//TODO
}
}