mirror of
https://github.com/CarmJos/MineSQL.git
synced 2026-06-05 00:48:16 +08:00
refactor(api): 重新设计API接口
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
<maven.javadoc.skip>true</maven.javadoc.skip>
|
||||
@@ -138,23 +138,23 @@
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>cc.carm.plugin.easysql.lib.bstats</shadedPattern>
|
||||
<shadedPattern>cc.carm.plugin.minesql.lib.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.json</pattern>
|
||||
<shadedPattern>cc.carm.plugin.easysql.lib.json</shadedPattern>
|
||||
<shadedPattern>cc.carm.plugin.minesql.lib.json</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>cc.carm.lib.githubreleases4j</pattern>
|
||||
<shadedPattern>cc.carm.plugin.easysql.lib.githubreleases4j</shadedPattern>
|
||||
<shadedPattern>cc.carm.plugin.minesql.lib.githubreleases4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.commands</pattern>
|
||||
<shadedPattern>cc.carm.plugin.easysql.lib.acf</shadedPattern> <!-- Replace this -->
|
||||
<shadedPattern>cc.carm.plugin.minesql.lib.acf</shadedPattern> <!-- Replace this -->
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.locales</pattern>
|
||||
<shadedPattern>cc.carm.plugin.easysql.lib.locales</shadedPattern> <!-- Replace this -->
|
||||
<shadedPattern>cc.carm.plugin.minesql.lib.locales</shadedPattern> <!-- Replace this -->
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
|
||||
+12
-12
@@ -1,10 +1,10 @@
|
||||
package cc.carm.plugin.easysql;
|
||||
package cc.carm.plugin.minesql;
|
||||
|
||||
import cc.carm.lib.easysql.api.SQLManager;
|
||||
import cc.carm.plugin.easysql.api.DBConfiguration;
|
||||
import cc.carm.plugin.easysql.configuration.PluginConfiguration;
|
||||
import cc.carm.plugin.easysql.util.DBPropertiesUtil;
|
||||
import cc.carm.plugin.easysql.util.JarResourceUtils;
|
||||
import cc.carm.plugin.minesql.api.DBConfiguration;
|
||||
import cc.carm.plugin.minesql.configuration.PluginConfiguration;
|
||||
import cc.carm.plugin.minesql.util.DBPropertiesUtil;
|
||||
import cc.carm.plugin.minesql.util.JarResourceUtils;
|
||||
import cn.beecp.BeeDataSource;
|
||||
import com.google.common.io.MoreFiles;
|
||||
import com.google.inject.Inject;
|
||||
@@ -39,30 +39,30 @@ import java.util.Properties;
|
||||
* @author huanmeng_qwq
|
||||
*/
|
||||
@Plugin("easysql-plugin")
|
||||
public class EasySQLSponge implements EasySQLPluginPlatform {
|
||||
public class MineSQLSponge implements MineSQLPlatform {
|
||||
@Inject
|
||||
@ConfigDir(sharedRoot = false)
|
||||
private Path configDirectory;
|
||||
@Inject
|
||||
private org.apache.logging.log4j.Logger logger;
|
||||
|
||||
private static EasySQLSponge instance;
|
||||
private static MineSQLSponge instance;
|
||||
private ConfigurationNode root;
|
||||
private PluginConfiguration configuration;
|
||||
private EasySQLRegistryImpl registry;
|
||||
private MineSQLRegistry registry;
|
||||
private PluginContainer pluginContainer;
|
||||
|
||||
private final Metrics metrics;
|
||||
|
||||
@Inject
|
||||
public EasySQLSponge(Metrics.Factory factory, PluginContainer pluginContainer) {
|
||||
public MineSQLSponge(Metrics.Factory factory, PluginContainer pluginContainer) {
|
||||
this.metrics = factory.make(14075);
|
||||
instance = this;
|
||||
HoconConfigurationLoader loader = HoconConfigurationLoader.builder().path(resolveConfig()).build();
|
||||
try {
|
||||
this.root = loader.load();
|
||||
this.configuration = new SpongeConfiguration(root);
|
||||
this.registry = new EasySQLRegistryImpl(this);
|
||||
this.registry = new MineSQLRegistry(this);
|
||||
this.pluginContainer = pluginContainer;
|
||||
enable();
|
||||
} catch (ConfigurateException ex) {
|
||||
@@ -166,7 +166,7 @@ public class EasySQLSponge implements EasySQLPluginPlatform {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull EasySQLRegistryImpl getRegistry() {
|
||||
public @NotNull MineSQLRegistry getRegistry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ public class EasySQLSponge implements EasySQLPluginPlatform {
|
||||
return java.util.logging.Logger.getLogger("easysql-plugin");
|
||||
}
|
||||
|
||||
public static EasySQLSponge getInstance() {
|
||||
public static MineSQLSponge getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
+7
-7
@@ -1,8 +1,8 @@
|
||||
package cc.carm.plugin.easysql;
|
||||
package cc.carm.plugin.minesql;
|
||||
|
||||
import cc.carm.plugin.easysql.api.DBConfiguration;
|
||||
import cc.carm.plugin.easysql.api.SQLDriverType;
|
||||
import cc.carm.plugin.easysql.configuration.PluginConfiguration;
|
||||
import cc.carm.plugin.minesql.api.DBConfiguration;
|
||||
import cc.carm.plugin.minesql.api.SQLDriverType;
|
||||
import cc.carm.plugin.minesql.configuration.PluginConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
@@ -60,18 +60,18 @@ public class SpongeConfiguration implements PluginConfiguration {
|
||||
String driverString = dbSection.getString("driver-type");
|
||||
SQLDriverType driverType = SQLDriverType.parse(driverString);
|
||||
if (driverType == null) {
|
||||
EasySQLSponge.getInstance().getLog().error("不存在预设的驱动类型 " + driverString + "," + " 请检查配置文件 databases." + dbEntry + "。");
|
||||
MineSQLSponge.getInstance().getLog().error("不存在预设的驱动类型 " + driverString + "," + " 请检查配置文件 databases." + dbEntry + "。");
|
||||
continue;
|
||||
}
|
||||
String host = dbSection.getString("host");
|
||||
if (host == null) {
|
||||
EasySQLSponge.getInstance().getLog().error("地址配置不得为空," + " 请检查配置文件 databases." + dbEntry + "。");
|
||||
MineSQLSponge.getInstance().getLog().error("地址配置不得为空," + " 请检查配置文件 databases." + dbEntry + "。");
|
||||
continue;
|
||||
}
|
||||
|
||||
int port = dbSection.node("port").getInt(-1);
|
||||
if (port < 0) {
|
||||
EasySQLSponge.getInstance().getLog().error("端口未配置正确," + " 请检查配置文件 databases." + dbEntry + "。");
|
||||
MineSQLSponge.getInstance().getLog().error("端口未配置正确," + " 请检查配置文件 databases." + dbEntry + "。");
|
||||
continue;
|
||||
}
|
||||
DBConfiguration dbConfiguration = DBConfiguration.create(driverType, host + ":" + port);
|
||||
Reference in New Issue
Block a user