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

Compare commits

...

30 Commits

Author SHA1 Message Date
carm 40afd988e4 chore: 修改插件版本 2023-03-16 01:15:18 +08:00
carm fff84fafae chore: 移除无用代码。 2023-03-16 01:14:35 +08:00
carm e6fad85438 feat(lib): 独立数据库依赖加载,缩减文件体积。 2023-03-16 01:12:25 +08:00
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
carm 010b5d846a ci(deploy): 修复部署问题 2022-12-19 19:09:07 +08:00
carm 1c650b53eb ci(deploy): 修复部署问题 2022-12-19 19:08:17 +08:00
carm e001050f15 docs: 补充开发文档 2022-12-19 19:05:13 +08:00
carm a461932135 docs: 补充使用场景 2022-12-19 18:59:38 +08:00
carm 5ecd7f54e2 ci(deploy): 支持三处同时部署 2022-12-19 18:46:38 +08:00
carm 2321ed35c2 refactor(api): 支持独立创建注册池,便于插件内部管理链接 2022-12-19 18:07:34 +08:00
carm 38afb05fc8 build(scm): 补全缺失的项目配置 2022-12-18 04:55:44 +08:00
31 changed files with 1112 additions and 378 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/”
+27
View File
@@ -0,0 +1,27 @@
# MineSQL Repository
采用github的repo分支进行依赖,随项目发布而自动更新。
其他依赖方式见主页介绍。
## 依赖方式
### Maven
```xml
<repositories>
<repository>
<id>MineSQL</id>
<name>GitHub Branch Repository</name>
<url>https://raw.githubusercontent.com/CarmJos/MineSQL/repo/</url>
</repository>
</repositories>
```
### Gradle
```groovy
repositories {
maven { url 'https://raw.githubusercontent.com/CarmJos/MineSQL/repo/' }
}
```
+77 -2
View File
@@ -8,8 +8,8 @@ on:
types: [ published ]
jobs:
gh-deploy:
name: "Deploy Project (GitHub)"
packages-deploy:
name: "Deploy Project (GitHub Packages)"
runs-on: ubuntu-latest
steps:
@@ -43,6 +43,81 @@ jobs:
asset_path: ".asset/*.jar"
asset_content_type: application/java-archive
github-deploy:
name: "Deploy Project (GitHub Repo)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Set up JDK"
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
cache: maven
- name: "Maven Deploy"
run: mvn -B -Plocal deploy --file pom.xml -DskipTests -Dgpg.skip
- name: "Copy artifacts"
run: |
rm -rf deploy
mkdir -vp deploy
cp -vrf $HOME/local-deploy/* deploy/
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 .doc/javadoc/JAVADOC-README.md docs/README.md
- name: "Generate Javadoc sitemap"
id: sitemap
uses: cicirello/generate-sitemap@v1
with:
base-url-path: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
path-to-root: docs
- name: "Output Javadoc stats"
run: |
echo "sitemap-path = ${{ steps.sitemap.outputs.sitemap-path }}"
echo "url-count = ${{ steps.sitemap.outputs.url-count }}"
echo "excluded-count = ${{ steps.sitemap.outputs.excluded-count }}"
ls -l docs
- name: "Configure Git"
env:
DEPLOY_PRI: ${{secrets.DEPLOY_PRI}}
run: |
sudo timedatectl set-timezone "Asia/Shanghai"
mkdir -p ~/.ssh/
echo "$DEPLOY_PRI" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
git config --global user.name '${{ github.repository_owner }}'
git config --global user.email '${{ github.repository_owner }}@users.noreply.github.com'
- name: "Commit&Push repository files"
run: |
cd deploy
git init
git remote add origin git@github.com:${{ github.repository_owner }}/${{ github.event.repository.name }}.git
git checkout -b repo
git add -A
git commit -m "Maven project deployment."
git push origin HEAD:repo --force
- name: "Commit&Push API documentation"
run: |
cd docs
git init
git remote add origin git@github.com:${{ github.repository_owner }}/${{ github.event.repository.name }}.git
git checkout -b gh-pages
git add -A
git commit -m "API Document generated."
git push origin HEAD:gh-pages --force
central-deploy:
name: "Deploy Project (Central)"
runs-on: ubuntu-latest
-74
View File
@@ -1,74 +0,0 @@
name: "Publish Javadoc"
on:
# 支持手动触发构建
workflow_dispatch:
release:
# 创建release的时候触发
types: [ published ]
jobs:
javadoc-deploy:
name: "Deploy Javadoc (Github Pages)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Set up JDK"
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: maven
- name: "Generate Javadoc"
run: mvn -B javadoc:javadoc -pl api --file pom.xml -DskipTests
- name: "Copy Javadoc"
run: |
rm -rf docs
mkdir -vp docs
cp -vrf api/target/site/apidocs/* docs/
cp -vrf .doc/javadoc/JAVADOC-README.md docs/README.md
- name: "Generate Sitemap"
id: sitemap
uses: cicirello/generate-sitemap@v1
with:
base-url-path: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
path-to-root: docs
- name: Output stats
run: |
echo "sitemap-path = ${{ steps.sitemap.outputs.sitemap-path }}"
echo "url-count = ${{ steps.sitemap.outputs.url-count }}"
echo "excluded-count = ${{ steps.sitemap.outputs.excluded-count }}"
ls -l docs
- name: Configure Git
env:
DEPLOY_PRI: ${{secrets.DEPLOY_PRI}}
run: |
sudo timedatectl set-timezone "Asia/Shanghai"
mkdir -p ~/.ssh/
echo "$DEPLOY_PRI" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
git config --global user.name '${{ github.repository_owner }}'
git config --global user.email '${{ github.repository_owner }}@users.noreply.github.com'
- name: Commit documentation changes
run: |
echo "Committing changes to git@github.com:${{ github.repository_owner }}/${{ github.event.repository.name }}.git ..."
cd docs
git init
git remote add origin git@github.com:${{ github.repository_owner }}/${{ github.event.repository.name }}.git
git checkout -b gh-pages
git add -A
git commit -m "API Document generated."
- name: Javadoc Website Push
run: |
cd docs
git push origin HEAD:gh-pages --force
+86 -30
View File
@@ -7,6 +7,7 @@
```
# MineSQL (EasySQL-Plugin)
[![version](https://img.shields.io/github/v/release/CarmJos/MineSQL)](https://github.com/CarmJos/MineSQL/releases)
[![License](https://img.shields.io/github/license/CarmJos/MineSQL)](https://opensource.org/licenses/GPL-3.0)
[![workflow](https://github.com/CarmJos/MineSQL/actions/workflows/maven.yml/badge.svg?branch=master)](https://github.com/CarmJos/MineSQL/actions/workflows/maven.yml)
@@ -16,30 +17,49 @@
轻松(用)SQL的独立运行库插件,支持多种服务端,适用于MineCraft全版本。
## 使用场景
## 优势
### 对于插件使用者
### 对于服主 (插件使用者)
- 统一配置数据库连接,避免重复配置费时费力分神。
- 支持更高级更全面的配置方式,以根据不同的使
用场景独立优化[连接池配置](https://github.com/Chris2018998/BeeCP/wiki/Configuration--List)。
- 使相关插件共用连接池,避免每个插件单独新开连接池导致资源的浪费。
### 对于插件开发者
- 基于 [EasySQL](https://github.com/CarmJos/EasySQL) 进行快捷的数据库操作。
- 通过 `MineSQL.getRegistry().get(database-name)` 快捷获取数据源,避免繁琐的链接过程。
- 详细的 DEBUG 方法,找到可恶的错误究竟在哪。
- 不再需要打包各类JDBC-Driver、连接池依赖以及EasySQL本体到插件中。
### 额外提醒
- 使用本依赖时,请保证其他插件的来源安全,避免可能带来的数据安全风险。
## 安装
1. 从 [Releases(发行)](https://github.com/CarmJos/MineSQL/releases/)
中点击 [最新版](https://github.com/CarmJos/MineSQL/releases/latest) 下载 `MineSQL-x.y.z.jar`
2. 将下载的 `MineSQL-x.y.z.jar` 放入服务器 `plugins/` 文件夹下。
3. 启动服务器,预加载配置文件后关闭服务器。
4. 修改 `plugins/MineSQL/config.yml` 以配置您的数据库选项。
5. 启动服务器,若配置无误,则您会看到 MineSQL一切正常的提示消息。
## 配置
### 插件配置文件 [`config.yml`](minesql-core/src/main/resources/config.yml)
### 插件配置文件 [`config.yml`](.doc/example-config.yml)
完整示例配置请见 [文件](minesql-core/src/main/resources/config.yml)。
完整示例配置请见 [示例配置文件](.doc/example-config.yml)。
#### MySQL/MariaDB 数据源详细配置示例
```yaml
databases:
sources:
"mysql-database": # 数据源ID,建议全英文小写并以“-”分隔,例如:hello-minecraft
# 数据库驱动类型
# 若您的数据库为 mariadb,则强烈推荐设置为 mariadb
driver-type: mysql
type: mysql
host: 127.0.0.1 # 数据库地址
port: 3306 # 数据库端口
database: minecraft # 数据库库名
@@ -50,20 +70,21 @@ databases:
#### h2 数据源详细配置示例
```yaml
databases:
"h2-database": # 数据源ID,建议全小写以“-”分隔,例如:hello-minecraft
driver-type: h2
sources:
# h2数据库运行模式
# 可选 file(文件模式) 与 mem(内存模式)
# 文件模式下,须指定 file-path ,以服务器运行目录为基准,支持绝对路径和相对路径。
# 可选 h2-file(文件模式) 与 h2-mem(内存模式)
# 文件模式下,须指定 file路径 ,以服务器运行目录为基准,支持绝对路径和相对路径。
# 内存模式下,所有数据库都将存储在内存中,一旦关服则数据将全部丢失,该模式一般用于测试
mode: file # 可选 mem(内存) file(文件) ;内存模式
"h2-file-db": # 数据源ID,建议全小写以“-”分隔,例如:hello-minecraft
type: h2-file
file-path: "db-files/minecraft"
"h2-mem-db": # 数据源ID,建议全小写以“-”分隔,例如:hello-minecraft
type: h2-mem
```
### Properties 配置文件 [`<插件目录>/db-properties/*.properties`](minesql-core/src/main/resources/db-properties/.example-mysql.properties)
### Properties 配置文件 [`<插件目录>/db-properties/*.properties`](core/src/main/resources/db-properties/.example-mysql.properties)
示例配置请见 [示例MySQL数据源Properties](minesql-core/src/main/resources/db-properties/.example-mysql.properties)。
示例配置请见 [示例MySQL数据源Properties](core/src/main/resources/db-properties/.example-mysql.properties)。
Properties 文件的文件名几位数据源的ID,允许为英文、数字、下划线、短横线;请不要包含中文、其他特殊符号与空格,以`.`开头的文件将被忽略。
@@ -71,6 +92,24 @@ Properties 文件的文件名几位数据源的ID,允许为英文、数字、
更多帮助详见 [BeeCP项目帮助](https://github.com/Chris2018998/BeeCP) 。
## 指令
插件主指令为 `/minesql` ,所有指令只允许后台执行。
```text
# help
- 查看插件指令帮助。
# version
- 查看当前插件、核心库(EasySQL)与连接池依赖版本。
# list
- 列出当前所有的数据源管理器与相关信息。
# info <数据源名称>
- 查看指定数据源的统计信息与当前仍未关闭的查询。
```
## 开发
### 依赖方式
@@ -91,10 +130,10 @@ Properties 文件的文件名几位数据源的ID,允许为英文、数字、
</repository>
<repository>
<!--采用github依赖库,安全稳定,但需要配置 (推荐)-->
<!--采用github分支依赖库,稳定更新快-->
<id>MineSQL</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/CarmJos/MineSQL</url>
<name>GitHub Branch Repository</name>
<url>https://raw.githubusercontent.com/CarmJos/MineSQL/repo/</url>
</repository>
<repository>
@@ -130,8 +169,8 @@ repositories {
//采用Maven中心库,安全稳定,但版本更新需要等待同步
mavenCentral()
// 采用github依赖库,安全稳定,但需要配置 (推荐)
maven { url 'https://maven.pkg.github.com/CarmJos/MineSQL' }
// 采用github分支依赖库,稳定更新快
maven { url 'https://raw.githubusercontent.com/CarmJos/MineSQL/repo/' }
// 采用我的私人依赖库,简单方便,但可能因为变故而无法使用
maven { url 'https://repo.carm.cc/repository/maven-public/' }
@@ -144,24 +183,41 @@ dependencies {
</details>
## 指令
### 操作示例
插件主指令为 `/easysql` ,所有指令只允许后台执行
插件接口入口类为 `MineSQL` ,更多方法详见 [MineSQL-Javadoc](https://carmjos.github.io/MineSQL/)
```text
# help
- 查看插件指令帮助。
关于 EasySQL的使用方法,请详见 [EasySQL开发文档](https://github.com/CarmJos/EasySQL/tree/master/.documentation) 。
# version
- 查看当前插件、核心库(EasySQL)与连接池依赖版本。
# list
- 列出当前所有的数据源管理器与相关信息。
<details>
<summary>点击查看简单实例</summary>
```java
public class Main extends JavaPlugin {
@Override
public void onEnable() {
SQLManager manager = MineSQL.getRegistery().get(getConfig().getString("database"));
if (manager == null) {
System.out.println("请配置一个正确的数据库名。");
setEnabled(false);
return;
}
// do something...
}
}
# info <数据源名称>
- 查看指定数据源的统计信息与当前仍未关闭的查询。
```
</details>
## 开源协议
本项目源码采用 [GNU General Public License v3.0](https://opensource.org/licenses/GPL-3.0) 开源协议。
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.0.0</version>
<version>1.4.0</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;
@@ -27,6 +30,8 @@ interface IMineSQL {
@NotNull SQLRegistry getRegistry();
@NotNull SQLRegistry createRegistry();
/**
* 创建一个新的 SQLManager 实例
*
@@ -59,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;
@@ -43,6 +45,15 @@ public class MineSQL {
return instance.getRegistry();
}
/**
* 创建一个独立的管理器注册池。
*
* @return {@link SQLRegistry}
*/
public static @NotNull SQLRegistry createRegistry() {
return instance.createRegistry();
}
/**
* 创建一个新的 SQLManager 实例
*
@@ -105,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,7 +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() + "\".";
}
}
+9 -36
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.0.0</version>
<version>1.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
@@ -68,10 +68,17 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.byteflux</groupId>
<artifactId>libby-core</artifactId>
<version>${deps.libby.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.chris2018998</groupId>
<artifactId>beecp</artifactId>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
<dependency>
@@ -101,48 +108,14 @@
<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>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>compile</scope>
</dependency>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<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>
@@ -8,27 +8,35 @@ 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;
import cc.carm.plugin.minesql.conf.SQLSourceGroup;
import cc.carm.plugin.minesql.lib.PluginLibraries;
import cc.carm.plugin.minesql.util.DBPropertiesUtil;
import cn.beecp.BeeDataSource;
import cn.beecp.BeeDataSourceConfig;
import co.aikar.commands.CommandManager;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.Locales;
import net.byteflux.libby.Library;
import org.jetbrains.annotations.NotNull;
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;
public class MineSQLCore implements IMineSQL {
protected static MineSQLCore instance;
public static final String REPO_OWNER = "CarmJos";
public static final String REPO_NAME = "MineSQL";
@@ -39,8 +47,20 @@ public class MineSQLCore implements IMineSQL {
protected final PluginConfiguration config;
public MineSQLCore(MineSQLPlatform platform) {
instance = this;
this.platform = platform;
getLogger().info("加载数据库依赖文件...");
getPlatform().getLibraryManager().addMavenLocal();
getPlatform().getLibraryManager().addMavenCentral();
getPlatform().getLibraryManager().addSonatype();
for (PluginLibraries value : PluginLibraries.values()) {
Library lib = value.getLibrary();
getLogger().info(" 加载 " + lib.getArtifactId() + " (" + lib.getVersion() + ") ...");
getPlatform().getLibraryManager().loadLibrary(value.getLibrary());
}
getLogger().info("加载配置文件...");
this.configProvider = EasyConfiguration.from(new File(platform.getPluginFolder(), "config.yml"));
this.config = new PluginConfiguration();
@@ -50,18 +70,59 @@ public class MineSQLCore implements IMineSQL {
MineSQL.initializeAPI(this);
getLogger().info("初始化注册池...");
this.registry = new MineSQLRegistry(this);
this.registry = createRegistry();
Map<String, Properties> dbProperties = readProperties();
Map<String, SQLSourceConfig> dbConfigurations = readConfigurations();
if (dbProperties.isEmpty() && dbConfigurations.isEmpty()) {
getLogger().warning("未检测到任何数据库配置,将不会预创建任何SQLManager。");
return;
}
dbProperties.forEach((id, properties) -> {
try {
getLogger().info("正在初始化数据库 #" + id + " ...");
SQLManagerImpl sqlManager = create(id, properties);
this.registry.getManagers().put(id, sqlManager);
getLogger().info("完成成初始化数据库 #" + id + "");
} catch (Exception ex) {
getLogger().severe("初始化SQLManager(#" + id + ") 出错,请检查配置文件: " + ex.getMessage());
ex.printStackTrace();
}
});
dbConfigurations.forEach((id, configuration) -> {
try {
getLogger().info("正在初始化数据库 #" + id + " ...");
SQLManagerImpl sqlManager = create(id, configuration);
this.registry.getManagers().put(id, sqlManager);
getLogger().info("完成初始化数据库 #" + id + "");
} catch (Exception ex) {
getLogger().severe("初始化SQLManager(#" + id + ") 出错,请检查配置文件: " + ex.getMessage());
ex.printStackTrace();
}
});
}
public MineSQLPlatform getPlatform() {
return platform;
}
public static MineSQLCore getInstance() {
return instance;
}
@Override
public @NotNull MineSQLRegistry getRegistry() {
return this.registry;
}
@Override
public @NotNull MineSQLRegistry createRegistry() {
return new MineSQLRegistry();
}
@Override
public @NotNull SQLManagerImpl create(@NotNull String name, @NotNull SQLSourceConfig conf) {
BeeDataSourceConfig config = new BeeDataSourceConfig();
@@ -113,6 +174,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 + "...");
@@ -1,7 +1,9 @@
package cc.carm.plugin.minesql;
import co.aikar.commands.CommandManager;
import net.byteflux.libby.LibraryManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.logging.Logger;
@@ -12,6 +14,8 @@ public interface MineSQLPlatform {
@NotNull Logger getLogger();
@NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager();
@Nullable CommandManager<?, ?, ?, ?, ?, ?> getCommandManager();
@NotNull LibraryManager getLibraryManager();
}
@@ -1,87 +1,29 @@
package cc.carm.plugin.minesql;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.manager.SQLManagerImpl;
import cc.carm.plugin.minesql.api.SQLRegistry;
import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
public class MineSQLRegistry implements SQLRegistry {
private static MineSQLRegistry instance;
protected ExecutorService executorPool;
protected MineSQLCore core;
private final HashMap<String, SQLManager> managers = new HashMap<>();
protected MineSQLRegistry(@NotNull MineSQLCore core) {
this.core = core;
MineSQLRegistry.instance = this;
this.executorPool = Executors.newFixedThreadPool(2, (r) -> {
Thread thread = new Thread(r, "EasySQLRegistry");
thread.setDaemon(true);
return thread;
});
Map<String, Properties> dbProperties = core.readProperties();
Map<String, SQLSourceConfig> dbConfigurations = core.readConfigurations();
if (dbProperties.isEmpty() && dbConfigurations.isEmpty()) {
core.getLogger().warning("未检测到任何数据库配置,将不会预创建任何SQLManager。");
return;
}
dbProperties.forEach((id, properties) -> {
try {
core.getLogger().info("正在初始化数据库 #" + id + " ...");
SQLManagerImpl sqlManager = this.core.create(id, properties);
this.managers.put(id, sqlManager);
core.getLogger().info("完成成初始化数据库 #" + id + "");
} catch (Exception ex) {
core.getLogger().severe("初始化SQLManager(#" + id + ") 出错,请检查配置文件: " + ex.getMessage());
ex.printStackTrace();
}
});
dbConfigurations.forEach((id, configuration) -> {
try {
core.getLogger().info("正在初始化数据库 #" + id + " ...");
SQLManagerImpl sqlManager = this.core.create(id, configuration);
this.managers.put(id, sqlManager);
core.getLogger().info("完成初始化数据库 #" + id + "");
} catch (Exception ex) {
core.getLogger().severe("初始化SQLManager(#" + id + ") 出错,请检查配置文件: " + ex.getMessage());
ex.printStackTrace();
}
});
}
protected HashMap<String, SQLManager> getManagers() {
return managers;
}
public ExecutorService getExecutor() {
return executorPool;
}
public static MineSQLRegistry getInstance() {
return instance;
}
public MineSQLCore getCore() {
return core;
}
@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
@@ -3,7 +3,7 @@ package cc.carm.plugin.minesql.command;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.SQLQuery;
import cc.carm.plugin.minesql.MineSQLCore;
import cc.carm.plugin.minesql.MineSQLRegistry;
import cc.carm.plugin.minesql.lib.PluginLibraries;
import cc.carm.plugin.minesql.util.VersionReader;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.CommandHelp;
@@ -43,7 +43,7 @@ public class MineSQLCommand extends BaseCommand {
issuer.sendMessage("§c只有后台执行才能使用此命令。");
return;
}
VersionReader reader = new VersionReader();
VersionReader reader = PluginLibraries.READER;
String pluginVersion = reader.get("plugin", null);
if (pluginVersion == null) {
issuer.sendMessage("§c无法获取当前版本信息,请保证使用原生版本以避免安全问题。");
@@ -51,9 +51,9 @@ public class MineSQLCommand extends BaseCommand {
}
issuer.sendMessage("§r当前插件版本为 §b" + pluginVersion + "§r。 §7(基于 EasySQL &3" + reader.get("api") + "&7)");
issuer.sendMessage("§8 - &f连接池依赖 BeeCP §9" + reader.get("beecp"));
issuer.sendMessage("§8 - &f数据库驱动 MySQL §9" + reader.get("mysql-driver"));
issuer.sendMessage("§8 - &f数据库驱动 MariaDB §9" + reader.get("mariadb-driver"));
issuer.sendMessage("§8 - &f数据库驱动 h2-database §9" + reader.get("h2-driver"));
issuer.sendMessage("§8 - &f数据库驱动 MySQL §9" + PluginLibraries.MYSQL_DRIVER.getVersion());
issuer.sendMessage("§8 - &f数据库驱动 MariaDB §9" + PluginLibraries.MARIADB_DRIVER.getVersion());
issuer.sendMessage("§8 - &f数据库驱动 h2-database §9" + PluginLibraries.H2_DRIVER.getVersion());
issuer.sendMessage("§r正在检查插件更新,请稍候...");
core.checkUpdate(pluginVersion);
@@ -66,7 +66,7 @@ public class MineSQLCommand extends BaseCommand {
issuer.sendMessage("§c只有后台执行才能使用此命令。");
return;
}
Map<String, ? extends SQLManager> runningManagers = MineSQLRegistry.getInstance().list();
Map<String, ? extends SQLManager> runningManagers = MineSQLCore.getInstance().getRegistry().list();
if (runningManagers.isEmpty()) {
issuer.sendMessage("§r当前无正在运行的数据库管理器。");
} else {
@@ -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({
@@ -0,0 +1,36 @@
package cc.carm.plugin.minesql.lib;
import cc.carm.plugin.minesql.util.VersionReader;
import net.byteflux.libby.Library;
import org.jetbrains.annotations.NotNull;
public enum PluginLibraries {
BEECP("com.github.chris2018998", "beecp"),
H2_DRIVER("com.h2database", "h2"),
MYSQL_DRIVER("com.mysql", "mysql-connector-j"),
MARIADB_DRIVER("org.mariadb.jdbc", "mariadb-java-client");
public static final VersionReader READER = new VersionReader();
private final @NotNull String groupID;
private final @NotNull String artifactID;
PluginLibraries(@NotNull String groupID, @NotNull String artifactID) {
this.groupID = groupID;
this.artifactID = artifactID;
}
public @NotNull Library getLibrary() {
return Library.builder().id(name())
.groupId(this.groupID).artifactId(this.artifactID)
.version(getVersion())
.build();
}
public @NotNull String getVersion() {
return READER.get(name().toLowerCase().replace('_', '-'));
}
}
@@ -17,7 +17,7 @@ public class DBPropertiesUtil {
if (!propertiesFolder.exists() || !propertiesFolder.isDirectory()) return propertiesMap;
File[] files = propertiesFolder.listFiles();
if (files == null || files.length == 0) return propertiesMap;
if (files == null) return propertiesMap;
for (File file : files) {
if (!validateName(file.getName())) continue;
String name = file.getName().substring(0, file.getName().lastIndexOf("."));
@@ -1,45 +0,0 @@
package cc.carm.plugin.minesql.util;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.InputStream;
import java.util.Properties;
public class MavenReadUtil {
public static String getMavenPropertiesPath(@NotNull String groupID, @NotNull String artifactID) {
return String.format("/META-INF/maven/%s/%s/pom.properties", groupID, artifactID);
}
public static synchronized @Nullable String getVersion(@NotNull Object provider,
@NotNull String groupID,
@NotNull String artifactID) {
String path = getMavenPropertiesPath(groupID, artifactID);
String version = null;
// Using maven properties to get the version
try (InputStream is = provider.getClass().getResourceAsStream(path)) {
if (is != null) {
Properties p = new Properties();
p.load(is);
version = p.getProperty("version", "");
}
} catch (Exception ignored) {
}
if (version != null) return version;
// Fine, lets try Java API
Package pkg = provider.getClass().getPackage();
if (pkg != null) {
version = pkg.getImplementationVersion();
if (version == null) {
version = pkg.getSpecificationVersion();
}
}
return version;
}
}
+11 -8
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.0.0</version>
<version>1.4.0</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>
@@ -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>
@@ -97,10 +104,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,7 +2,10 @@ 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 net.byteflux.libby.BukkitLibraryManager;
import net.byteflux.libby.LibraryManager;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.jetbrains.annotations.NotNull;
@@ -13,6 +16,8 @@ public class MineSQLBukkit extends EasyPlugin implements MineSQLPlatform {
protected static MineSQLBukkit instance;
protected BukkitLibraryManager libraryManager;
protected MineSQLCore core;
protected PaperCommandManager commandManager;
@@ -20,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);
}
@@ -43,7 +51,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,10 +81,15 @@ public class MineSQLBukkit extends EasyPlugin implements MineSQLPlatform {
return this.core.getConfig();
}
public @NotNull PaperCommandManager getCommandManager() {
public @NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
return commandManager;
}
@Override
public @NotNull LibraryManager getLibraryManager() {
return this.libraryManager;
}
@Override
public @NotNull File getPluginFolder() {
return getDataFolder();
+11 -8
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.0.0</version>
<version>1.4.0</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>
@@ -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>
@@ -108,10 +115,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>
@@ -5,6 +5,8 @@ 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;
@@ -20,6 +22,8 @@ public class MineSQLBungee extends Plugin implements MineSQLPlatform {
protected static MineSQLBungee instance;
protected BungeeLibraryManager libraryManager;
protected MineSQLCore core;
protected BungeeCommandManager commandManager;
@@ -27,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);
}
@@ -51,7 +58,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(
@@ -92,6 +99,11 @@ public class MineSQLBungee extends Plugin implements MineSQLPlatform {
return this.commandManager;
}
@Override
public @NotNull LibraryManager getLibraryManager() {
return this.libraryManager;
}
@SuppressWarnings("deprecation")
public void outputInfo() {
Optional.ofNullable(JarResourceUtils.readResource(this.getResourceAsStream("PLUGIN_INFO")))
+127
View File
@@ -0,0 +1,127 @@
<?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.4.0</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>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>${deps.bstats.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-sponge</artifactId>
<version>${deps.acf.version}</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,133 @@
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.byteflux.libby.LibraryManager;
import net.byteflux.libby.SpongeLibraryManager;
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 SpongeLibraryManager<MineSQLSponge> libraryManager;
protected final MineSQLCore core;
// protected SpongeCommandManager commandManager;
@Inject
public MineSQLSponge(Metrics.Factory factory,
PluginContainer pluginContainer,
SpongeLibraryManager<MineSQLSponge> libraryManager) {
this.pluginContainer = pluginContainer;
this.metricsFactory = factory;
this.libraryManager = libraryManager;
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;
}
@Override
public @NotNull LibraryManager getLibraryManager() {
return this.libraryManager;
}
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}"
}
]
}
+13 -8
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.0.0</version>
<version>1.4.0</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>
@@ -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>
@@ -99,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>
@@ -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,22 @@ 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.slf4j.LoggerFactory;
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.4.0",
description = "EasySQL Plugin For Velocity",
url = "https://github.com/CarmJos/MineSQL",
authors = {"CarmJos", "GhostChu"}
@@ -35,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;
@@ -47,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);
@@ -72,7 +86,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();
@@ -114,11 +128,19 @@ public class MineSQLVelocity implements MineSQLPlatform {
return commandManager;
}
@Override
public @NotNull LibraryManager getLibraryManager() {
return this.libraryManager;
}
public @NotNull PluginConfiguration getConfiguration() {
return this.core.getConfig();
}
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))));
}
}
+24 -57
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>minesql-parent</artifactId>
<groupId>cc.carm.plugin</groupId>
<version>1.0.0</version>
<version>1.4.0</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>
@@ -77,83 +80,45 @@
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.bstats</shadedPattern>
<shadedPattern>${code.package}.lib.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>org.json</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.json</shadedPattern>
<shadedPattern>${code.package}.lib.json</shadedPattern>
</relocation>
<relocation>
<pattern>cc.carm.lib.easyplugin</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.easyplugin</shadedPattern>
<shadedPattern>${code.package}.lib.easyplugin</shadedPattern>
</relocation>
<relocation>
<pattern>cc.carm.lib.githubreleases4j</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.githubreleases4j</shadedPattern>
<shadedPattern>${code.package}.lib.githubreleases4j</shadedPattern>
</relocation>
<relocation>
<pattern>cc.carm.lib.configuration</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.configuration</shadedPattern>
<shadedPattern>${code.package}.lib.configuration</shadedPattern>
</relocation>
<relocation>
<pattern>org.bspfsystems.yamlconfiguration</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.configuration.yaml
</shadedPattern> <!-- Replace this -->
<shadedPattern>${code.package}.lib.configuration.yaml</shadedPattern>
</relocation>
<relocation>
<pattern>org.yaml.snakeyaml</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.yaml</shadedPattern> <!-- Replace this -->
<shadedPattern>${code.package}.lib.yaml</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.acf</shadedPattern> <!-- Replace this -->
<shadedPattern>${code.package}.lib.acf</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>co.aikar.locales</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.locales</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>cn.beecp</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.beecp</shadedPattern> <!-- Replace this -->
<shadedPattern>${code.package}.lib.locales</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>org.h2</pattern>
<shadedPattern>cc.carm.plugin.minesql.driver.h2</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>org.mariadb</pattern>
<shadedPattern>cc.carm.plugin.minesql.driver.mariadb</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>com.mysql</pattern>
<shadedPattern>cc.carm.plugin.minesql.driver.mysql</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>com.sun.jna</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.jna</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>com.google.protobuf</pattern>
<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 -->
</relocation>
<relocation>
<pattern>com.github</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.github</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.checkerframework</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>waffle</pattern>
<shadedPattern>cc.carm.plugin.minesql.lib.waffle</shadedPattern> <!-- Replace this -->
<pattern>net.byteflux.libby</pattern>
<shadedPattern>${code.package}.lib.libby</shadedPattern>
</relocation>
</relocations>
@@ -172,6 +137,8 @@
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/*.txt</exclude>
<exclude>LICENSE</exclude>
<exclude>README</exclude>
</excludes>
</filter>
</filters>
+98 -9
View File
@@ -11,20 +11,26 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<deps.easysql.version>0.4.6</deps.easysql.version>
<deps.easysql.version>0.4.7</deps.easysql.version>
<deps.easyconf.version>3.3.1</deps.easyconf.version>
<deps.easyplugin.version>1.4.18</deps.easyplugin.version>
<deps.beecp.version>3.3.9</deps.beecp.version>
<deps.libby.version>1.1.5</deps.libby.version>
<deps.acf.version>0.5.1-SNAPSHOT</deps.acf.version>
<deps.bstats.version>3.0.0</deps.bstats.version>
<deps.mysql-driver.version>8.0.31</deps.mysql-driver.version>
<deps.mariadb-driver.version>3.1.0</deps.mariadb-driver.version>
<deps.h2-driver.version>2.1.214</deps.h2-driver.version>
<code.package>cc.carm.plugin.minesql</code.package>
</properties>
<groupId>cc.carm.plugin</groupId>
<artifactId>minesql-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<version>1.4.0</version>
<modules>
<module>api</module>
<module>core</module>
@@ -32,6 +38,8 @@
<module>platforms/bukkit</module>
<module>platforms/bungee</module>
<module>platforms/velocity</module>
<module>platforms/sponge8</module>
<module>plugin</module>
</modules>
@@ -62,6 +70,13 @@
</developer>
</developers>
<scm>
<connection>scm:git:git@github.com:CarmJos/MineSQL</connection>
<developerConnection>scm:git:git@github.com:CarmJos/MineSQL.git</developerConnection>
<url>https://github.com/CarmJos/MineSQL</url>
<tag>HEAD</tag>
</scm>
<licenses>
<license>
<name>GNU General Public License v3.0</name>
@@ -81,11 +96,6 @@
<distributionManagement>
<downloadUrl>https://github.com/CarmJos/MineSQL/releases</downloadUrl>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/CarmJos/MineSQL</url>
</repository>
</distributionManagement>
<repositories>
@@ -95,6 +105,11 @@
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
<repository>
<id>AlessioDP</id>
<url>https://repo.alessiodp.com/releases/</url>
</repository>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2/</url>
@@ -158,8 +173,8 @@
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>${deps.mysql-driver.version}</version>
</dependency>
@@ -199,6 +214,37 @@
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
@@ -241,5 +287,48 @@
</resources>
</build>
<profiles>
<profile>
<id>ossrh</id>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</profile>
<profile>
<id>github</id>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/CarmJos/MineSQL</url>
</repository>
</distributionManagement>
</profile>
<profile>
<id>local</id>
<distributionManagement>
<snapshotRepository>
<id>localRepository</id>
<url>file:${user.home}/local-deploy/</url>
</snapshotRepository>
<repository>
<id>localRepository</id>
<url>file:${user.home}/local-deploy/</url>
</repository>
</distributionManagement>
</profile>
</profiles>
</project>