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

feat(lib): 独立数据库依赖加载,缩减文件体积。

This commit is contained in:
2023-03-16 01:12:25 +08:00
parent 6331cf2047
commit e6fad85438
16 changed files with 192 additions and 107 deletions
+10 -3
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.3.1</version>
<version>1.4.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -79,17 +79,24 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.byteflux</groupId>
<artifactId>libby-bukkit</artifactId>
<version>${deps.libby.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.0</version>
<version>${deps.bstats.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-paper</artifactId>
<version>0.5.1-SNAPSHOT</version>
<version>${deps.acf.version}</version>
<scope>compile</scope>
</dependency>
@@ -4,10 +4,11 @@ import cc.carm.lib.easyplugin.EasyPlugin;
import cc.carm.plugin.minesql.conf.PluginConfiguration;
import co.aikar.commands.CommandManager;
import co.aikar.commands.PaperCommandManager;
import net.byteflux.libby.BukkitLibraryManager;
import net.byteflux.libby.LibraryManager;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@@ -15,6 +16,8 @@ public class MineSQLBukkit extends EasyPlugin implements MineSQLPlatform {
protected static MineSQLBukkit instance;
protected BukkitLibraryManager libraryManager;
protected MineSQLCore core;
protected PaperCommandManager commandManager;
@@ -22,6 +25,9 @@ public class MineSQLBukkit extends EasyPlugin implements MineSQLPlatform {
protected void load() {
MineSQLBukkit.instance = this;
log("加载依赖管理器...");
this.libraryManager = new BukkitLibraryManager(this);
log("加载基础核心...");
this.core = new MineSQLCore(this);
}
@@ -75,10 +81,15 @@ public class MineSQLBukkit extends EasyPlugin implements MineSQLPlatform {
return this.core.getConfig();
}
public @Nullable CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
public @NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
return commandManager;
}
@Override
public @NotNull LibraryManager getLibraryManager() {
return this.libraryManager;
}
@Override
public @NotNull File getPluginFolder() {
return getDataFolder();
+10 -3
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.3.1</version>
<version>1.4.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -90,17 +90,24 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.byteflux</groupId>
<artifactId>libby-bungee</artifactId>
<version>${deps.libby.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bungeecord</artifactId>
<version>3.0.0</version>
<version>${deps.bstats.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-bungee</artifactId>
<version>0.5.1-SNAPSHOT</version>
<version>${deps.acf.version}</version>
<scope>compile</scope>
</dependency>
@@ -5,12 +5,13 @@ import cc.carm.lib.easyplugin.utils.JarResourceUtils;
import cc.carm.plugin.minesql.conf.PluginConfiguration;
import co.aikar.commands.BungeeCommandManager;
import co.aikar.commands.CommandManager;
import net.byteflux.libby.BungeeLibraryManager;
import net.byteflux.libby.LibraryManager;
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 org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.Arrays;
@@ -21,6 +22,8 @@ public class MineSQLBungee extends Plugin implements MineSQLPlatform {
protected static MineSQLBungee instance;
protected BungeeLibraryManager libraryManager;
protected MineSQLCore core;
protected BungeeCommandManager commandManager;
@@ -28,6 +31,9 @@ public class MineSQLBungee extends Plugin implements MineSQLPlatform {
public void onLoad() {
MineSQLBungee.instance = this;
getLogger().info("加载依赖管理器...");
this.libraryManager = new BungeeLibraryManager(this);
getLogger().info("加载基础核心...");
this.core = new MineSQLCore(this);
}
@@ -89,10 +95,15 @@ public class MineSQLBungee extends Plugin implements MineSQLPlatform {
}
@Override
public @Nullable CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
public @NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
return this.commandManager;
}
@Override
public @NotNull LibraryManager getLibraryManager() {
return this.libraryManager;
}
@SuppressWarnings("deprecation")
public void outputInfo() {
Optional.ofNullable(JarResourceUtils.readResource(this.getResourceAsStream("PLUGIN_INFO")))
+10 -4
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.3.1</version>
<version>1.4.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -84,18 +84,24 @@
</exclusions>
</dependency>
<dependency>
<groupId>net.byteflux</groupId>
<artifactId>libby-sponge</artifactId>
<version>${deps.libby.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-sponge</artifactId>
<version>3.0.0</version>
<optional>true</optional>
<version>${deps.bstats.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-sponge</artifactId>
<version>0.5.1-SNAPSHOT</version>
<version>${deps.acf.version}</version>
<scope>compile</scope>
</dependency>
@@ -5,6 +5,8 @@ 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.byteflux.libby.LibraryManager;
import net.byteflux.libby.SpongeLibraryManager;
import net.kyori.adventure.text.Component;
import org.bstats.charts.SimplePie;
import org.bstats.sponge.Metrics;
@@ -41,14 +43,17 @@ public class MineSQLSponge implements MineSQLPlatform {
private final PluginContainer pluginContainer;
private final Metrics.Factory metricsFactory;
protected final SpongeLibraryManager<MineSQLSponge> libraryManager;
protected final MineSQLCore core;
// protected SpongeCommandManager commandManager;
@Inject
public MineSQLSponge(Metrics.Factory factory,
PluginContainer pluginContainer) {
PluginContainer pluginContainer,
SpongeLibraryManager<MineSQLSponge> libraryManager) {
this.pluginContainer = pluginContainer;
this.metricsFactory = factory;
this.libraryManager = libraryManager;
getLogger().info("加载基础核心...");
this.core = new MineSQLCore(this);
@@ -110,6 +115,11 @@ public class MineSQLSponge implements MineSQLPlatform {
return null;
}
@Override
public @NotNull LibraryManager getLibraryManager() {
return this.libraryManager;
}
public String getVersion() {
return pluginContainer.metadata().version().toString();
}
+12 -3
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.3.1</version>
<version>1.4.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -82,16 +82,25 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.byteflux</groupId>
<artifactId>libby-velocity</artifactId>
<version>${deps.libby.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-velocity</artifactId>
<version>3.0.0</version>
<version>${deps.bstats.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-velocity</artifactId>
<version>0.5.1-SNAPSHOT</version>
<version>${deps.acf.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
@@ -16,11 +16,13 @@ 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.byteflux.libby.LibraryManager;
import net.byteflux.libby.VelocityLibraryManager;
import net.kyori.adventure.text.Component;
import org.bstats.charts.SimplePie;
import org.bstats.velocity.Metrics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.nio.file.Path;
@@ -29,7 +31,7 @@ import java.util.Optional;
import java.util.logging.Logger;
@Plugin(id = "minesql", name = "MineSQL (EasySQL-Plugin)", version = "1.3.1",
@Plugin(id = "minesql", name = "MineSQL (EasySQL-Plugin)", version = "1.3.2",
description = "EasySQL Plugin For Velocity",
url = "https://github.com/CarmJos/MineSQL",
authors = {"CarmJos", "GhostChu"}
@@ -41,6 +43,7 @@ public class MineSQLVelocity implements MineSQLPlatform {
private final File dataFolder;
private final Metrics.Factory metricsFactory;
protected VelocityLibraryManager<MineSQLVelocity> libraryManager;
protected MineSQLCore core;
protected VelocityCommandManager commandManager;
@@ -53,14 +56,19 @@ public class MineSQLVelocity implements MineSQLPlatform {
this.logger = logger;
this.dataFolder = dataDirectory.toFile();
this.metricsFactory = metricsFactory;
getLogger().info("加载基础核心...");
this.core = new MineSQLCore(this);
this.libraryManager = new VelocityLibraryManager<>(
LoggerFactory.getLogger("minesql"), dataDirectory,
server.getPluginManager(), this
);
}
@Subscribe(order = PostOrder.FIRST)
public void onInitialize(ProxyInitializeEvent event) {
outputInfo();
getLogger().info("加载基础核心...");
this.core = new MineSQLCore(this);
getLogger().info("初始化指令管理器...");
this.commandManager = new VelocityCommandManager(server, this);
@@ -116,10 +124,15 @@ public class MineSQLVelocity implements MineSQLPlatform {
@Override
public @Nullable CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
public @NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
return commandManager;
}
@Override
public @NotNull LibraryManager getLibraryManager() {
return this.libraryManager;
}
public @NotNull PluginConfiguration getConfiguration() {
return this.core.getConfig();
}