1
mirror of https://github.com/CarmJos/MineSQL.git synced 2026-06-13 21:01:08 +08:00

Compare commits

...

20 Commits

Author SHA1 Message Date
carm 6331cf2047 fix(update): 修复更新检测配置读取错误的问题 2023-01-17 01:51:13 +08:00
carm f314ec4351 fix(update): 修复更新检测配置读取错误的问题 2023-01-16 22:34:25 +08:00
carm 6fc169ca30 chore(name): 修改项目模块名 2023-01-16 00:23:41 +08:00
carm 5b90969f81 build(deps): 移除重复依赖 2023-01-16 00:22:05 +08:00
carm 33c79affab build(plugin): 移除无用插件 2023-01-16 00:21:11 +08:00
carm f3b7653150 doc(api): 修正Branch库的位置 2023-01-15 16:19:24 +08:00
carm d2df91d45c feat(platform): Support Sponge8 (#4) 2023-01-14 21:07:37 +08:00
huanmeng_qwq 3d885a85a2 feat(platform): Sponge8 support (#4)
* feat(support): 恢复Sponge代码

(cherry picked from commit 58bddd86aa)

* Sponge8 support

* Sponge8 support

* Sponge8 support

Co-authored-by: carm <carm@carm.cc>
2023-01-14 18:05:10 +08:00
carm 3c45eb29bf fix(get): 修复获取首个Manager会出现报错的问题 2023-01-14 17:28:45 +08:00
carm 6456f0d2fe Revert "feat(support): 恢复Sponge代码"
This reverts commit 58bddd86aa.
2023-01-14 17:07:57 +08:00
carm 58bddd86aa feat(support): 恢复Sponge代码 2023-01-14 17:06:37 +08:00
carm 7dec1a1e5a doc(api): 修正Branch库的位置 2023-01-14 15:25:08 +08:00
carm ddf263c697 feat(get): 添加快速获取首个SQLManager实例的方法。 2023-01-05 19:18:17 +08:00
carm 054f9bb04c feat(table): 添加单独的表声明类及快速初始化表方法。 2023-01-03 20:52:24 +08:00
carm 8c9c6b72e2 doc: 修复语法错误 fix #3 2022-12-20 14:46:35 +08:00
carm 668df1d517 chore(conf): 修改配置文件注释 2022-12-20 09:45:42 +08:00
carm 0134b0f518 docs: 修复错误的示例配置文件 2022-12-20 09:43:33 +08:00
carm 7ca019bac9 docs: 修复排版问题 2022-12-19 19:19:50 +08:00
carm e8608adada docs: 修复排版问题 2022-12-19 19:14:30 +08:00
carm 6c82c6419b ci(javadoc): 修复部署问题 2022-12-19 19:13:01 +08:00
26 changed files with 620 additions and 82 deletions
+3 -3
View File
@@ -29,13 +29,13 @@ properties:
databases:
"example-mariadb": # 数据库源名称 不可包含“.” 以“example-”开头的数据源不会被加载
driver-type: mariadb
type: mariadb # MySQL / MariaDB 类型
host: 127.0.0.1 # 数据库地址
port: 3306 # 数据库端口
username: minecraft # 数据库用户名
password: password #数据库连接密码
database: minecraft #数据库名
"example-h2": # 数据库源名称 不可包含“.” 以“example-”开头的数据源不会被加载
driver-type: h2 #数据库驱动类型,目前支持 mariadb, mysql, h2
"example-h2":
type: h2-file
file: "example.db" #数据库文件路径,相对于“plugins/MineSQL/db-files/”
+2 -2
View File
@@ -13,7 +13,7 @@
<repository>
<id>MineSQL</id>
<name>GitHub Branch Repository</name>
<url>https://github.com/CarmJos/MineSQL/blob/repo/</url>
<url>https://raw.githubusercontent.com/CarmJos/MineSQL/repo/</url>
</repository>
</repositories>
```
@@ -22,6 +22,6 @@
```groovy
repositories {
maven { url 'https://github.com/CarmJos/MineSQL/blob/repo/' }
maven { url 'https://raw.githubusercontent.com/CarmJos/MineSQL/repo/' }
}
```
+2 -2
View File
@@ -63,14 +63,14 @@ jobs:
rm -rf deploy
mkdir -vp deploy
cp -vrf $HOME/local-deploy/* deploy/
cp -vrf .documentation/repository/REPO-README.md deploy/README.md
cp -vrf .doc/repository/REPO-README.md deploy/README.md
- name: "Copy Javadoc"
run: |
rm -rf docs
mkdir -vp docs
cp -vrf api/target/apidocs/* docs/
cp -vrf .documentation/javadoc/JAVADOC-README.md docs/README.md
cp -vrf .doc/javadoc/JAVADOC-README.md docs/README.md
- name: "Generate Javadoc sitemap"
id: sitemap
+5 -8
View File
@@ -22,11 +22,8 @@
### 对于服主 (插件使用者)
- 统一配置数据库连接,避免重复配置费时费力分神。
-
支持更高级更全面的配置方式,以根据不同的使用场景独立优化[连接池配置](https://github.com/Chris2018998/BeeCP/wiki/Configuration--List)
- 支持更高级更全面的配置方式,以根据不同的使
用场景独立优化[连接池配置](https://github.com/Chris2018998/BeeCP/wiki/Configuration--List)。
- 使相关插件共用连接池,避免每个插件单独新开连接池导致资源的浪费。
### 对于插件开发者
@@ -136,7 +133,7 @@ Properties 文件的文件名几位数据源的ID,允许为英文、数字、
<!--采用github分支依赖库,稳定更新快-->
<id>MineSQL</id>
<name>GitHub Branch Repository</name>
<url>https://github.com/CarmJos/MineSQL/blob/repo/</url>
<url>https://raw.githubusercontent.com/CarmJos/MineSQL/repo/</url>
</repository>
<repository>
@@ -173,7 +170,7 @@ repositories {
mavenCentral()
// 采用github分支依赖库,稳定更新快
maven { url 'https://github.com/CarmJos/MineSQL/blob/repo/' }
maven { url 'https://raw.githubusercontent.com/CarmJos/MineSQL/repo/' }
// 采用我的私人依赖库,简单方便,但可能因为变故而无法使用
maven { url 'https://repo.carm.cc/repository/maven-public/' }
@@ -207,7 +204,7 @@ public class Main extends JavaPlugin {
if (manager == null) {
System.out.println("请配置一个正确的数据库名。");
setEnable(false);
setEnabled(false);
return;
}
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.1.1</version>
<version>1.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -4,11 +4,14 @@ import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.SQLQuery;
import cc.carm.plugin.minesql.api.SQLRegistry;
import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
import cc.carm.plugin.minesql.api.table.SQLTablesRoot;
import cc.carm.plugin.minesql.api.table.SimpleSQLTable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.sql.DataSource;
import java.io.File;
import java.sql.SQLException;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
@@ -61,4 +64,18 @@ interface IMineSQL {
*/
void shutdown(SQLManager manager, @Nullable Consumer<Map<UUID, SQLQuery>> activeQueries);
/**
* 读取一个 {@link SQLTablesRoot} 中全部的 {@link SimpleSQLTable} 实例并初始化。
*
* @param tablesRoot {@link SQLTablesRoot}实例
*/
void createTables(@NotNull SQLTablesRoot tablesRoot) throws Exception;
/**
* 读取一个 {@link SQLTablesRoot}类中 中全部的静态 {@link SimpleSQLTable} 实例并初始化。
*
* @param tablesRootClazz {@link SQLTablesRoot}静态类
*/
void createTables(@NotNull Class<? extends SQLTablesRoot> tablesRootClazz) throws Exception;
}
@@ -4,6 +4,8 @@ import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.SQLQuery;
import cc.carm.plugin.minesql.api.SQLRegistry;
import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
import cc.carm.plugin.minesql.api.table.SQLTablesRoot;
import cc.carm.plugin.minesql.api.table.SimpleSQLTable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -114,4 +116,23 @@ public class MineSQL {
shutdown(manager, true);
}
/**
* 读取一个 {@link SQLTablesRoot} 中全部的 {@link SimpleSQLTable} 实例并初始化。
*
* @param tablesRoot {@link SQLTablesRoot}实例
*/
public static void createTables(@NotNull SQLTablesRoot tablesRoot) throws Exception {
instance.createTables(tablesRoot);
}
/**
* 读取一个 {@link SQLTablesRoot}类中 中全部的静态 {@link SimpleSQLTable} 实例并初始化。
*
* @param tablesRootClazz {@link SQLTablesRoot}静态类
*/
public static void createTables(@NotNull Class<? extends SQLTablesRoot> tablesRootClazz) throws Exception {
instance.createTables(tablesRootClazz);
}
}
@@ -12,6 +12,14 @@ import java.util.Optional;
* 入口类
*/
public interface SQLRegistry {
/**
* 获取原生注册的首个 SQLManager 实例
*
* @return {@link SQLManager} 实例
*/
default @Nullable SQLManager get() {
return get(null);
}
/**
* 获取原生注册的指定名称的 SQLManager 实例
@@ -0,0 +1,12 @@
package cc.carm.plugin.minesql.api.table;
import cc.carm.lib.easysql.api.function.SQLHandler;
import java.util.function.Supplier;
/**
* 表声明类的根节点,用于标注该类用于记录表的结构信息。
* <br> 创建表请使用 {@link SimpleSQLTable#of(String, String, Supplier, SQLHandler)}。
*/
public abstract class SQLTablesRoot {
}
@@ -0,0 +1,156 @@
package cc.carm.plugin.minesql.api.table;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateBatchAction;
import cc.carm.lib.easysql.api.builder.*;
import cc.carm.lib.easysql.api.function.SQLHandler;
import cc.carm.plugin.minesql.MineSQL;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.SQLException;
import java.util.Optional;
import java.util.function.Supplier;
public class SimpleSQLTable {
public static @NotNull SimpleSQLTable of(@NotNull String tableName,
@NotNull SQLHandler<TableCreateBuilder> tableBuilder) {
return new SimpleSQLTable(null, tableName, null, tableBuilder);
}
public static @NotNull SimpleSQLTable of(@Nullable String database, @NotNull String tableName,
@NotNull SQLHandler<TableCreateBuilder> tableBuilder) {
return new SimpleSQLTable(database, tableName, null, tableBuilder);
}
public static @NotNull SimpleSQLTable of(@Nullable String database, @NotNull String tableName,
@Nullable String tablePrefix, @NotNull SQLHandler<TableCreateBuilder> tableBuilder) {
return new SimpleSQLTable(database, tableName, () -> tablePrefix, tableBuilder);
}
public static @NotNull SimpleSQLTable of(@Nullable String database, @NotNull String tableName,
@Nullable Supplier<String> tablePrefix, @NotNull SQLHandler<TableCreateBuilder> tableBuilder) {
return new SimpleSQLTable(database, tableName, tablePrefix, tableBuilder);
}
protected final @Nullable String database;
protected final @NotNull String tableName;
protected final @Nullable Supplier<String> tablePrefix;
protected final @NotNull SQLHandler<TableCreateBuilder> tableCreator;
public SimpleSQLTable(@Nullable String database, @NotNull String tableName,
@Nullable Supplier<String> tablePrefix, @NotNull SQLHandler<TableCreateBuilder> table) {
this.database = database;
this.tableName = tableName;
this.tablePrefix = tablePrefix;
this.tableCreator = table;
}
public boolean create() throws SQLException {
SQLManager sqlManager = getSQLManager();
if (sqlManager == null) throw new SQLException(getExceptionReason());
TableCreateBuilder tableBuilder = sqlManager.createTable(getTableName());
tableCreator.accept(tableBuilder);
return tableBuilder.build().executeFunction(l -> l > 0, false);
}
public @Nullable String getDatabase() {
return database;
}
public @Nullable SQLManager getSQLManager() {
return MineSQL.getRegistry().get(getDatabase());
}
public @NotNull String getTableName() {
String prefix = getTablePrefix();
return (prefix != null ? prefix : "") + tableName;
}
public @Nullable String getTablePrefix() {
return Optional.ofNullable(tablePrefix).map(Supplier::get).orElse(null);
}
public @NotNull TableQueryBuilder createQuery() {
return Optional.ofNullable(getSQLManager()).map(this::createQuery)
.orElseThrow(() -> new NullPointerException(getExceptionReason()));
}
public @NotNull TableQueryBuilder createQuery(@NotNull SQLManager sqlManager) {
return sqlManager.createQuery().inTable(getTableName());
}
public @NotNull DeleteBuilder createDelete() {
return Optional.ofNullable(getSQLManager()).map(this::createDelete)
.orElseThrow(() -> new NullPointerException(getExceptionReason()));
}
public @NotNull DeleteBuilder createDelete(@NotNull SQLManager sqlManager) {
return sqlManager.createDelete(getTableName());
}
public @NotNull UpdateBuilder createUpdate() {
return Optional.ofNullable(getSQLManager()).map(this::createUpdate)
.orElseThrow(() -> new NullPointerException(getExceptionReason()));
}
public @NotNull UpdateBuilder createUpdate(@NotNull SQLManager sqlManager) {
return sqlManager.createUpdate(getTableName());
}
public @NotNull InsertBuilder<PreparedSQLUpdateAction<Integer>> createInsert() {
return Optional.ofNullable(getSQLManager()).map(this::createInsert)
.orElseThrow(() -> new NullPointerException(getExceptionReason()));
}
public @NotNull InsertBuilder<PreparedSQLUpdateAction<Integer>> createInsert(@NotNull SQLManager sqlManager) {
return sqlManager.createInsert(getTableName());
}
public @NotNull InsertBuilder<PreparedSQLUpdateBatchAction<Integer>> createInsertBatch() {
return Optional.ofNullable(getSQLManager()).map(this::createInsertBatch)
.orElseThrow(() -> new NullPointerException(getExceptionReason()));
}
public @NotNull InsertBuilder<PreparedSQLUpdateBatchAction<Integer>> createInsertBatch(@NotNull SQLManager sqlManager) {
return sqlManager.createInsertBatch(getTableName());
}
public @NotNull ReplaceBuilder<PreparedSQLUpdateAction<Integer>> createReplace() {
return Optional.ofNullable(getSQLManager()).map(this::createReplace)
.orElseThrow(() -> new NullPointerException(getExceptionReason()));
}
public @NotNull ReplaceBuilder<PreparedSQLUpdateAction<Integer>> createReplace(@NotNull SQLManager sqlManager) {
return sqlManager.createReplace(getTableName());
}
public @NotNull ReplaceBuilder<PreparedSQLUpdateBatchAction<Integer>> createReplaceBatch() {
return Optional.ofNullable(getSQLManager()).map(this::createReplaceBatch)
.orElseThrow(() -> new NullPointerException(getExceptionReason()));
}
public @NotNull ReplaceBuilder<PreparedSQLUpdateBatchAction<Integer>> createReplaceBatch(@NotNull SQLManager sqlManager) {
return sqlManager.createReplaceBatch(getTableName());
}
public @NotNull TableAlterBuilder alter() {
return Optional.ofNullable(getSQLManager()).map(this::alter)
.orElseThrow(() -> new NullPointerException(getExceptionReason()));
}
public @NotNull TableAlterBuilder alter(@NotNull SQLManager sqlManager) {
return sqlManager.alterTable(getTableName());
}
private String getExceptionReason() {
if (getDatabase() == null) return "Cannot find any SQLManager.";
else return "Cannot find any SQLManager for \"" + getDatabase() + "\".";
}
}
+1 -16
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.1.1</version>
<version>1.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
@@ -101,13 +101,6 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.carm.lib</groupId>
<artifactId>githubreleases4j</artifactId>
<version>1.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
@@ -131,18 +124,10 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>
@@ -8,6 +8,8 @@ import cc.carm.lib.easysql.api.SQLQuery;
import cc.carm.lib.easysql.manager.SQLManagerImpl;
import cc.carm.lib.githubreleases4j.GithubReleases4J;
import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
import cc.carm.plugin.minesql.api.table.SQLTablesRoot;
import cc.carm.plugin.minesql.api.table.SimpleSQLTable;
import cc.carm.plugin.minesql.command.MineSQLCommand;
import cc.carm.plugin.minesql.command.MineSQLHelpFormatter;
import cc.carm.plugin.minesql.conf.PluginConfiguration;
@@ -23,6 +25,8 @@ import org.jetbrains.annotations.Nullable;
import javax.sql.DataSource;
import java.io.File;
import java.lang.reflect.Field;
import java.sql.SQLException;
import java.util.*;
import java.util.function.Consumer;
import java.util.logging.Logger;
@@ -157,6 +161,48 @@ public class MineSQLCore implements IMineSQL {
}
}
@Override
public void createTables(@NotNull SQLTablesRoot tablesRoot) throws SQLException {
for (Field field : tablesRoot.getClass().getDeclaredFields()) {
initializeTableField(tablesRoot, field);
}
}
@Override
public void createTables(@NotNull Class<? extends SQLTablesRoot> clazz) throws SQLException {
initializeTableClass(clazz);
}
protected void initializeTableClass(@NotNull Class<?> clazz) throws SQLException {
if (!SQLTablesRoot.class.isAssignableFrom(clazz)) return;
for (Field field : clazz.getDeclaredFields()) {
initializeTableField(clazz, field);
}
for (Class<?> subClass : clazz.getDeclaredClasses()) {
initializeTableClass(subClass);
}
}
protected void initializeTableField(@NotNull Object source, @NotNull Field field) throws SQLException {
try {
field.setAccessible(true);
Object object = field.get(source);
if (object instanceof SimpleSQLTable) {
((SimpleSQLTable) object).create();
} else if (source instanceof SQLTablesRoot && object instanceof SQLTablesRoot) {
createTables((SQLTablesRoot) object);
} else if (source instanceof Class<?> && object instanceof Class<?>) {
// 当且仅当 源字段与字段 均为静态类时,才对目标字段进行下一步初始化加载。
initializeTableClass((Class<?>) object);
}
} catch (IllegalAccessException ignored) {
}
}
public void shutdownAll() {
this.registry.getManagers().forEach((k, manager) -> {
getLogger().info(" 正在关闭数据库 " + k + "...");
@@ -2,6 +2,7 @@ package cc.carm.plugin.minesql;
import co.aikar.commands.CommandManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.logging.Logger;
@@ -12,6 +13,6 @@ public interface MineSQLPlatform {
@NotNull Logger getLogger();
@NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager();
@Nullable CommandManager<?, ?, ?, ?, ?, ?> getCommandManager();
}
@@ -21,7 +21,9 @@ public class MineSQLRegistry implements SQLRegistry {
@Override
public @NotNull Optional<@Nullable SQLManager> getOptional(@Nullable String id) {
return Optional.of(this.managers.get(id));
if (id != null) return Optional.of(this.managers.get(id));
else if (managers.isEmpty()) return Optional.empty();
else return Optional.ofNullable(managers.values().iterator().next());
}
@Override
@@ -8,16 +8,16 @@ import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
public class PluginConfiguration extends ConfigurationRoot {
@HeaderComment("排错模式,一般留给开发者检查问题,平常使用无需开启。")
public ConfigValue<Boolean> DEBUG = ConfiguredValue.of(Boolean.class, false);
public final ConfigValue<Boolean> DEBUG = ConfiguredValue.of(Boolean.class, false);
@HeaderComment({
@HeaderComment({"",
"统计数据设定",
"该选项用于帮助开发者统计插件版本与使用情况,且绝不会影响性能与使用体验。",
"当然,您也可以选择在这里关闭,或在plugins/bStats下的配置文件中关闭所有插件的统计信息。"
})
public ConfigValue<Boolean> METRICS = ConfiguredValue.of(Boolean.class, true);
public final ConfigValue<Boolean> METRICS = ConfiguredValue.of(Boolean.class, true);
@HeaderComment({
@HeaderComment({"",
"检查更新设定",
"该选项用于插件判断是否要检查更新,若您不希望插件检查更新并提示您,可以选择关闭。",
"检查更新为异步操作,绝不会影响性能与使用体验。"
@@ -25,15 +25,15 @@ public class PluginConfiguration extends ConfigurationRoot {
public ConfigValue<Boolean> UPDATE_CHECKER = ConfiguredValue.of(Boolean.class, true);
@HeaderComment({"插件注册池配置"})
public SettingsConfig SETTINGS = new SettingsConfig();
public final SettingsConfig SETTINGS = new SettingsConfig();
@HeaderComment({
@HeaderComment({"",
"Properties 数据库配置文件配置",
"相关配置介绍(BeeCP) https://github.com/Chris2018998/BeeCP/wiki/Configuration--List#配置列表"
})
public PropertiesConfig PROPERTIES = new PropertiesConfig();
public final PropertiesConfig PROPERTIES = new PropertiesConfig();
@HeaderComment({
@HeaderComment({"",
"数据库源配置",
"目前支持的驱动类型(type)有 mariadb、mysql、h2-file(文件数据库) 与 h2-mem(内存临时数据库)。",
"详细配置介绍请查看 https://github.com/CarmJos/MineSQL/.doc/README.md"
@@ -47,7 +47,7 @@ public class PluginConfiguration extends ConfigurationRoot {
public static class PropertiesConfig extends ConfigurationRoot {
@HeaderComment("该选项用于启用 Properties 配置读取若您不希望插件启用 Properties 文件配置,可以选择关闭。")
@HeaderComment({"该选项用于启用 Properties 配置读取", "若您不希望插件启用 Properties 文件配置功能,可以选择关闭。"})
public ConfigValue<Boolean> ENABLE = ConfiguredValue.of(Boolean.class, true);
@HeaderComment({
+2 -6
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.1.1</version>
<version>1.3.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -19,7 +19,7 @@
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<artifactId>minesql-bukkit</artifactId>
<artifactId>minesql-platform-bukkit</artifactId>
<packaging>jar</packaging>
<name>MineSQL-Bukkit</name>
@@ -97,10 +97,6 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -2,10 +2,12 @@ package cc.carm.plugin.minesql;
import cc.carm.lib.easyplugin.EasyPlugin;
import cc.carm.plugin.minesql.conf.PluginConfiguration;
import co.aikar.commands.CommandManager;
import co.aikar.commands.PaperCommandManager;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@@ -43,7 +45,7 @@ public class MineSQLBukkit extends EasyPlugin implements MineSQLPlatform {
);
}
if (getConfiguration().PROPERTIES.ENABLE.getNotNull()) {
if (getConfiguration().UPDATE_CHECKER.getNotNull()) {
log("开始检查更新,可能需要一小段时间...");
log(" 如不希望检查更新,可在配置文件中关闭。");
getScheduler().runAsync(() -> this.core.checkUpdate(getDescription().getVersion()));
@@ -73,7 +75,7 @@ public class MineSQLBukkit extends EasyPlugin implements MineSQLPlatform {
return this.core.getConfig();
}
public @NotNull PaperCommandManager getCommandManager() {
public @Nullable CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
return commandManager;
}
+2 -6
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.1.1</version>
<version>1.3.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -19,7 +19,7 @@
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<artifactId>minesql-bungee</artifactId>
<artifactId>minesql-platform-bungee</artifactId>
<packaging>jar</packaging>
<name>MineSQL-Bungee</name>
@@ -108,10 +108,6 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -10,6 +10,7 @@ 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;
@@ -51,7 +52,7 @@ public class MineSQLBungee extends Plugin implements MineSQLPlatform {
);
}
if (getConfiguration().PROPERTIES.ENABLE.getNotNull()) {
if (getConfiguration().UPDATE_CHECKER.getNotNull()) {
getLogger().info("开始检查更新,可能需要一小段时间...");
getLogger().info(" 如不希望检查更新,可在配置文件中关闭。");
ProxyServer.getInstance().getScheduler().runAsync(
@@ -88,7 +89,7 @@ public class MineSQLBungee extends Plugin implements MineSQLPlatform {
}
@Override
public @NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
public @Nullable CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
return this.commandManager;
}
+121
View File
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
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>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.3.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
<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>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<artifactId>minesql-platform-sponge</artifactId>
<name>MineSQL-Sponge</name>
<description>轻松(用)SQL的独立运行库Sponge版本插件。</description>
<url>https://github.com/CarmJos/MineSQL</url>
<developers>
<developer>
<id>huanmeng</id>
<name>huanmeng-qwq</name>
<email>huanmeng@huanmeng-qwq.com</email>
<roles>
<role>Contributor</role>
</roles>
</developer>
</developers>
<licenses>
<license>
<name>GNU General Public License v3.0</name>
<url>https://opensource.org/licenses/GPL-3.0</url>
</license>
</licenses>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/CarmJos/EasySQL-Plugin/issues</url>
</issueManagement>
<ciManagement>
<system>GitHub Actions</system>
<url>https://github.com/CarmJos/EasySQL-Plugin/actions/workflows/maven.yml</url>
</ciManagement>
<repositories>
<repository>
<id>sponge</id>
<url>https://repo.spongepowered.org/maven</url>
</repository>
</repositories>
<dependencies>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>minesql-core</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>ninja.leaping.configurate</groupId>
<artifactId>configurate-hocon</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-sponge</artifactId>
<version>3.0.0</version>
<optional>true</optional>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-sponge</artifactId>
<version>0.5.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,123 @@
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.CommandManager;
import com.google.inject.Inject;
import net.kyori.adventure.text.Component;
import org.bstats.charts.SimplePie;
import org.bstats.sponge.Metrics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.api.Server;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.config.ConfigDir;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.Order;
import org.spongepowered.api.event.lifecycle.StartingEngineEvent;
import org.spongepowered.api.event.lifecycle.StoppingEngineEvent;
import org.spongepowered.plugin.PluginContainer;
import org.spongepowered.plugin.builtin.jvm.Plugin;
import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Optional;
/**
* @author huanmeng_qwq, CarmJos
*/
@Plugin("minesql")
public class MineSQLSponge implements MineSQLPlatform {
@Inject
@ConfigDir(sharedRoot = false)
private Path configDirectory;
@Inject
private org.apache.logging.log4j.Logger logger;
private final PluginContainer pluginContainer;
private final Metrics.Factory metricsFactory;
protected final MineSQLCore core;
// protected SpongeCommandManager commandManager;
@Inject
public MineSQLSponge(Metrics.Factory factory,
PluginContainer pluginContainer) {
this.pluginContainer = pluginContainer;
this.metricsFactory = factory;
getLogger().info("加载基础核心...");
this.core = new MineSQLCore(this);
}
@Listener(order = Order.PRE)
public void starting(StartingEngineEvent<Server> e) {
outputInfo();
// getLogger().info("初始化指令管理器...");
// this.commandManager = new SpongeCommandManager(pluginContainer);
//
// getLogger().info("注册相关指令...");
// this.core.initializeCommands(getCommandManager());
if (getConfiguration().METRICS.getNotNull()) {
getLogger().info("启用统计数据...");
Metrics metrics = this.metricsFactory.make(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().UPDATE_CHECKER.getNotNull()) {
getLogger().info("开始检查更新,可能需要一小段时间...");
getLogger().info(" 如不希望检查更新,可在配置文件中关闭。");
Sponge.asyncScheduler().executor(pluginContainer)
.execute(() -> this.core.checkUpdate(getVersion()));
} else {
getLogger().info("已禁用检查更新,跳过。");
}
}
@Listener
public void disable(StoppingEngineEvent<Server> e) {
outputInfo();
logger.info("终止全部数据库连接...");
this.core.shutdownAll();
}
@Override
public @NotNull File getPluginFolder() {
return configDirectory.toFile();
}
public @NotNull PluginConfiguration getConfiguration() {
return this.core.getConfig();
}
public @NotNull java.util.logging.Logger getLogger() {
return java.util.logging.Logger.getLogger("MineSQL");
}
//fixme acf-sponge是基于sponge5编写的 无法使用
@Override
public @Nullable CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
return null;
}
public String getVersion() {
return pluginContainer.metadata().version().toString();
}
public void outputInfo() {
Optional.ofNullable(JarResourceUtils.readResource(this.getClass().getResourceAsStream("PLUGIN_INFO")))
.map(v -> ColorParser.parse(Arrays.asList(v)))
.ifPresent(list -> list.forEach(s -> Sponge.server().sendMessage(Component.text(s))));
}
}
@@ -0,0 +1,39 @@
{
"loader": {
"name": "java_plain",
"version": "1.0"
},
"license": "GPL-3.0-or-later",
"global": {
"version": "8.0.0",
"links": {
"homepage": "${project.url}",
"source": "${project.url}",
"issues": "${project.url}/issues"
},
"contributors": [
{
"name": "huanmeng",
"description": "ContributorContributor"
},
{
"name": "CarmJos",
"description": "Lead Developer"
}
],
"dependencies": [
{
"id": "spongeapi",
"version": "8.0.0"
}
]
},
"plugins": [
{
"id": "minesql",
"name": "MineSQL (EasySQL-Plugin)",
"entrypoint": "cc.carm.plugin.minesql.MineSQLSponge",
"description": "${project.description}"
}
]
}
+2 -6
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.1.1</version>
<version>1.3.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -19,7 +19,7 @@
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<artifactId>minesql-velocity</artifactId>
<artifactId>minesql-platform-velocity</artifactId>
<packaging>jar</packaging>
<name>MineSQL-Velocity</name>
@@ -99,10 +99,6 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -1,6 +1,8 @@
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.CommandManager;
import co.aikar.commands.VelocityCommandManager;
@@ -14,16 +16,20 @@ 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.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 java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Optional;
import java.util.logging.Logger;
@Plugin(id = "minesql", name = "MineSQL (EasySQL-Plugin)", version = "1.0.0",
@Plugin(id = "minesql", name = "MineSQL (EasySQL-Plugin)", version = "1.3.1",
description = "EasySQL Plugin For Velocity",
url = "https://github.com/CarmJos/MineSQL",
authors = {"CarmJos", "GhostChu"}
@@ -72,7 +78,7 @@ public class MineSQLVelocity implements MineSQLPlatform {
);
}
if (getConfiguration().PROPERTIES.ENABLE.getNotNull()) {
if (getConfiguration().UPDATE_CHECKER.getNotNull()) {
getLogger().info("开始检查更新,可能需要一小段时间...");
getLogger().info(" 如不希望检查更新,可在配置文件中关闭。");
server.getScheduler().buildTask(this, () -> this.core.checkUpdate(getVersion())).schedule();
@@ -110,7 +116,7 @@ public class MineSQLVelocity implements MineSQLPlatform {
@Override
public @NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
public @Nullable CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
return commandManager;
}
@@ -119,6 +125,9 @@ public class MineSQLVelocity implements MineSQLPlatform {
}
public void outputInfo() {
Optional.ofNullable(JarResourceUtils.readResource(this.getClass().getResourceAsStream("PLUGIN_INFO")))
.map(v -> ColorParser.parse(Arrays.asList(v)))
.ifPresent(list -> list.forEach(s -> getServer().getConsoleCommandSource().sendMessage(Component.text(s))));
}
}
}
+19 -11
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.1.1</version>
<version>1.3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
@@ -22,21 +22,28 @@
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>minesql-bukkit</artifactId>
<artifactId>minesql-platform-bukkit</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>minesql-bungee</artifactId>
<artifactId>minesql-platform-bungee</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>minesql-velocity</artifactId>
<artifactId>minesql-platform-sponge</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>minesql-platform-velocity</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
@@ -45,10 +52,6 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -137,11 +140,13 @@
</relocation>
<relocation>
<pattern>com.google.protobuf</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.google.protobuf</shadedPattern> <!-- Replace this -->
<shadedPattern>cc.carm.plugin.minesql.lib.google.protobuf
</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>com.google.errorprone</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.google.errorprone</shadedPattern> <!-- Replace this -->
<shadedPattern>cc.carm.plugin.minesql.lib.google.errorprone
</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>com.github</pattern>
@@ -149,7 +154,8 @@
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.checkerframework</shadedPattern> <!-- Replace this -->
<shadedPattern>cc.carm.plugin.minesql.lib.checkerframework
</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>waffle</pattern>
@@ -172,6 +178,8 @@
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/*.txt</exclude>
<exclude>LICENSE</exclude>
<exclude>README</exclude>
</excludes>
</filter>
</filters>
+3 -1
View File
@@ -24,7 +24,7 @@
<groupId>cc.carm.plugin</groupId>
<artifactId>minesql-parent</artifactId>
<packaging>pom</packaging>
<version>1.1.1</version>
<version>1.3.1</version>
<modules>
<module>api</module>
<module>core</module>
@@ -32,6 +32,8 @@
<module>platforms/bukkit</module>
<module>platforms/bungee</module>
<module>platforms/velocity</module>
<module>platforms/sponge8</module>
<module>plugin</module>
</modules>