mirror of
https://github.com/CarmJos/MineSQL.git
synced 2024-09-19 20:25:45 +00:00
feat(proj): 项目完成,测试使用。
This commit is contained in:
parent
1557c14116
commit
5c30bea7eb
@ -19,7 +19,7 @@ properties:
|
|||||||
enable: true
|
enable: true
|
||||||
# 文件夹路径,将读取该文件夹下的所有 .properties 文件,并以文件名为数据管理器名称。
|
# 文件夹路径,将读取该文件夹下的所有 .properties 文件,并以文件名为数据管理器名称。
|
||||||
# 读取时,将排除以 “.” 开头的文件与非 .properties 文件。
|
# 读取时,将排除以 “.” 开头的文件与非 .properties 文件。
|
||||||
# 默认为 "db-properties/" 相对路径,指向“plugins/EasySQL-Plugin/db-properties/”;
|
# 默认为 "db-properties/" 相对路径,指向“plugins/MineSQL/db-properties/”;
|
||||||
# 该选项也支持绝对路径,但使用绝对路径时,请务必注意权限问题。
|
# 该选项也支持绝对路径,但使用绝对路径时,请务必注意权限问题。
|
||||||
folder: "db-properties/"
|
folder: "db-properties/"
|
||||||
|
|
||||||
@ -38,7 +38,4 @@ databases:
|
|||||||
|
|
||||||
"example-h2": # 数据库源名称 不可包含“.” 以“example-”开头的数据源不会被加载
|
"example-h2": # 数据库源名称 不可包含“.” 以“example-”开头的数据源不会被加载
|
||||||
driver-type: h2 #数据库驱动类型,目前支持 mariadb, mysql, h2
|
driver-type: h2 #数据库驱动类型,目前支持 mariadb, mysql, h2
|
||||||
file: "example.db" #数据库文件路径,相对于“plugins/EasySQL-Plugin/db-files/”
|
file: "example.db" #数据库文件路径,相对于“plugins/MineSQL/db-files/”
|
||||||
username: minecraft # 数据库用户名
|
|
||||||
password: password #数据库连接密码
|
|
||||||
database: minecraft #数据库名
|
|
@ -1,9 +1,9 @@
|
|||||||
# EasySQL Plugin Javadoc
|
# MineSQL _(EasySQL Plugin)_ Javadoc
|
||||||
|
|
||||||
基于 [Github Pages](https://pages.github.com/) 搭建,请访问 [JavaDoc](https://carmjos.github.io/EasySQL-Plugin) 。
|
基于 [Github Pages](https://pages.github.com/) 搭建,请访问 [JavaDoc](https://carmjos.github.io/MineSQL) 。
|
||||||
|
|
||||||
## 如何实现?
|
## 如何实现?
|
||||||
|
|
||||||
若您也想通过 [Github Actions](https://docs.github.com/en/actions/learn-github-actions)
|
若您也想通过 [Github Actions](https://docs.github.com/en/actions/learn-github-actions)
|
||||||
自动部署项目的Javadoc到 [Github Pages](https://pages.github.com/) ,
|
自动部署项目的Javadoc到 [Github Pages](https://pages.github.com/) ,
|
||||||
可以参考我的文章 [《自动部署Javadoc到Github Pages》](https://pages.carm.cc/doc/javadoc-in-github.html) 。
|
可以参考我的文章 [《自动部署Javadoc到Github Pages》](https://pages.carm.cc/doc/javadoc-in-github.html) 。
|
86
.github/workflows/deploy.yml
vendored
86
.github/workflows/deploy.yml
vendored
@ -1,7 +1,4 @@
|
|||||||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
name: "Deploy & Publish"
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
|
||||||
|
|
||||||
name: Deploy & Upload
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# 支持手动触发构建
|
# 支持手动触发构建
|
||||||
@ -11,8 +8,8 @@ on:
|
|||||||
types: [ published ]
|
types: [ published ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
gh-deploy:
|
||||||
|
name: "Deploy Project (GitHub)"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@ -26,65 +23,36 @@ jobs:
|
|||||||
server-id: github
|
server-id: github
|
||||||
server-username: MAVEN_USERNAME
|
server-username: MAVEN_USERNAME
|
||||||
server-password: MAVEN_TOKEN
|
server-password: MAVEN_TOKEN
|
||||||
|
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
|
||||||
|
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
|
||||||
|
|
||||||
- name: "Maven Deploy"
|
- name: "Maven Deploy"
|
||||||
run: mvn -B deploy --file pom.xml -DskipTests
|
run: mvn -B -Pgithub deploy --file pom.xml -DskipTests
|
||||||
env:
|
env:
|
||||||
MAVEN_USERNAME: ${{ github.repository_owner }}
|
MAVEN_USERNAME: ${{ github.repository_owner }}
|
||||||
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
|
||||||
|
|
||||||
- name: "Release Asset Upload"
|
central-deploy:
|
||||||
id: upload-release-asset
|
name: "Deploy Project (Central)"
|
||||||
uses: shogo82148/actions-upload-release-asset@v1
|
runs-on: ubuntu-latest
|
||||||
env:
|
steps:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
- uses: actions/checkout@v2
|
||||||
|
- name: "Set up JDK"
|
||||||
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ github.event.release.upload_url }}
|
java-version: '11'
|
||||||
asset_path: asset/*.jar
|
distribution: 'adopt'
|
||||||
asset_content_type: application/java-archive
|
cache: maven
|
||||||
|
server-id: ossrh
|
||||||
|
server-username: MAVEN_USERNAME
|
||||||
|
server-password: MAVEN_PASSWORD
|
||||||
|
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
|
||||||
|
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
|
||||||
|
|
||||||
- name: "Javadoc Deploy Staging"
|
- name: "Central Deploy"
|
||||||
run: |
|
run: mvn -B -Possrh deploy --file pom.xml -DskipTests
|
||||||
rm -rf docs
|
|
||||||
mkdir -vp docs
|
|
||||||
cp -vrf api-docs/* docs/
|
|
||||||
cp -vrf .documentation/JAVADOC-README.md docs/README.md
|
|
||||||
|
|
||||||
- name: "Generate the 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 }}"
|
|
||||||
|
|
||||||
- name: "Configure Git"
|
|
||||||
env:
|
env:
|
||||||
DEPLOY_PRI: ${{secrets.DEPLOY_PRI}}
|
MAVEN_USERNAME: ${{ secrets.OSSRH_USER }}
|
||||||
run: |
|
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASS }}
|
||||||
sudo timedatectl set-timezone "Asia/Shanghai"
|
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
|
||||||
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 'CarmJos'
|
|
||||||
git config --global user.email 'carm@carm.cc'
|
|
||||||
|
|
||||||
- name: "Commit Javadocs"
|
|
||||||
run: |
|
|
||||||
cd docs
|
|
||||||
git init
|
|
||||||
git remote add origin git@github.com:${{ github.repository }}.git
|
|
||||||
git checkout -b gh-pages
|
|
||||||
git add -A
|
|
||||||
git commit -m "API Document generated."
|
|
||||||
|
|
||||||
- name: "Push javadocs"
|
|
||||||
run: |
|
|
||||||
cd docs
|
|
||||||
git push origin HEAD:gh-pages --force
|
|
||||||
|
74
.github/workflows/javadoc.yml
vendored
Normal file
74
.github/workflows/javadoc.yml
vendored
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
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
|
18
.github/workflows/maven.yml
vendored
18
.github/workflows/maven.yml
vendored
@ -6,7 +6,12 @@ name: Build & Tests
|
|||||||
on:
|
on:
|
||||||
# 支持手动触发构建
|
# 支持手动触发构建
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
push:
|
push:
|
||||||
|
paths-ignore:
|
||||||
|
- ".github/**"
|
||||||
|
- "README.md"
|
||||||
|
- "LICENCE"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -20,19 +25,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
cache: maven
|
|
||||||
server-id: github
|
|
||||||
server-username: MAVEN_USERNAME
|
|
||||||
server-password: MAVEN_TOKEN
|
|
||||||
- name: "Package"
|
- name: "Package"
|
||||||
run: mvn -B package --file pom.xml -Dmaven.javadoc.skip=true
|
run: mvn -B package --file pom.xml -Dgpg.skip
|
||||||
env:
|
|
||||||
MAVEN_USERNAME: ${{ github.repository_owner }}
|
|
||||||
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
||||||
- name: "Target Stage"
|
- name: "Target Stage"
|
||||||
run: mkdir -vp staging && ls -l asset/ && cp -vrf asset/*.jar staging
|
run: mkdir staging && cp */target/*.jar staging
|
||||||
- name: "Upload artifact"
|
- name: "Upload artifact"
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: Artifact
|
name: Artifact
|
||||||
path: staging
|
path: staging
|
33
README.md
33
README.md
@ -1,17 +1,14 @@
|
|||||||
```text
|
```text
|
||||||
______ _____ ____ _ _____ _ _
|
__ ____ ________ __
|
||||||
| ____| / ____|/ __ \| | | __ \| | (_)
|
/ |/ (_)__ ___ / __/ __ \ / /
|
||||||
| |__ __ _ ___ _ _| (___ | | | | | | |__) | |_ _ __ _ _ _ __
|
/ /|_/ / / _ \/ -_)\ \/ /_/ / / /__
|
||||||
| __| / _` / __| | | |\___ \| | | | | | ___/| | | | |/ _` | | '_ \
|
/_/ /_/_/_//_/\__/___/\___\_\/____/
|
||||||
| |___| (_| \__ \ |_| |____) | |__| | |____ | | | | |_| | (_| | | | | |
|
#MineSQL (EasySQL-Plugin)
|
||||||
|______\__,_|___/\__, |_____/ \___\_\______| |_| |_|\__,_|\__, |_|_| |_|
|
|
||||||
__/ | __/ |
|
|
||||||
|___/ |___/
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<font size="20" color="red">注意:该项目仍在开发中!</font>
|
<font size="20" color="red">注意:该项目仍在开发中!</font>
|
||||||
|
|
||||||
# EasySQL-Plugin
|
# MineSQL (EasySQL-Plugin)
|
||||||
|
|
||||||
轻松(用)SQL的独立运行库插件,支持多种服务端,适用于MineCraft全版本。
|
轻松(用)SQL的独立运行库插件,支持多种服务端,适用于MineCraft全版本。
|
||||||
|
|
||||||
@ -27,9 +24,9 @@
|
|||||||
|
|
||||||
## 配置
|
## 配置
|
||||||
|
|
||||||
### 插件配置文件 [`config.yml`](easysql-plugin-core/src/main/resources/config.yml)
|
### 插件配置文件 [`config.yml`](minesql-core/src/main/resources/config.yml)
|
||||||
|
|
||||||
完整示例配置请见 [源文件](easysql-plugin-core/src/main/resources/config.yml)。
|
完整示例配置请见 [源文件](minesql-core/src/main/resources/config.yml)。
|
||||||
|
|
||||||
#### MySQL/MariaDB 数据源详细配置示例
|
#### MySQL/MariaDB 数据源详细配置示例
|
||||||
|
|
||||||
@ -60,9 +57,9 @@ databases:
|
|||||||
file-path: "db-files/minecraft"
|
file-path: "db-files/minecraft"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Properties 配置文件 [`<插件目录>/db-properties/*.properties`](easysql-plugin-core/src/main/resources/db-properties/.example-mysql.properties)
|
### Properties 配置文件 [`<插件目录>/db-properties/*.properties`](minesql-core/src/main/resources/db-properties/.example-mysql.properties)
|
||||||
|
|
||||||
示例配置请见 [示例MySQL数据源Properties](easysql-plugin-core/src/main/resources/db-properties/.example-mysql.properties)。
|
示例配置请见 [示例MySQL数据源Properties](minesql-core/src/main/resources/db-properties/.example-mysql.properties)。
|
||||||
|
|
||||||
Properties 文件的文件名几位数据源的ID,允许为英文、数字、下划线、短横线;请不要包含中文、其他特殊符号与空格,以`.`开头的文件将被忽略。
|
Properties 文件的文件名几位数据源的ID,允许为英文、数字、下划线、短横线;请不要包含中文、其他特殊符号与空格,以`.`开头的文件将被忽略。
|
||||||
|
|
||||||
@ -91,9 +88,9 @@ Properties 文件的文件名几位数据源的ID,允许为英文、数字、
|
|||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<!--采用github依赖库,安全稳定,但需要配置 (推荐)-->
|
<!--采用github依赖库,安全稳定,但需要配置 (推荐)-->
|
||||||
<id>EasySQL-Plugin</id>
|
<id>MineSQL</id>
|
||||||
<name>GitHub Packages</name>
|
<name>GitHub Packages</name>
|
||||||
<url>https://maven.pkg.github.com/CarmJos/EasySQL-Plugin</url>
|
<url>https://maven.pkg.github.com/CarmJos/MineSQL</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
@ -109,7 +106,7 @@ Properties 文件的文件名几位数据源的ID,允许为英文、数字、
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<artifactId>easysql-plugin-api</artifactId>
|
<artifactId>minesql-api</artifactId>
|
||||||
<version>[LATEST RELEASE]</version>
|
<version>[LATEST RELEASE]</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -130,14 +127,14 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
||||||
// 采用github依赖库,安全稳定,但需要配置 (推荐)
|
// 采用github依赖库,安全稳定,但需要配置 (推荐)
|
||||||
maven { url 'https://maven.pkg.github.com/CarmJos/EasySQL-Plugin' }
|
maven { url 'https://maven.pkg.github.com/CarmJos/MineSQL' }
|
||||||
|
|
||||||
// 采用我的私人依赖库,简单方便,但可能因为变故而无法使用
|
// 采用我的私人依赖库,简单方便,但可能因为变故而无法使用
|
||||||
maven { url 'https://repo.carm.cc/repository/maven-public/' }
|
maven { url 'https://repo.carm.cc/repository/maven-public/' }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly "cc.carm.plugin:easysql-plugin-api:[LATEST RELEASE]"
|
compileOnly "cc.carm.plugin:minesql-api:[LATEST RELEASE]"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
19
api/pom.xml
19
api/pom.xml
@ -3,7 +3,7 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>easysql-plugin</artifactId>
|
<artifactId>minesql-parent</artifactId>
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<version>0.0.3-SNAPSHOT</version>
|
<version>0.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
@ -16,12 +16,12 @@
|
|||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<artifactId>easysql-plugin-api</artifactId>
|
<artifactId>minesql-api</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>EasySQL-Plugin-API</name>
|
<name>MineSQL-API</name>
|
||||||
<description>轻松(用)SQL的独立运行库插件的公用API接口部分。</description>
|
<description>轻松(用)SQL的独立运行库插件的公用API接口部分。</description>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin</url>
|
<url>https://github.com/CarmJos/MineSQL</url>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
@ -45,12 +45,12 @@
|
|||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>GitHub Issues</system>
|
<system>GitHub Issues</system>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin/issues</url>
|
<url>https://github.com/CarmJos/MineSQL/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>GitHub Actions</system>
|
<system>GitHub Actions</system>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin/actions/workflows/maven.yml</url>
|
<url>https://github.com/CarmJos/MineSQL/actions/workflows/maven.yml</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -61,6 +61,12 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyconfiguration-core</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -92,7 +98,6 @@
|
|||||||
<includeDependencySources>true</includeDependencySources>
|
<includeDependencySources>true</includeDependencySources>
|
||||||
<dependencySourceIncludes>cc.carm.lib:easysql-api</dependencySourceIncludes>
|
<dependencySourceIncludes>cc.carm.lib:easysql-api</dependencySourceIncludes>
|
||||||
<dependencySourceIncludes>cc.carm.plugin:*</dependencySourceIncludes>
|
<dependencySourceIncludes>cc.carm.plugin:*</dependencySourceIncludes>
|
||||||
<outputDirectory>${project.parent.basedir}/api-docs/</outputDirectory>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
21
api/src/main/java/cc/carm/plugin/minesql/IMineSQL.java
Normal file
21
api/src/main/java/cc/carm/plugin/minesql/IMineSQL.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package cc.carm.plugin.minesql;
|
||||||
|
|
||||||
|
import cc.carm.plugin.minesql.api.SQLRegistry;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
interface IMineSQL {
|
||||||
|
|
||||||
|
@NotNull SQLRegistry getRegistry();
|
||||||
|
|
||||||
|
@NotNull File getPluginFolder();
|
||||||
|
|
||||||
|
default @NotNull File getSourceFolder() {
|
||||||
|
return new File(getPluginFolder(), "db-files");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull Logger getLogger();
|
||||||
|
|
||||||
|
}
|
@ -2,16 +2,30 @@ package cc.carm.plugin.minesql;
|
|||||||
|
|
||||||
import cc.carm.plugin.minesql.api.SQLRegistry;
|
import cc.carm.plugin.minesql.api.SQLRegistry;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class MineSQL {
|
public class MineSQL {
|
||||||
|
|
||||||
protected static SQLRegistry api;
|
private static IMineSQL instance;
|
||||||
|
|
||||||
protected static void initializeAPI(SQLRegistry api) {
|
protected static void initializeAPI(IMineSQL api) {
|
||||||
MineSQL.api = api;
|
MineSQL.instance = api;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SQLRegistry get() {
|
public static Logger getLogger() {
|
||||||
return api;
|
return instance.getLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SQLRegistry getRegistry() {
|
||||||
|
return instance.getRegistry();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 数据库源文件所在目录,非插件数据目录。
|
||||||
|
*/
|
||||||
|
public static File getDataSourceFolder() {
|
||||||
|
return instance.getSourceFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,226 +0,0 @@
|
|||||||
package cc.carm.plugin.minesql.api;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DBConfiguration {
|
|
||||||
|
|
||||||
public static DBConfiguration create(@NotNull SQLDriverType sourceType, @NotNull String url) {
|
|
||||||
return new DBConfiguration(sourceType.getDriverClass(), sourceType.getUrlPrefix(), url, sourceType.getInitializeSQLs());
|
|
||||||
}
|
|
||||||
|
|
||||||
private final @NotNull String driverClassName;
|
|
||||||
private final @NotNull String urlPrefix;
|
|
||||||
private final @NotNull List<String> initializeSQLs;
|
|
||||||
|
|
||||||
private @NotNull String url;
|
|
||||||
|
|
||||||
private @Nullable String username;
|
|
||||||
private @Nullable String password;
|
|
||||||
|
|
||||||
private @Nullable String connectionInitSql;
|
|
||||||
|
|
||||||
private @Nullable String poolName;
|
|
||||||
private @Nullable Integer maxPoolSize;
|
|
||||||
private @Nullable Integer maxActive;
|
|
||||||
|
|
||||||
private @Nullable Integer maxHoldTime;
|
|
||||||
|
|
||||||
private @Nullable Long idleTimeout;
|
|
||||||
|
|
||||||
private @Nullable Long maxWaitTime;
|
|
||||||
|
|
||||||
|
|
||||||
private @Nullable String schema;
|
|
||||||
private @Nullable Boolean autoCommit;
|
|
||||||
private @Nullable Boolean readOnly;
|
|
||||||
|
|
||||||
private @Nullable String validationSQL;
|
|
||||||
private @Nullable Integer validationTimeout;
|
|
||||||
private @Nullable Long validationInterval;
|
|
||||||
|
|
||||||
|
|
||||||
private DBConfiguration(@NotNull String driverClass, @NotNull String urlPrefix,
|
|
||||||
@NotNull String url, @NotNull String[] initializeSQLs) {
|
|
||||||
this.driverClassName = driverClass;
|
|
||||||
this.urlPrefix = urlPrefix;
|
|
||||||
this.url = url;
|
|
||||||
this.initializeSQLs = Arrays.asList(initializeSQLs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull String getDriverClassName() {
|
|
||||||
return driverClassName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull String getUrlPrefix() {
|
|
||||||
return urlPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull List<String> getInitializeSQLs() {
|
|
||||||
return initializeSQLs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setInitializeSQLs(@Nullable String[] initializeSQLs) {
|
|
||||||
this.initializeSQLs.clear();
|
|
||||||
this.initializeSQLs.addAll(Arrays.asList(initializeSQLs));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration addInitializeSQL(@NotNull String initializeSQL) {
|
|
||||||
this.initializeSQLs.add(initializeSQL);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration clearExtraSettings() {
|
|
||||||
this.initializeSQLs.clear();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setUrl(String url) {
|
|
||||||
this.url = url;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable String getConnectionInitSql() {
|
|
||||||
return connectionInitSql;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setConnectionInitSql(String connectionInitSql) {
|
|
||||||
this.connectionInitSql = connectionInitSql;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable String getValidationSQL() {
|
|
||||||
return validationSQL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setValidationSQL(String validationSQL) {
|
|
||||||
this.validationSQL = validationSQL;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable Long getValidationInterval() {
|
|
||||||
return validationInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setValidationInterval(@Nullable Long validationInterval) {
|
|
||||||
this.validationInterval = validationInterval;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable String getPoolName() {
|
|
||||||
return poolName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setPoolName(String poolName) {
|
|
||||||
this.poolName = poolName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable String getSchema() {
|
|
||||||
return schema;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setSchema(String schema) {
|
|
||||||
this.schema = schema;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable Boolean getAutoCommit() {
|
|
||||||
return autoCommit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setAutoCommit(Boolean autoCommit) {
|
|
||||||
this.autoCommit = autoCommit;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable Boolean getReadOnly() {
|
|
||||||
return readOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setReadOnly(Boolean readOnly) {
|
|
||||||
this.readOnly = readOnly;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable Integer getMaxHoldTime() {
|
|
||||||
return maxHoldTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setMaxHoldTime(@Nullable Integer maxHoldTime) {
|
|
||||||
this.maxHoldTime = maxHoldTime;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable Integer getValidationTimeout() {
|
|
||||||
return validationTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setValidationTimeout(Integer validationTimeout) {
|
|
||||||
this.validationTimeout = validationTimeout;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable Long getIdleTimeout() {
|
|
||||||
return idleTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setIdleTimeout(Long idleTimeout) {
|
|
||||||
this.idleTimeout = idleTimeout;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable Integer getMaxActive() {
|
|
||||||
return maxActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setMaxActive(Integer maxActive) {
|
|
||||||
this.maxActive = maxActive;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable Integer getMaxPoolSize() {
|
|
||||||
return maxPoolSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setMaxPoolSize(@Nullable Integer maxPoolSize) {
|
|
||||||
this.maxPoolSize = maxPoolSize;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable Long getMaxWaitTime() {
|
|
||||||
return maxWaitTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBConfiguration setMaxWaitTime(Long maxWaitTime) {
|
|
||||||
this.maxWaitTime = maxWaitTime;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,37 +1,54 @@
|
|||||||
package cc.carm.plugin.minesql.api;
|
package cc.carm.plugin.minesql.api;
|
||||||
|
|
||||||
|
import cc.carm.lib.easysql.api.SQLManager;
|
||||||
|
import cc.carm.lib.easysql.api.function.SQLHandler;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public enum SQLDriverType {
|
public enum SQLDriverType {
|
||||||
|
|
||||||
MARIADB("org.mariadb.jdbc.Driver", "jdbc:mariadb://",
|
MARIADB(
|
||||||
new String[]{"mariadb", "maria-db"}, new String[]{}
|
"org.mariadb.jdbc.Driver", "jdbc:mariadb://",
|
||||||
|
new String[]{"maria-db"}, null
|
||||||
),
|
),
|
||||||
MYSQL("com.mysql.jdbc.Driver", "jdbc:mysql://",
|
|
||||||
new String[]{"mysql"}, new String[]{}
|
MYSQL("com.mysql.jdbc.Driver", "jdbc:mysql://", null, null),
|
||||||
|
|
||||||
|
H2_FILE("org.h2.Driver", "jdbc:h2:file:",
|
||||||
|
new String[]{"h2"},
|
||||||
|
(manager) -> {
|
||||||
|
manager.executeSQL("SET MODE=MySQL");
|
||||||
|
manager.executeSQL("SET DB_CLOSE_DELAY=-1");
|
||||||
|
manager.executeSQL("SET DB_CLOSE_ON_EXIT=FALSE");
|
||||||
|
}
|
||||||
),
|
),
|
||||||
H2("org.h2.Driver", "jdbc:h2:",
|
|
||||||
new String[]{"h2", "h2-db", "h2-database"},
|
H2_MEM("org.h2.Driver", "jdbc:h2:mem:",
|
||||||
new String[]{"SET MODE=MySQL", "SET DB_CLOSE_DELAY=-1"}
|
new String[]{"h2-memory", "h2-temp"},
|
||||||
|
(manager) -> {
|
||||||
|
manager.executeSQL("SET MODE=MySQL");
|
||||||
|
manager.executeSQL("SET DB_CLOSE_DELAY=-1");
|
||||||
|
manager.executeSQL("SET DB_CLOSE_ON_EXIT=FALSE");
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
private final @NotNull String driverClass;
|
private final @NotNull String driverClass;
|
||||||
private final @NotNull String urlPrefix;
|
private final @NotNull String jdbcPrefix;
|
||||||
private final @NotNull String[] databaseAlias;
|
private final @NotNull String[] databaseAlias;
|
||||||
private final @NotNull String[] initializeSQLs;
|
private final @Nullable SQLHandler<SQLManager> initializer;
|
||||||
|
|
||||||
SQLDriverType(@NotNull String driverClass, @NotNull String urlPrefix,
|
SQLDriverType(@NotNull String driverClass, @NotNull String jdbcPrefix,
|
||||||
@NotNull String[] databaseAlias,
|
@Nullable String[] databaseAlias,
|
||||||
@NotNull String[] initializeSQLs) {
|
@Nullable SQLHandler<SQLManager> initializer) {
|
||||||
|
|
||||||
this.driverClass = driverClass;
|
this.driverClass = driverClass;
|
||||||
this.urlPrefix = urlPrefix;
|
this.jdbcPrefix = jdbcPrefix;
|
||||||
this.databaseAlias = databaseAlias;
|
this.databaseAlias = Optional.ofNullable(databaseAlias).orElse(new String[0]);
|
||||||
this.initializeSQLs = initializeSQLs;
|
this.initializer = initializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull String[] getDatabaseAlias() {
|
public @NotNull String[] getDatabaseAlias() {
|
||||||
@ -42,24 +59,24 @@ public enum SQLDriverType {
|
|||||||
return driverClass;
|
return driverClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull String getUrlPrefix() {
|
public @NotNull String getJdbcPrefix() {
|
||||||
return urlPrefix;
|
return jdbcPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull String[] getInitializeSQLs() {
|
public @Nullable SQLHandler<SQLManager> getInitializer() {
|
||||||
return initializeSQLs;
|
return initializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract("null->null")
|
@Contract("null->null")
|
||||||
public static @Nullable SQLDriverType parse(@Nullable String driverString) {
|
public static @Nullable SQLDriverType parse(@Nullable String driverString) {
|
||||||
if (driverString == null) return null;
|
if (driverString == null) return null;
|
||||||
return Arrays.stream(values())
|
return Arrays.stream(values())
|
||||||
.filter(value -> value.name().equalsIgnoreCase(driverString) || has(value.getDatabaseAlias(), driverString))
|
.filter(value -> value.name().equalsIgnoreCase(driverString) || anyMatch(value.getDatabaseAlias(), driverString))
|
||||||
.findFirst().orElse(null);
|
.findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean anyMatch(String[] array, String value) {
|
||||||
private static boolean has(String[] array, String value) {
|
|
||||||
return Arrays.stream(array).anyMatch(s -> s.equalsIgnoreCase(value));
|
return Arrays.stream(array).anyMatch(s -> s.equalsIgnoreCase(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package cc.carm.plugin.minesql.api;
|
|||||||
|
|
||||||
import cc.carm.lib.easysql.api.SQLManager;
|
import cc.carm.lib.easysql.api.SQLManager;
|
||||||
import cc.carm.lib.easysql.api.SQLQuery;
|
import cc.carm.lib.easysql.api.SQLQuery;
|
||||||
|
import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
@ -52,7 +53,7 @@ public interface SQLRegistry {
|
|||||||
* @throws Exception 若创建失败则抛出异常
|
* @throws Exception 若创建失败则抛出异常
|
||||||
*/
|
*/
|
||||||
@NotNull SQLManager create(@NotNull String name,
|
@NotNull SQLManager create(@NotNull String name,
|
||||||
@NotNull DBConfiguration configuration) throws Exception;
|
@NotNull SQLSourceConfig configuration) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建并注册一个新的 SQLManager 实例
|
* 创建并注册一个新的 SQLManager 实例
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package cc.carm.plugin.minesql.api.conf;
|
||||||
|
|
||||||
|
import cc.carm.plugin.minesql.api.SQLDriverType;
|
||||||
|
import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public abstract class SQLDriverConfig {
|
||||||
|
|
||||||
|
protected final @NotNull SQLDriverType type;
|
||||||
|
|
||||||
|
public SQLDriverConfig(@NotNull SQLDriverType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract SQLSourceConfig createSource();
|
||||||
|
|
||||||
|
public @NotNull SQLDriverType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract @NotNull Map<String, Object> serialize();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package cc.carm.plugin.minesql.api.conf.drivers;
|
||||||
|
|
||||||
|
import cc.carm.plugin.minesql.api.SQLDriverType;
|
||||||
|
import cc.carm.plugin.minesql.api.conf.SQLDriverConfig;
|
||||||
|
import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class H2MemConfig extends SQLDriverConfig {
|
||||||
|
|
||||||
|
protected final @Nullable String database;
|
||||||
|
|
||||||
|
public H2MemConfig(@Nullable String database) {
|
||||||
|
super(SQLDriverType.H2_MEM);
|
||||||
|
this.database = database;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable String getDatabase() {
|
||||||
|
return database;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SQLSourceConfig createSource() {
|
||||||
|
return SQLSourceConfig.create(getType().getDriverClass(), buildJDBC(), getType().getInitializer());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String buildJDBC() {
|
||||||
|
return getType().getJdbcPrefix() + Optional.ofNullable(getDatabase()).orElse("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Map<String, Object> serialize() {
|
||||||
|
Map<String, Object> values = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
values.put("type", getType().name());
|
||||||
|
if (getDatabase() != null) values.put("database", getDatabase());
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package cc.carm.plugin.minesql.api.conf.impl;
|
||||||
|
|
||||||
|
import cc.carm.plugin.minesql.MineSQL;
|
||||||
|
import cc.carm.plugin.minesql.api.SQLDriverType;
|
||||||
|
import cc.carm.plugin.minesql.api.conf.SQLDriverConfig;
|
||||||
|
import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class FileBasedConfig extends SQLDriverConfig {
|
||||||
|
|
||||||
|
protected final @NotNull String filePath;
|
||||||
|
|
||||||
|
public FileBasedConfig(@NotNull SQLDriverType type,
|
||||||
|
@NotNull String filePath) {
|
||||||
|
super(type);
|
||||||
|
this.filePath = filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull String getFilePath() {
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SQLSourceConfig createSource() {
|
||||||
|
File file = new File(MineSQL.getDataSourceFolder(), filePath);
|
||||||
|
return SQLSourceConfig.create(getType().getDriverClass(), file.getAbsolutePath(), getType().getInitializer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Map<String, Object> serialize() {
|
||||||
|
Map<String, Object> values = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
values.put("type", getType().name());
|
||||||
|
values.put("file", getFilePath());
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,87 @@
|
|||||||
|
package cc.carm.plugin.minesql.api.conf.impl;
|
||||||
|
|
||||||
|
import cc.carm.plugin.minesql.api.SQLDriverType;
|
||||||
|
import cc.carm.plugin.minesql.api.conf.SQLDriverConfig;
|
||||||
|
import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class RemoteAuthConfig extends SQLDriverConfig {
|
||||||
|
|
||||||
|
protected final @NotNull String host;
|
||||||
|
protected final int port;
|
||||||
|
protected final @NotNull String database;
|
||||||
|
protected final @Nullable String username;
|
||||||
|
protected final @Nullable String password;
|
||||||
|
|
||||||
|
protected final @Nullable String extraSettings;
|
||||||
|
|
||||||
|
public RemoteAuthConfig(@NotNull SQLDriverType type,
|
||||||
|
@NotNull String host, int port, @NotNull String database,
|
||||||
|
@Nullable String username, @Nullable String password,
|
||||||
|
@Nullable String extraSettings) {
|
||||||
|
super(type);
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
this.database = database;
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
this.extraSettings = extraSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SQLSourceConfig createSource() {
|
||||||
|
return SQLSourceConfig.create(
|
||||||
|
getType().getDriverClass(), buildJDBC(), getType().getInitializer()
|
||||||
|
).setUsername(getUsername()).setPassword(getPassword());
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull String getDatabase() {
|
||||||
|
return database;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public @Nullable String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable String getExtraSettings() {
|
||||||
|
return extraSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String buildJDBC() {
|
||||||
|
return String.format("%s%s:%s/%s%s", getType().getJdbcPrefix(), getHost(), getPort(), getDatabase(), getExtraSettings());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Map<String, Object> serialize() {
|
||||||
|
Map<String, Object> values = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
values.put("type", getType().name());
|
||||||
|
|
||||||
|
values.put("host", getHost());
|
||||||
|
values.put("port", getPort());
|
||||||
|
values.put("database", getDatabase());
|
||||||
|
if (getUsername() != null) values.put("username", username);
|
||||||
|
if (getPassword() != null) values.put("password", password);
|
||||||
|
if (getExtraSettings() != null) values.put("extra", extraSettings);
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
package cc.carm.plugin.minesql.api.source;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class SQLPoolSettings {
|
||||||
|
|
||||||
|
private @Nullable String poolName;
|
||||||
|
private @Nullable Integer maxPoolSize;
|
||||||
|
private @Nullable Integer maxActive;
|
||||||
|
|
||||||
|
private @Nullable Integer maxHoldTime;
|
||||||
|
|
||||||
|
private @Nullable Long idleTimeout;
|
||||||
|
|
||||||
|
private @Nullable Long maxWaitTime;
|
||||||
|
|
||||||
|
private @Nullable String schema;
|
||||||
|
private @Nullable Boolean autoCommit;
|
||||||
|
private @Nullable Boolean readOnly;
|
||||||
|
|
||||||
|
private @Nullable String validationSQL;
|
||||||
|
private @Nullable Integer validationTimeout;
|
||||||
|
private @Nullable Long validationInterval;
|
||||||
|
|
||||||
|
public @Nullable String getValidationSQL() {
|
||||||
|
return validationSQL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLPoolSettings setValidationSQL(String validationSQL) {
|
||||||
|
this.validationSQL = validationSQL;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Long getValidationInterval() {
|
||||||
|
return validationInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLPoolSettings setValidationInterval(@Nullable Long validationInterval) {
|
||||||
|
this.validationInterval = validationInterval;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable String getPoolName() {
|
||||||
|
return poolName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLPoolSettings setPoolName(String poolName) {
|
||||||
|
this.poolName = poolName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable String getSchema() {
|
||||||
|
return schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLPoolSettings setSchema(String schema) {
|
||||||
|
this.schema = schema;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Boolean getAutoCommit() {
|
||||||
|
return autoCommit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLPoolSettings setAutoCommit(Boolean autoCommit) {
|
||||||
|
this.autoCommit = autoCommit;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Boolean getReadOnly() {
|
||||||
|
return readOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLPoolSettings setReadOnly(Boolean readOnly) {
|
||||||
|
this.readOnly = readOnly;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Integer getMaxHoldTime() {
|
||||||
|
return maxHoldTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLPoolSettings setMaxHoldTime(@Nullable Integer maxHoldTime) {
|
||||||
|
this.maxHoldTime = maxHoldTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Integer getValidationTimeout() {
|
||||||
|
return validationTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLPoolSettings setValidationTimeout(Integer validationTimeout) {
|
||||||
|
this.validationTimeout = validationTimeout;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Long getIdleTimeout() {
|
||||||
|
return idleTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLPoolSettings setIdleTimeout(Long idleTimeout) {
|
||||||
|
this.idleTimeout = idleTimeout;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Integer getMaxActive() {
|
||||||
|
return maxActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLPoolSettings setMaxActive(Integer maxActive) {
|
||||||
|
this.maxActive = maxActive;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Integer getMaxPoolSize() {
|
||||||
|
return maxPoolSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLPoolSettings setMaxPoolSize(@Nullable Integer maxPoolSize) {
|
||||||
|
this.maxPoolSize = maxPoolSize;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Long getMaxWaitTime() {
|
||||||
|
return maxWaitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLPoolSettings setMaxWaitTime(Long maxWaitTime) {
|
||||||
|
this.maxWaitTime = maxWaitTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,135 @@
|
|||||||
|
package cc.carm.plugin.minesql.api.source;
|
||||||
|
|
||||||
|
import cc.carm.lib.easysql.api.SQLManager;
|
||||||
|
import cc.carm.lib.easysql.api.function.SQLHandler;
|
||||||
|
import cc.carm.plugin.minesql.api.SQLDriverType;
|
||||||
|
import cc.carm.plugin.minesql.api.conf.drivers.H2MemConfig;
|
||||||
|
import cc.carm.plugin.minesql.api.conf.impl.FileBasedConfig;
|
||||||
|
import cc.carm.plugin.minesql.api.conf.impl.RemoteAuthConfig;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class SQLSourceConfig {
|
||||||
|
|
||||||
|
public static SQLSourceConfig createMySQL(@NotNull String host, int port, @NotNull String database,
|
||||||
|
@NotNull String username, @Nullable String password,
|
||||||
|
@Nullable String extraSettings) {
|
||||||
|
return new RemoteAuthConfig(SQLDriverType.MYSQL, host, port, database, username, password, extraSettings).createSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SQLSourceConfig createMariaDB(@NotNull String host, int port, @NotNull String database,
|
||||||
|
@NotNull String username, @Nullable String password,
|
||||||
|
@Nullable String extraSettings) {
|
||||||
|
return new RemoteAuthConfig(SQLDriverType.MARIADB, host, port, database, username, password, extraSettings).createSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SQLSourceConfig createH2File(@NotNull File file) {
|
||||||
|
return create(SQLDriverType.H2_FILE, file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SQLSourceConfig createH2File(@NotNull String filePath) {
|
||||||
|
return new FileBasedConfig(SQLDriverType.H2_FILE, filePath).createSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SQLSourceConfig createH2Mem(@Nullable String databaseName) {
|
||||||
|
return new H2MemConfig(databaseName).createSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SQLSourceConfig create(@NotNull SQLDriverType sourceType, @NotNull String url) {
|
||||||
|
return create(sourceType.getDriverClass(), sourceType.getJdbcPrefix() + url, sourceType.getInitializer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SQLSourceConfig create(@NotNull String driverClass, @NotNull String jdbcURL) {
|
||||||
|
return create(driverClass, jdbcURL, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SQLSourceConfig create(@NotNull String driverClassName, @NotNull String jdbcURL,
|
||||||
|
@Nullable SQLHandler<SQLManager> initializer) {
|
||||||
|
return new SQLSourceConfig(driverClassName, jdbcURL, initializer, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SQLSourceConfig create(@NotNull String driverClassName, @NotNull String jdbcURL,
|
||||||
|
@Nullable SQLHandler<SQLManager> initializer, @Nullable SQLPoolSettings settings) {
|
||||||
|
return new SQLSourceConfig(driverClassName, jdbcURL, initializer, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull String driverClassName;
|
||||||
|
private @NotNull String jdbcURL;
|
||||||
|
private @Nullable String username;
|
||||||
|
private @Nullable String password;
|
||||||
|
|
||||||
|
private @Nullable SQLHandler<SQLManager> initializer;
|
||||||
|
private @NotNull SQLPoolSettings settings;
|
||||||
|
|
||||||
|
public SQLSourceConfig(@NotNull String driverClassName, @NotNull String jdbcURL,
|
||||||
|
@Nullable SQLHandler<SQLManager> initializer, @Nullable SQLPoolSettings settings) {
|
||||||
|
this.driverClassName = driverClassName;
|
||||||
|
this.jdbcURL = jdbcURL;
|
||||||
|
this.initializer = initializer;
|
||||||
|
this.settings = Optional.ofNullable(settings).orElse(new SQLPoolSettings());
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull String getDriverClassName() {
|
||||||
|
return driverClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLSourceConfig setDriverClassName(String driverClassName) {
|
||||||
|
this.driverClassName = driverClassName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull String getJdbcURL() {
|
||||||
|
return jdbcURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLSourceConfig setJdbcURL(String jdbcURL) {
|
||||||
|
this.jdbcURL = jdbcURL;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLSourceConfig setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLSourceConfig setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable SQLHandler<SQLManager> getInitializer() {
|
||||||
|
return initializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLSourceConfig setInitializer(SQLHandler<SQLManager> initializer) {
|
||||||
|
this.initializer = initializer;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull SQLPoolSettings getSettings() {
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLSourceConfig setSettings(SQLPoolSettings settings) {
|
||||||
|
this.settings = settings;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SQLSourceConfig editSettings(Consumer<SQLPoolSettings> consumer) {
|
||||||
|
consumer.accept(settings);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
core/pom.xml
32
core/pom.xml
@ -3,12 +3,11 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>easysql-plugin</artifactId>
|
<artifactId>minesql-parent</artifactId>
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<version>0.0.3-SNAPSHOT</version>
|
<version>0.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
||||||
@ -17,11 +16,11 @@
|
|||||||
<maven.javadoc.skip>true</maven.javadoc.skip>
|
<maven.javadoc.skip>true</maven.javadoc.skip>
|
||||||
<maven.deploy.skip>true</maven.deploy.skip>
|
<maven.deploy.skip>true</maven.deploy.skip>
|
||||||
</properties>
|
</properties>
|
||||||
<artifactId>easysql-plugin-core</artifactId>
|
<artifactId>minesql-core</artifactId>
|
||||||
|
|
||||||
<name>EasySQL-Plugin-Core</name>
|
<name>MineSQL-Core</name>
|
||||||
<description>轻松(用)SQL的独立运行库插件的主要实现部分。</description>
|
<description>轻松(用)SQL的独立运行库插件的主要实现部分。</description>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin</url>
|
<url>https://github.com/CarmJos/MineSQL</url>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
@ -45,19 +44,19 @@
|
|||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>GitHub Issues</system>
|
<system>GitHub Issues</system>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin/issues</url>
|
<url>https://github.com/CarmJos/MineSQL/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>GitHub Actions</system>
|
<system>GitHub Actions</system>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin/actions/workflows/maven.yml</url>
|
<url>https://github.com/CarmJos/MineSQL/actions/workflows/maven.yml</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
<artifactId>easysql-plugin-api</artifactId>
|
<artifactId>minesql-api</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -87,6 +86,18 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyplugin-utils</artifactId>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyconfiguration-yaml</artifactId>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>githubreleases4j</artifactId>
|
<artifactId>githubreleases4j</artifactId>
|
||||||
@ -105,6 +116,7 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--suppress VulnerableLibrariesLocal -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
@ -133,10 +145,6 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
144
core/src/main/java/cc/carm/plugin/minesql/MineSQLCore.java
Normal file
144
core/src/main/java/cc/carm/plugin/minesql/MineSQLCore.java
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
package cc.carm.plugin.minesql;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.EasyConfiguration;
|
||||||
|
import cc.carm.lib.configuration.yaml.YAMLConfigProvider;
|
||||||
|
import cc.carm.lib.easyplugin.utils.JarResourceUtils;
|
||||||
|
import cc.carm.lib.easysql.api.SQLManager;
|
||||||
|
import cc.carm.lib.githubreleases4j.GithubReleases4J;
|
||||||
|
import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
|
||||||
|
import cc.carm.plugin.minesql.command.EasySQLCommand;
|
||||||
|
import cc.carm.plugin.minesql.command.EasySQLHelpFormatter;
|
||||||
|
import cc.carm.plugin.minesql.conf.PluginConfiguration;
|
||||||
|
import cc.carm.plugin.minesql.conf.SQLSourceGroup;
|
||||||
|
import cc.carm.plugin.minesql.util.DBPropertiesUtil;
|
||||||
|
import co.aikar.commands.CommandManager;
|
||||||
|
import co.aikar.commands.InvalidCommandArgument;
|
||||||
|
import co.aikar.commands.Locales;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class MineSQLCore implements IMineSQL {
|
||||||
|
|
||||||
|
public static final String REPO_OWNER = "CarmJos";
|
||||||
|
public static final String REPO_NAME = "MineSQL";
|
||||||
|
|
||||||
|
protected final MineSQLPlatform platform;
|
||||||
|
|
||||||
|
protected final MineSQLRegistry registry;
|
||||||
|
protected final YAMLConfigProvider configProvider;
|
||||||
|
protected final PluginConfiguration config;
|
||||||
|
|
||||||
|
public MineSQLCore(MineSQLPlatform platform) {
|
||||||
|
this.platform = platform;
|
||||||
|
|
||||||
|
getLogger().info("加载配置文件...");
|
||||||
|
this.configProvider = EasyConfiguration.from(new File(platform.getPluginFolder(), "config.yml"));
|
||||||
|
this.config = new PluginConfiguration();
|
||||||
|
this.configProvider.initialize(this.config);
|
||||||
|
|
||||||
|
getLogger().info("初始化注册池...");
|
||||||
|
this.registry = new MineSQLRegistry(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MineSQLPlatform getPlatform() {
|
||||||
|
return platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull MineSQLRegistry getRegistry() {
|
||||||
|
return this.registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull File getPluginFolder() {
|
||||||
|
return getPlatform().getPluginFolder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Logger getLogger() {
|
||||||
|
return getPlatform().getLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PluginConfiguration getConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public YAMLConfigProvider getConfigProvider() {
|
||||||
|
return configProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull Map<String, SQLSourceConfig> readConfigurations() {
|
||||||
|
SQLSourceGroup group = getConfig().SOURCES.getNotNull();
|
||||||
|
Map<String, SQLSourceConfig> sources = new LinkedHashMap<>();
|
||||||
|
group.getSources().forEach((k, v) -> sources.put(k, v.createSource()));
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull Map<String, Properties> readProperties() {
|
||||||
|
if (!getConfig().PROPERTIES.ENABLE.getNotNull()) return new HashMap<>();
|
||||||
|
|
||||||
|
String propertiesFolder = getConfig().PROPERTIES.FOLDER.get();
|
||||||
|
if (propertiesFolder == null || propertiesFolder.length() == 0) return new HashMap<>();
|
||||||
|
|
||||||
|
File file = new File(getPluginFolder(), propertiesFolder);
|
||||||
|
if (!file.exists() || !file.isDirectory()) {
|
||||||
|
try {
|
||||||
|
JarResourceUtils.copyFolderFromJar(
|
||||||
|
"db-properties", file, JarResourceUtils.CopyOption.COPY_IF_NOT_EXIST
|
||||||
|
);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
getLogger().severe("初始化properties示例文件失败:" + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DBPropertiesUtil.readFromFolder(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
protected void initializeCommands(CommandManager<?, ?, ?, ?, ?, ?> commandManager) {
|
||||||
|
commandManager.enableUnstableAPI("help");
|
||||||
|
commandManager.setHelpFormatter(new EasySQLHelpFormatter(commandManager));
|
||||||
|
commandManager.getLocales().setDefaultLocale(Locales.SIMPLIFIED_CHINESE);
|
||||||
|
commandManager.getCommandContexts().registerContext(SQLManager.class, c -> {
|
||||||
|
String name = c.popFirstArg();
|
||||||
|
try {
|
||||||
|
return getRegistry().get(name);
|
||||||
|
} catch (NullPointerException exception) {
|
||||||
|
throw new InvalidCommandArgument("不存在名为 " + name + " 的数据库管理器。");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
commandManager.getCommandCompletions().registerCompletion("sql-managers", c -> {
|
||||||
|
if (c.getIssuer().isPlayer()) return ImmutableList.of();
|
||||||
|
else return ImmutableList.copyOf(getRegistry().list().keySet());
|
||||||
|
});
|
||||||
|
commandManager.registerCommand(new EasySQLCommand(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkUpdate(String currentVersion) {
|
||||||
|
Logger logger = getLogger();
|
||||||
|
|
||||||
|
Integer behindVersions = GithubReleases4J.getVersionBehind(REPO_OWNER, REPO_NAME, currentVersion);
|
||||||
|
String downloadURL = GithubReleases4J.getReleasesURL(REPO_OWNER, REPO_NAME);
|
||||||
|
if (behindVersions == null) {
|
||||||
|
logger.severe("检查更新失败,请您定期查看插件是否更新,避免安全问题。");
|
||||||
|
logger.severe("下载地址 " + downloadURL);
|
||||||
|
} else if (behindVersions < 0) {
|
||||||
|
logger.severe("检查更新失败! 当前版本未知,请您使用原生版本以避免安全问题。");
|
||||||
|
logger.severe("最新版下载地址 " + downloadURL);
|
||||||
|
} else if (behindVersions > 0) {
|
||||||
|
logger.warning("发现新版本! 目前已落后 " + behindVersions + " 个版本。");
|
||||||
|
logger.warning("最新版下载地址 " + downloadURL);
|
||||||
|
} else {
|
||||||
|
logger.info("检查完成,当前已是最新版本。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,52 +1,17 @@
|
|||||||
package cc.carm.plugin.minesql;
|
package cc.carm.plugin.minesql;
|
||||||
|
|
||||||
import cc.carm.lib.easysql.api.SQLManager;
|
|
||||||
import cc.carm.plugin.minesql.api.DBConfiguration;
|
|
||||||
import cc.carm.plugin.minesql.api.SQLRegistry;
|
|
||||||
import cc.carm.plugin.minesql.command.EasySQLCommand;
|
|
||||||
import cc.carm.plugin.minesql.command.EasySQLHelpFormatter;
|
|
||||||
import co.aikar.commands.CommandManager;
|
import co.aikar.commands.CommandManager;
|
||||||
import co.aikar.commands.InvalidCommandArgument;
|
|
||||||
import co.aikar.commands.Locales;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.io.File;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public interface MineSQLPlatform {
|
public interface MineSQLPlatform {
|
||||||
|
|
||||||
@NotNull SQLRegistry getRegistry();
|
@NotNull File getPluginFolder();
|
||||||
|
|
||||||
@NotNull Map<String, DBConfiguration> readConfigurations();
|
@NotNull Logger getLogger();
|
||||||
|
|
||||||
@NotNull Map<String, Properties> readProperties();
|
@NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager();
|
||||||
|
|
||||||
Logger getLogger();
|
|
||||||
|
|
||||||
default void initializeAPI(SQLRegistry registry) {
|
|
||||||
MineSQL.initializeAPI(registry);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
default void initializeCommands(CommandManager<?, ?, ?, ?, ?, ?> commandManager) {
|
|
||||||
commandManager.enableUnstableAPI("help");
|
|
||||||
commandManager.setHelpFormatter(new EasySQLHelpFormatter(commandManager));
|
|
||||||
commandManager.getLocales().setDefaultLocale(Locales.SIMPLIFIED_CHINESE);
|
|
||||||
commandManager.getCommandContexts().registerContext(SQLManager.class, c -> {
|
|
||||||
String name = c.popFirstArg();
|
|
||||||
try {
|
|
||||||
return getRegistry().get(name);
|
|
||||||
} catch (NullPointerException exception) {
|
|
||||||
throw new InvalidCommandArgument("不存在名为 " + name + " 的数据库管理器。");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
commandManager.getCommandCompletions().registerCompletion("sql-managers", c -> {
|
|
||||||
if (c.getIssuer().isPlayer()) return ImmutableList.of();
|
|
||||||
else return ImmutableList.copyOf(getRegistry().list().keySet());
|
|
||||||
});
|
|
||||||
commandManager.registerCommand(new EasySQLCommand());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,8 @@ package cc.carm.plugin.minesql;
|
|||||||
import cc.carm.lib.easysql.api.SQLManager;
|
import cc.carm.lib.easysql.api.SQLManager;
|
||||||
import cc.carm.lib.easysql.api.SQLQuery;
|
import cc.carm.lib.easysql.api.SQLQuery;
|
||||||
import cc.carm.lib.easysql.manager.SQLManagerImpl;
|
import cc.carm.lib.easysql.manager.SQLManagerImpl;
|
||||||
import cc.carm.lib.githubreleases4j.GithubReleases4J;
|
|
||||||
import cc.carm.plugin.minesql.api.DBConfiguration;
|
|
||||||
import cc.carm.plugin.minesql.api.SQLRegistry;
|
import cc.carm.plugin.minesql.api.SQLRegistry;
|
||||||
|
import cc.carm.plugin.minesql.api.source.SQLSourceConfig;
|
||||||
import cn.beecp.BeeDataSource;
|
import cn.beecp.BeeDataSource;
|
||||||
import cn.beecp.BeeDataSourceConfig;
|
import cn.beecp.BeeDataSourceConfig;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@ -18,40 +17,38 @@ import java.util.*;
|
|||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class MineSQLRegistry implements SQLRegistry {
|
public class MineSQLRegistry implements SQLRegistry {
|
||||||
public static final String REPO_OWNER = "CarmJos";
|
|
||||||
public static final String REPO_NAME = "EasySQL-Plugin";
|
|
||||||
|
|
||||||
private static MineSQLRegistry instance;
|
private static MineSQLRegistry instance;
|
||||||
|
|
||||||
protected ExecutorService executorPool;
|
protected ExecutorService executorPool;
|
||||||
protected MineSQLPlatform platform;
|
protected MineSQLCore core;
|
||||||
private final HashMap<String, SQLManagerImpl> sqlManagerRegistry = new HashMap<>();
|
private final HashMap<String, SQLManagerImpl> managers = new HashMap<>();
|
||||||
|
|
||||||
protected MineSQLRegistry(@NotNull MineSQLPlatform platform) {
|
protected MineSQLRegistry(@NotNull MineSQLCore core) {
|
||||||
this.platform = platform;
|
this.core = core;
|
||||||
MineSQLRegistry.instance = this;
|
MineSQLRegistry.instance = this;
|
||||||
this.executorPool = Executors.newFixedThreadPool(2, (r) -> {
|
this.executorPool = Executors.newFixedThreadPool(2, (r) -> {
|
||||||
Thread thread = new Thread(r, "EasySQLRegistry");
|
Thread thread = new Thread(r, "EasySQLRegistry");
|
||||||
thread.setDaemon(true);
|
thread.setDaemon(true);
|
||||||
return thread;
|
return thread;
|
||||||
});
|
});
|
||||||
Map<String, Properties> dbProperties = platform.readProperties();
|
|
||||||
Map<String, DBConfiguration> dbConfigurations = platform.readConfigurations();
|
Map<String, Properties> dbProperties = core.readProperties();
|
||||||
|
Map<String, SQLSourceConfig> dbConfigurations = core.readConfigurations();
|
||||||
|
|
||||||
if (dbProperties.isEmpty() && dbConfigurations.isEmpty()) {
|
if (dbProperties.isEmpty() && dbConfigurations.isEmpty()) {
|
||||||
platform.getLogger().warning("未检测到任何数据库配置,将不会创建任何SQLManager。");
|
core.getLogger().warning("未检测到任何数据库配置,将不会预创建任何SQLManager。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbProperties.forEach((id, properties) -> {
|
dbProperties.forEach((id, properties) -> {
|
||||||
try {
|
try {
|
||||||
SQLManagerImpl sqlManager = create(id, properties);
|
SQLManagerImpl sqlManager = create(id, properties);
|
||||||
this.sqlManagerRegistry.put(id, sqlManager);
|
this.managers.put(id, sqlManager);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
platform.getLogger().warning("初始化SQLManager(#" + id + ") 出错,请检查配置文件.");
|
core.getLogger().warning("初始化SQLManager(#" + id + ") 出错,请检查配置文件.");
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -59,54 +56,86 @@ public class MineSQLRegistry implements SQLRegistry {
|
|||||||
dbConfigurations.forEach((id, configuration) -> {
|
dbConfigurations.forEach((id, configuration) -> {
|
||||||
try {
|
try {
|
||||||
SQLManagerImpl sqlManager = create(id, configuration);
|
SQLManagerImpl sqlManager = create(id, configuration);
|
||||||
this.sqlManagerRegistry.put(id, sqlManager);
|
this.managers.put(id, sqlManager);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
platform.getLogger().warning("初始化SQLManager(#" + id + ") 出错,请检查配置文件.");
|
core.getLogger().warning("初始化SQLManager(#" + id + ") 出错,请检查配置文件.");
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shutdownAll() {
|
||||||
|
this.managers.forEach((k, manager) -> {
|
||||||
|
getCore().getLogger().info(" 正在关闭数据库 " + k + "...");
|
||||||
|
shutdown(manager, activeQueries -> {
|
||||||
|
getCore().getLogger().info(" 数据库 " + k + " 仍有有 " + activeQueries + " 条活动查询");
|
||||||
|
if (manager.getDataSource() instanceof BeeDataSource
|
||||||
|
&& this.core.getConfig().SETTINGS.FORCE_CLOSE.getNotNull()) {
|
||||||
|
getCore().getLogger().info(" 将强制关闭全部活跃链接...");
|
||||||
|
BeeDataSource dataSource = (BeeDataSource) manager.getDataSource();
|
||||||
|
dataSource.close(); //Close bee connection pool
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.managers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected HashMap<String, SQLManagerImpl> getManagers() {
|
||||||
|
return managers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExecutorService getExecutor() {
|
||||||
|
return executorPool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MineSQLRegistry getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MineSQLCore getCore() {
|
||||||
|
return core;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull SQLManagerImpl get(@Nullable String id) throws NullPointerException {
|
public @NotNull SQLManagerImpl get(@Nullable String id) throws NullPointerException {
|
||||||
return Objects.requireNonNull(this.sqlManagerRegistry.get(id), "并不存在ID为 #" + id + " 的SQLManager.");
|
return Objects.requireNonNull(this.managers.get(id), "并不存在ID为 #" + id + " 的SQLManager.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Optional<@Nullable SQLManagerImpl> getOptional(@Nullable String id) {
|
public @NotNull Optional<@Nullable SQLManagerImpl> getOptional(@Nullable String id) {
|
||||||
return Optional.of(this.sqlManagerRegistry.get(id));
|
return Optional.of(this.managers.get(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
public @NotNull Map<String, SQLManagerImpl> list() {
|
public @NotNull Map<String, SQLManagerImpl> list() {
|
||||||
return ImmutableMap.copyOf(this.sqlManagerRegistry);
|
return ImmutableMap.copyOf(this.managers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull SQLManagerImpl create(@NotNull String name, @NotNull DBConfiguration configuration) throws Exception {
|
public @NotNull SQLManagerImpl create(@NotNull String name, @NotNull SQLSourceConfig conf) {
|
||||||
BeeDataSourceConfig config = new BeeDataSourceConfig();
|
BeeDataSourceConfig config = new BeeDataSourceConfig();
|
||||||
config.setDriverClassName(configuration.getDriverClassName());
|
config.setDriverClassName(conf.getDriverClassName());
|
||||||
config.setJdbcUrl(configuration.getUrlPrefix() + configuration.getUrl());
|
config.setJdbcUrl(conf.getJdbcURL());
|
||||||
Optional.ofNullable(configuration.getUsername()).ifPresent(config::setUsername);
|
Optional.ofNullable(conf.getUsername()).ifPresent(config::setUsername);
|
||||||
Optional.ofNullable(configuration.getPassword()).ifPresent(config::setPassword);
|
Optional.ofNullable(conf.getPassword()).ifPresent(config::setPassword);
|
||||||
|
|
||||||
Optional.ofNullable(configuration.getPoolName()).ifPresent(config::setPoolName);
|
Optional.ofNullable(conf.getSettings().getPoolName()).ifPresent(config::setPoolName);
|
||||||
Optional.ofNullable(configuration.getMaxPoolSize()).ifPresent(config::setMaxActive);
|
Optional.ofNullable(conf.getSettings().getMaxPoolSize()).ifPresent(config::setMaxActive);
|
||||||
Optional.ofNullable(configuration.getMaxActive()).ifPresent(config::setMaxActive);
|
Optional.ofNullable(conf.getSettings().getMaxActive()).ifPresent(config::setMaxActive);
|
||||||
|
|
||||||
Optional.ofNullable(configuration.getIdleTimeout()).ifPresent(config::setIdleTimeout);
|
Optional.ofNullable(conf.getSettings().getIdleTimeout()).ifPresent(config::setIdleTimeout);
|
||||||
Optional.ofNullable(configuration.getMaxWaitTime()).ifPresent(config::setMaxWait);
|
Optional.ofNullable(conf.getSettings().getMaxWaitTime()).ifPresent(config::setMaxWait);
|
||||||
Optional.ofNullable(configuration.getMaxHoldTime()).ifPresent(config::setHoldTimeout);
|
Optional.ofNullable(conf.getSettings().getMaxHoldTime()).ifPresent(config::setHoldTimeout);
|
||||||
|
|
||||||
Optional.ofNullable(configuration.getAutoCommit()).ifPresent(config::setDefaultAutoCommit);
|
Optional.ofNullable(conf.getSettings().getAutoCommit()).ifPresent(config::setDefaultAutoCommit);
|
||||||
Optional.ofNullable(configuration.getReadOnly()).ifPresent(config::setDefaultReadOnly);
|
Optional.ofNullable(conf.getSettings().getReadOnly()).ifPresent(config::setDefaultReadOnly);
|
||||||
Optional.ofNullable(configuration.getSchema()).ifPresent(config::setDefaultSchema);
|
Optional.ofNullable(conf.getSettings().getSchema()).ifPresent(config::setDefaultSchema);
|
||||||
|
|
||||||
Optional.ofNullable(configuration.getValidationSQL()).ifPresent(config::setValidTestSql);
|
Optional.ofNullable(conf.getSettings().getValidationSQL()).ifPresent(config::setValidTestSql);
|
||||||
Optional.ofNullable(configuration.getValidationTimeout()).ifPresent(config::setValidTestTimeout);
|
Optional.ofNullable(conf.getSettings().getValidationTimeout()).ifPresent(config::setValidTestTimeout);
|
||||||
Optional.ofNullable(configuration.getValidationInterval()).ifPresent(config::setValidAssumeTime);
|
Optional.ofNullable(conf.getSettings().getValidationInterval()).ifPresent(config::setValidAssumeTime);
|
||||||
|
|
||||||
return create(name, config);
|
return create(name, config);
|
||||||
}
|
}
|
||||||
@ -135,39 +164,4 @@ public class MineSQLRegistry implements SQLRegistry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HashMap<String, SQLManagerImpl> getManagers() {
|
|
||||||
return sqlManagerRegistry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExecutorService getExecutor() {
|
|
||||||
return executorPool;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MineSQLRegistry getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MineSQLPlatform getPlatform() {
|
|
||||||
return platform;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkUpdate(String currentVersion) {
|
|
||||||
Logger logger = getInstance().getPlatform().getLogger();
|
|
||||||
getExecutor().execute(() -> {
|
|
||||||
Integer behindVersions = GithubReleases4J.getVersionBehind(REPO_OWNER, REPO_NAME, currentVersion);
|
|
||||||
String downloadURL = GithubReleases4J.getReleasesURL(REPO_OWNER, REPO_NAME);
|
|
||||||
if (behindVersions == null) {
|
|
||||||
logger.severe("检查更新失败,请您定期查看插件是否更新,避免安全问题。");
|
|
||||||
logger.severe("下载地址 " + downloadURL);
|
|
||||||
} else if (behindVersions < 0) {
|
|
||||||
logger.severe("检查更新失败! 当前版本未知,请您使用原生版本以避免安全问题。");
|
|
||||||
logger.severe("最新版下载地址 " + downloadURL);
|
|
||||||
} else if (behindVersions > 0) {
|
|
||||||
logger.warning("发现新版本! 目前已落后 " + behindVersions + " 个版本。");
|
|
||||||
logger.warning("最新版下载地址 " + downloadURL);
|
|
||||||
} else {
|
|
||||||
logger.info("检查完成,当前已是最新版本。");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package cc.carm.plugin.minesql.command;
|
|||||||
|
|
||||||
import cc.carm.lib.easysql.api.SQLManager;
|
import cc.carm.lib.easysql.api.SQLManager;
|
||||||
import cc.carm.lib.easysql.api.SQLQuery;
|
import cc.carm.lib.easysql.api.SQLQuery;
|
||||||
|
import cc.carm.plugin.minesql.MineSQLCore;
|
||||||
import cc.carm.plugin.minesql.MineSQLRegistry;
|
import cc.carm.plugin.minesql.MineSQLRegistry;
|
||||||
import cc.carm.plugin.minesql.util.VersionReader;
|
import cc.carm.plugin.minesql.util.VersionReader;
|
||||||
import co.aikar.commands.BaseCommand;
|
import co.aikar.commands.BaseCommand;
|
||||||
@ -15,9 +16,15 @@ import java.util.UUID;
|
|||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@CommandAlias("EasySQL")
|
@CommandAlias("EasySQL")
|
||||||
@Description("EasySQL-Plugin的主指令,用于开发者进行调试,只允许后台执行。")
|
@Description("MineSQL的主指令,用于开发者进行调试,只允许后台执行。")
|
||||||
public class EasySQLCommand extends BaseCommand {
|
public class EasySQLCommand extends BaseCommand {
|
||||||
|
|
||||||
|
protected final MineSQLCore core;
|
||||||
|
|
||||||
|
public EasySQLCommand(MineSQLCore core) {
|
||||||
|
this.core = core;
|
||||||
|
}
|
||||||
|
|
||||||
@HelpCommand
|
@HelpCommand
|
||||||
@Syntax("&9[页码或子指令名称]")
|
@Syntax("&9[页码或子指令名称]")
|
||||||
@Description("查看指定数据源的统计信息与当前仍未关闭的查询。")
|
@Description("查看指定数据源的统计信息与当前仍未关闭的查询。")
|
||||||
@ -49,7 +56,7 @@ public class EasySQLCommand extends BaseCommand {
|
|||||||
issuer.sendMessage("§8 - &f数据库驱动 h2-database §9" + reader.get("h2-driver"));
|
issuer.sendMessage("§8 - &f数据库驱动 h2-database §9" + reader.get("h2-driver"));
|
||||||
|
|
||||||
issuer.sendMessage("§r正在检查插件更新,请稍候...");
|
issuer.sendMessage("§r正在检查插件更新,请稍候...");
|
||||||
MineSQLRegistry.getInstance().checkUpdate(pluginVersion);
|
core.checkUpdate(pluginVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("list")
|
@Subcommand("list")
|
||||||
|
@ -10,7 +10,7 @@ public class EasySQLHelpFormatter extends CommandHelpFormatter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printHelpHeader(CommandHelp help, CommandIssuer issuer) {
|
public void printHelpHeader(CommandHelp help, CommandIssuer issuer) {
|
||||||
issuer.sendMessage("§3§lEasySQL-Plugin §7指令帮助");
|
issuer.sendMessage("§3§lMineSQL §7指令帮助");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -27,7 +27,7 @@ public class EasySQLHelpFormatter extends CommandHelpFormatter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printSearchHeader(CommandHelp help, CommandIssuer issuer) {
|
public void printSearchHeader(CommandHelp help, CommandIssuer issuer) {
|
||||||
issuer.sendMessage("§3§lEasySQL-Plugin §7指令帮助查询");
|
issuer.sendMessage("§3§lMineSQL §7指令帮助查询");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,7 +41,7 @@ public class EasySQLHelpFormatter extends CommandHelpFormatter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printDetailedHelpHeader(CommandHelp help, CommandIssuer issuer, HelpEntry entry) {
|
public void printDetailedHelpHeader(CommandHelp help, CommandIssuer issuer, HelpEntry entry) {
|
||||||
issuer.sendMessage("§3§lEasySQL-Plugin §7指令帮助 §8(§f" + entry.getCommand() + "§8)");
|
issuer.sendMessage("§3§lMineSQL §7指令帮助 §8(§f" + entry.getCommand() + "§8)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
package cc.carm.plugin.minesql.conf;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.core.ConfigurationRoot;
|
||||||
|
import cc.carm.lib.configuration.core.annotation.HeaderComment;
|
||||||
|
import cc.carm.lib.configuration.core.value.ConfigValue;
|
||||||
|
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
|
||||||
|
|
||||||
|
public class PluginConfiguration extends ConfigurationRoot {
|
||||||
|
|
||||||
|
@HeaderComment("排错模式,一般留给开发者检查问题,平常使用无需开启。")
|
||||||
|
public ConfigValue<Boolean> DEBUG = ConfiguredValue.of(Boolean.class, false);
|
||||||
|
|
||||||
|
@HeaderComment({
|
||||||
|
"统计数据设定",
|
||||||
|
"该选项用于帮助开发者统计插件版本与使用情况,且绝不会影响性能与使用体验。",
|
||||||
|
"当然,您也可以选择在这里关闭,或在plugins/bStats下的配置文件中关闭所有插件的统计信息。"
|
||||||
|
})
|
||||||
|
public ConfigValue<Boolean> METRICS = ConfiguredValue.of(Boolean.class, true);
|
||||||
|
|
||||||
|
@HeaderComment({
|
||||||
|
"检查更新设定",
|
||||||
|
"该选项用于插件判断是否要检查更新,若您不希望插件检查更新并提示您,可以选择关闭。",
|
||||||
|
"检查更新为异步操作,绝不会影响性能与使用体验。"
|
||||||
|
})
|
||||||
|
public ConfigValue<Boolean> UPDATE_CHECKER = ConfiguredValue.of(Boolean.class, true);
|
||||||
|
|
||||||
|
@HeaderComment({"插件注册池配置"})
|
||||||
|
public SettingsConfig SETTINGS = new SettingsConfig();
|
||||||
|
|
||||||
|
@HeaderComment({
|
||||||
|
"Properties 数据库配置文件配置",
|
||||||
|
"相关配置介绍(BeeCP) https://github.com/Chris2018998/BeeCP/wiki/Configuration--List#配置列表"
|
||||||
|
})
|
||||||
|
public PropertiesConfig PROPERTIES = new PropertiesConfig();
|
||||||
|
|
||||||
|
@HeaderComment({
|
||||||
|
"数据库源配置",
|
||||||
|
"目前支持的驱动类型(type)有 mariadb、mysql、h2-file(文件数据库) 与 h2-mem(内存临时数据库)。",
|
||||||
|
"详细配置介绍请查看 https://github.com/CarmJos/MineSQL/.doc/README.md"
|
||||||
|
})
|
||||||
|
public ConfigValue<SQLSourceGroup> SOURCES = ConfigValue.builder()
|
||||||
|
.asValue(SQLSourceGroup.class).fromSection()
|
||||||
|
.parseValue((w, d) -> SQLSourceGroup.parse(w))
|
||||||
|
.serializeValue(SQLSourceGroup::serialize)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
public static class PropertiesConfig extends ConfigurationRoot {
|
||||||
|
|
||||||
|
@HeaderComment("该选项用于启用 Properties 配置读取,若您不希望插件启用 Properties 文件配置,可以选择关闭。")
|
||||||
|
public ConfigValue<Boolean> ENABLE = ConfiguredValue.of(Boolean.class, true);
|
||||||
|
|
||||||
|
@HeaderComment({
|
||||||
|
"文件夹路径,将读取该文件夹下的所有 .properties 文件,并以文件名为数据管理器名称。",
|
||||||
|
"读取时,将排除以 “.” 开头的文件与非 .properties 文件。",
|
||||||
|
"默认为 \"db-properties/\" 相对路径,指向“plugins/MineSQL/db-properties/”;",
|
||||||
|
"该选项也支持绝对路径,但使用绝对路径时,请务必注意权限问题。"
|
||||||
|
})
|
||||||
|
public ConfigValue<String> FOLDER = ConfiguredValue.of(String.class, "db-properties/");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SettingsConfig extends ConfigurationRoot {
|
||||||
|
|
||||||
|
@HeaderComment({"在插件卸载时是否强制关闭活跃链接"})
|
||||||
|
public ConfigValue<Boolean> FORCE_CLOSE = ConfiguredValue.of(Boolean.class, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
package cc.carm.plugin.minesql.conf;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
|
||||||
|
import cc.carm.plugin.minesql.MineSQL;
|
||||||
|
import cc.carm.plugin.minesql.api.SQLDriverType;
|
||||||
|
import cc.carm.plugin.minesql.api.conf.SQLDriverConfig;
|
||||||
|
import cc.carm.plugin.minesql.api.conf.drivers.H2MemConfig;
|
||||||
|
import cc.carm.plugin.minesql.api.conf.impl.FileBasedConfig;
|
||||||
|
import cc.carm.plugin.minesql.api.conf.impl.RemoteAuthConfig;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SQLSourceGroup {
|
||||||
|
|
||||||
|
protected final LinkedHashMap<String, SQLDriverConfig> sources;
|
||||||
|
|
||||||
|
public SQLSourceGroup(LinkedHashMap<String, SQLDriverConfig> sources) {
|
||||||
|
this.sources = sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, SQLDriverConfig> getSources() {
|
||||||
|
return Collections.unmodifiableMap(sources);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull Map<String, Object> serialize() {
|
||||||
|
Map<String, Object> data = new LinkedHashMap<>();
|
||||||
|
this.sources.forEach((k, v) -> data.put(k, v.serialize()));
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @NotNull SQLSourceGroup parse(ConfigurationWrapper<?> rootSection) {
|
||||||
|
LinkedHashMap<String, SQLDriverConfig> configs = new LinkedHashMap<>();
|
||||||
|
for (String name : rootSection.getKeys(false)) {
|
||||||
|
if (!rootSection.isConfigurationSection(name)) continue;
|
||||||
|
ConfigurationWrapper<?> section = rootSection.getConfigurationSection(name);
|
||||||
|
if (section == null) continue;
|
||||||
|
SQLDriverConfig conf = parse(name, section);
|
||||||
|
if (conf != null) configs.put(name, conf);
|
||||||
|
}
|
||||||
|
return new SQLSourceGroup(configs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable SQLDriverConfig parse(String name, ConfigurationWrapper<?> section) {
|
||||||
|
@Nullable String driverString = section.getString("type");
|
||||||
|
@Nullable SQLDriverType driverType = SQLDriverType.parse(driverString);
|
||||||
|
if (driverType == null) {
|
||||||
|
MineSQL.getLogger().severe("驱动类型 " + driverString + " 不存在于预设中," + " 请检查配置文件 sources." + name + "。");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (driverType) {
|
||||||
|
case MYSQL:
|
||||||
|
case MARIADB: {
|
||||||
|
String host = section.getString("host");
|
||||||
|
int port = section.getInt("port", 0);
|
||||||
|
String database = section.getString("database");
|
||||||
|
if (host == null || database == null || !(port > 0 && port <= 65535)) {
|
||||||
|
MineSQL.getLogger().severe("数据库连接配置有误," + " 请检查配置文件 sources." + name + "。");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String username = section.getString("username");
|
||||||
|
String password = section.getString("password");
|
||||||
|
String extra = section.getString("extra");
|
||||||
|
return new RemoteAuthConfig(driverType, host, port, database, username, password, extra);
|
||||||
|
}
|
||||||
|
case H2_MEM: {
|
||||||
|
return new H2MemConfig(section.getString("database"));
|
||||||
|
}
|
||||||
|
case H2_FILE: {
|
||||||
|
String filePath = section.getString("file");
|
||||||
|
if (filePath == null) {
|
||||||
|
MineSQL.getLogger().severe("数据库文件地址配置有误," + " 请检查配置文件 sources." + name + "。");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new FileBasedConfig(SQLDriverType.H2_FILE, filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,22 +0,0 @@
|
|||||||
package cc.carm.plugin.minesql.configuration;
|
|
||||||
|
|
||||||
import cc.carm.plugin.minesql.api.DBConfiguration;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public interface PluginConfiguration {
|
|
||||||
|
|
||||||
boolean isDebugEnabled();
|
|
||||||
|
|
||||||
boolean isMetricsEnabled();
|
|
||||||
|
|
||||||
boolean isUpdateCheckerEnabled();
|
|
||||||
|
|
||||||
boolean isPropertiesEnabled();
|
|
||||||
|
|
||||||
String getPropertiesFolder();
|
|
||||||
|
|
||||||
@NotNull Map<String, DBConfiguration> getDBConfigurations();
|
|
||||||
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
package cc.carm.plugin.minesql.util;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipInputStream;
|
|
||||||
|
|
||||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
|
||||||
public class JarResourceUtils {
|
|
||||||
public static final char JAR_SEPARATOR = '/';
|
|
||||||
|
|
||||||
public static @Nullable String[] readResource(@Nullable InputStream resourceStream) {
|
|
||||||
if (resourceStream == null) return null;
|
|
||||||
try (Scanner scanner = new Scanner(resourceStream, "UTF-8")) {
|
|
||||||
List<String> contents = new ArrayList<>();
|
|
||||||
while (scanner.hasNextLine()) {
|
|
||||||
contents.add(scanner.nextLine());
|
|
||||||
}
|
|
||||||
return contents.toArray(new String[0]);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void copyFolderFromJar(String folderName, File destFolder, CopyOption option)
|
|
||||||
throws IOException {
|
|
||||||
copyFolderFromJar(folderName, destFolder, option, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void copyFolderFromJar(String folderName, File destFolder,
|
|
||||||
CopyOption option, PathTrimmer trimmer) throws IOException {
|
|
||||||
if (!destFolder.exists())
|
|
||||||
destFolder.mkdirs();
|
|
||||||
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
|
|
||||||
File fullPath;
|
|
||||||
String path = JarResourceUtils.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
|
||||||
if (trimmer != null)
|
|
||||||
path = trimmer.trim(path);
|
|
||||||
try {
|
|
||||||
if (!path.startsWith("file"))
|
|
||||||
path = "file://" + path;
|
|
||||||
|
|
||||||
fullPath = new File(new URI(path));
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(fullPath));
|
|
||||||
|
|
||||||
ZipEntry entry;
|
|
||||||
while ((entry = zis.getNextEntry()) != null) {
|
|
||||||
if (!entry.getName().startsWith(folderName + JAR_SEPARATOR))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
String fileName = entry.getName();
|
|
||||||
|
|
||||||
if (fileName.charAt(fileName.length() - 1) == JAR_SEPARATOR) {
|
|
||||||
File file = new File(destFolder + File.separator + fileName);
|
|
||||||
if (file.isFile()) {
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
file.mkdirs();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
File file = new File(destFolder + File.separator + fileName);
|
|
||||||
if (option == CopyOption.COPY_IF_NOT_EXIST && file.exists())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!file.getParentFile().exists())
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
|
|
||||||
if (!file.exists())
|
|
||||||
file.createNewFile();
|
|
||||||
FileOutputStream fos = new FileOutputStream(file);
|
|
||||||
|
|
||||||
int len;
|
|
||||||
while ((len = zis.read(buffer)) > 0) {
|
|
||||||
fos.write(buffer, 0, len);
|
|
||||||
}
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
zis.closeEntry();
|
|
||||||
zis.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum CopyOption {
|
|
||||||
COPY_IF_NOT_EXIST, REPLACE_IF_EXIST
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface PathTrimmer {
|
|
||||||
String trim(String original);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,6 @@
|
|||||||
|
&d __ ____ &f________ __
|
||||||
&3 ______ _____ ____ _ &f_____ _ _
|
&d / |/ (_)__ ___ &f/ __/ __ \ / /
|
||||||
&3| ____| / ____|/ __ \| | &f| __ \| | (_)
|
&d / /|_/ / / _ \/ -_)&f\ \/ /_/ / / /__
|
||||||
&3| |__ __ _ ___ _ _| (___ | | | | | &f| |__) | |_ _ __ _ _ _ __
|
&d/_/ /_/_/_//_/\__/&f___/\___\_\/____/
|
||||||
&3| __| / _` / __| | | |\___ \| | | | | &f| ___/| | | | |/ _` | | '_ \
|
&8# &dMine&fSQL &8&o(EasySQL-Plugin) &7v&f${project.version}
|
||||||
&3| |___| (_| \__ \ |_| |____) | |__| | |____ &f| | | | |_| | (_| | | | | |
|
&8- &7查看更多信息请访问项目主页&f https://github.com/CarmJos/MineSQL
|
||||||
&3|______\__,_|___/\__, |_____/ \___\_\______| &f|_| |_|\__,_|\__, |_|_| |_|
|
|
||||||
&3 __/ | &f __/ |
|
|
||||||
&3 |___/ &f|___/
|
|
||||||
|
|
||||||
&f 查看更多信息请访问项目主页&f https://github.com/CarmJos/EasySQL-Plugin
|
|
@ -1,11 +1,11 @@
|
|||||||
# suppress inspection "SpellCheckingInspection" for whole file
|
# suppress inspection "SpellCheckingInspection" for whole file
|
||||||
|
|
||||||
plugin=${project.version}
|
plugin=${project.version}
|
||||||
api=${easysql.version}
|
api=${deps.easysql.version}
|
||||||
|
|
||||||
beecp=${beecp.version}
|
beecp=${deps.beecp.version}
|
||||||
|
|
||||||
mysql-driver=${mysql-driver.version}
|
mysql-driver=${deps.mysql-driver.version}
|
||||||
mariadb-driver=${mariadb-driver.version}
|
mariadb-driver=${deps.mariadb-driver.version}
|
||||||
h2-driver=${h2-driver.version}
|
h2-driver=${deps.h2-driver.version}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>easysql-plugin</artifactId>
|
<artifactId>minesql-parent</artifactId>
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<version>0.0.3-SNAPSHOT</version>
|
<version>0.0.3-SNAPSHOT</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
@ -19,12 +19,12 @@
|
|||||||
<maven.deploy.skip>true</maven.deploy.skip>
|
<maven.deploy.skip>true</maven.deploy.skip>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<artifactId>easysql-plugin-bukkit</artifactId>
|
<artifactId>minesql-bukkit</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>EasySQL-Plugin-Bukkit</name>
|
<name>MineSQL-Bukkit</name>
|
||||||
<description>轻松(用)SQL的独立运行库Bukkit版本插件。</description>
|
<description>轻松(用)SQL的独立运行库Bukkit版本插件。</description>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin</url>
|
<url>https://github.com/CarmJos/MineSQL</url>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
@ -48,19 +48,19 @@
|
|||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>GitHub Issues</system>
|
<system>GitHub Issues</system>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin/issues</url>
|
<url>https://github.com/CarmJos/MineSQL/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>GitHub Actions</system>
|
<system>GitHub Actions</system>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin/actions/workflows/maven.yml</url>
|
<url>https://github.com/CarmJos/MineSQL/actions/workflows/maven.yml</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
<artifactId>easysql-plugin-core</artifactId>
|
<artifactId>minesql-core</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -68,7 +68,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easyplugin-main</artifactId>
|
<artifactId>easyplugin-main</artifactId>
|
||||||
<version>${easyplugin.version}</version>
|
<version>${deps.easyplugin.version}</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -102,66 +102,15 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>3.2.3</version>
|
</plugin>
|
||||||
<executions>
|
<plugin>
|
||||||
<execution>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<phase>package</phase>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<goals>
|
</plugin>
|
||||||
<goal>shade</goal>
|
<plugin>
|
||||||
</goals>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
</execution>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
</executions>
|
|
||||||
|
|
||||||
<configuration>
|
|
||||||
<finalName>${project.name}-${project.version}</finalName>
|
|
||||||
<outputDirectory>${project.parent.basedir}/asset/</outputDirectory>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
<relocations>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.bstats</pattern>
|
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.bstats</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.json</pattern>
|
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.json</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>cc.carm.lib.easyplugin</pattern>
|
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.easyplugin</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>cc.carm.lib.githubreleases4j</pattern>
|
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.githubreleases4j</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>co.aikar.commands</pattern>
|
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.acf</shadedPattern> <!-- Replace this -->
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>co.aikar.locales</pattern>
|
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.locales</shadedPattern> <!-- Replace this -->
|
|
||||||
</relocation>
|
|
||||||
</relocations>
|
|
||||||
<filters>
|
|
||||||
<filter>
|
|
||||||
<artifact>co.aikar:*</artifact>
|
|
||||||
<excludes>
|
|
||||||
<exclude>META-INF/MANIFEST.MF</exclude>
|
|
||||||
<exclude>META-INF/*.txt</exclude>
|
|
||||||
<exclude>acf-core*.properties</exclude>
|
|
||||||
<exclude>acf-minecraft*.properties</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
<filter>
|
|
||||||
<artifact>*:*</artifact>
|
|
||||||
<excludes>
|
|
||||||
<exclude>META-INF/MANIFEST.MF</exclude>
|
|
||||||
<exclude>META-INF/*.txt</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
</filters>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
@ -1,90 +0,0 @@
|
|||||||
package cc.carm.plugin.minesql;
|
|
||||||
|
|
||||||
import cc.carm.plugin.minesql.api.DBConfiguration;
|
|
||||||
import cc.carm.plugin.minesql.api.SQLDriverType;
|
|
||||||
import cc.carm.plugin.minesql.configuration.PluginConfiguration;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class BukkitConfiguration implements PluginConfiguration {
|
|
||||||
|
|
||||||
private final @NotNull FileConfiguration configuration;
|
|
||||||
|
|
||||||
protected BukkitConfiguration(@NotNull FileConfiguration configuration) {
|
|
||||||
this.configuration = configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull FileConfiguration getConfiguration() {
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDebugEnabled() {
|
|
||||||
return getConfiguration().getBoolean("debug", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isMetricsEnabled() {
|
|
||||||
return getConfiguration().getBoolean("metrics", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isUpdateCheckerEnabled() {
|
|
||||||
return getConfiguration().getBoolean("check-update", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPropertiesEnabled() {
|
|
||||||
return getConfiguration().getBoolean("properties.enable", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPropertiesFolder() {
|
|
||||||
return getConfiguration().getString("properties.folder", "db-properties/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Map<String, DBConfiguration> getDBConfigurations() {
|
|
||||||
Map<String, DBConfiguration> dbConfigurations = new LinkedHashMap<>();
|
|
||||||
ConfigurationSection dbConfigurationsSection = getConfiguration().getConfigurationSection("databases");
|
|
||||||
if (dbConfigurationsSection != null) {
|
|
||||||
for (String dbName : dbConfigurationsSection.getKeys(false)) {
|
|
||||||
if (dbName.startsWith("example-")) continue;
|
|
||||||
ConfigurationSection dbSection = dbConfigurationsSection.getConfigurationSection(dbName);
|
|
||||||
if (dbSection == null) continue;
|
|
||||||
|
|
||||||
String driverString = dbSection.getString("driver-type");
|
|
||||||
SQLDriverType driverType = SQLDriverType.parse(driverString);
|
|
||||||
if (driverType == null) {
|
|
||||||
MineSQLBukkit.getInstance().error("不存在预设的驱动类型 " + driverString + "," + " 请检查配置文件 databases." + dbName + "。");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String host = dbSection.getString("host");
|
|
||||||
if (host == null) {
|
|
||||||
MineSQLBukkit.getInstance().error("地址配置不得为空," + " 请检查配置文件 databases." + dbName + "。");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int port = dbSection.getInt("port", -1);
|
|
||||||
if (port < 0) {
|
|
||||||
MineSQLBukkit.getInstance().error("端口未配置正确," + " 请检查配置文件 databases." + dbName + "。");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
DBConfiguration dbConfiguration = DBConfiguration.create(driverType, host + ":" + port);
|
|
||||||
|
|
||||||
String username = dbSection.getString("username");
|
|
||||||
String password = dbSection.getString("password");
|
|
||||||
|
|
||||||
dbConfiguration.setUsername(username);
|
|
||||||
dbConfiguration.setPassword(password);
|
|
||||||
|
|
||||||
dbConfigurations.put(dbName, dbConfiguration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dbConfigurations;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,147 +1,88 @@
|
|||||||
package cc.carm.plugin.minesql;
|
package cc.carm.plugin.minesql;
|
||||||
|
|
||||||
import cc.carm.lib.easyplugin.EasyPlugin;
|
import cc.carm.lib.easyplugin.EasyPlugin;
|
||||||
import cc.carm.lib.easyplugin.i18n.EasyPluginMessageProvider;
|
import cc.carm.plugin.minesql.conf.PluginConfiguration;
|
||||||
import cc.carm.lib.easysql.api.SQLManager;
|
|
||||||
import cc.carm.plugin.minesql.api.DBConfiguration;
|
|
||||||
import cc.carm.plugin.minesql.util.DBPropertiesUtil;
|
|
||||||
import cc.carm.plugin.minesql.util.JarResourceUtils;
|
|
||||||
import cn.beecp.BeeDataSource;
|
|
||||||
import co.aikar.commands.PaperCommandManager;
|
import co.aikar.commands.PaperCommandManager;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bstats.charts.SimplePie;
|
import org.bstats.charts.SimplePie;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class MineSQLBukkit extends EasyPlugin implements MineSQLPlatform {
|
public class MineSQLBukkit extends EasyPlugin implements MineSQLPlatform {
|
||||||
|
|
||||||
public MineSQLBukkit() {
|
|
||||||
super(new EasyPluginMessageProvider.zh_CN());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static MineSQLBukkit instance;
|
protected static MineSQLBukkit instance;
|
||||||
|
|
||||||
private BukkitConfiguration configuration;
|
protected MineSQLCore core;
|
||||||
private MineSQLRegistry registry;
|
protected PaperCommandManager commandManager;
|
||||||
|
|
||||||
private PaperCommandManager commandManager;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load() {
|
protected void load() {
|
||||||
MineSQLBukkit.instance = this;
|
MineSQLBukkit.instance = this;
|
||||||
|
|
||||||
log("加载配置文件...");
|
log("加载基础核心...");
|
||||||
getInstance().saveDefaultConfig();
|
this.core = new MineSQLCore(this);
|
||||||
this.configuration = new BukkitConfiguration(getInstance().getConfig());
|
|
||||||
|
|
||||||
log("初始化EasySQL注册器...");
|
log("初始化MineSQL API...");
|
||||||
this.registry = new MineSQLRegistry(this);
|
MineSQL.initializeAPI(this.core);
|
||||||
|
|
||||||
log("初始化EasySQLAPI...");
|
|
||||||
initializeAPI(getRegistry()); // 尽快地初始化接口,方便其他插件调用
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean initialize() {
|
protected boolean initialize() {
|
||||||
log("初始化指令管理器...");
|
log("初始化指令管理器...");
|
||||||
this.commandManager = new PaperCommandManager(this);
|
this.commandManager = new PaperCommandManager(this);
|
||||||
log("注册相关指令...");
|
|
||||||
initializeCommands(getCommandManager());
|
|
||||||
|
|
||||||
if (getConfiguration().isMetricsEnabled()) {
|
log("注册相关指令...");
|
||||||
|
this.core.initializeCommands(getCommandManager());
|
||||||
|
|
||||||
|
if (getConfiguration().METRICS.getNotNull()) {
|
||||||
log("启用统计数据...");
|
log("启用统计数据...");
|
||||||
Metrics metrics = new Metrics(this, 14075);
|
Metrics metrics = new Metrics(this, 14075);
|
||||||
metrics.addCustomChart(new SimplePie("update_check",
|
metrics.addCustomChart(new SimplePie("update_check",
|
||||||
() -> getConfiguration().isUpdateCheckerEnabled() ? "ENABLED" : "DISABLED")
|
() -> getConfiguration().UPDATE_CHECKER.getNotNull() ? "ENABLED" : "DISABLED")
|
||||||
);
|
);
|
||||||
metrics.addCustomChart(new SimplePie("properties_configuration",
|
metrics.addCustomChart(new SimplePie("properties_configuration",
|
||||||
() -> getConfiguration().isPropertiesEnabled() ? "ENABLED" : "DISABLED")
|
() -> getConfiguration().PROPERTIES.ENABLE.getNotNull() ? "ENABLED" : "DISABLED")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getConfiguration().isUpdateCheckerEnabled()) {
|
if (getConfiguration().PROPERTIES.ENABLE.getNotNull()) {
|
||||||
log("开始检查更新...");
|
log("开始检查更新,可能需要一小段时间...");
|
||||||
getRegistry().checkUpdate(getDescription().getVersion());
|
log(" 如不希望检查更新,可在配置文件中关闭。");
|
||||||
|
getScheduler().runAsync(() -> this.core.checkUpdate(getDescription().getVersion()));
|
||||||
} else {
|
} else {
|
||||||
log("已禁用检查更新,跳过。");
|
log("已禁用检查更新,跳过。");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void shutdown() {
|
protected void shutdown() {
|
||||||
log("终止全部数据库连接...");
|
log("终止全部数据库连接...");
|
||||||
for (String dbName : new HashSet<>(getRegistry().list().keySet())) {
|
this.core.getRegistry().shutdownAll();
|
||||||
log(" 正在关闭数据库 " + dbName + "...");
|
|
||||||
SQLManager manager = getRegistry().get(dbName);
|
|
||||||
getRegistry().shutdown(manager, activeQueries -> {
|
|
||||||
log(" 数据库 " + dbName + " 仍有有 " + activeQueries + " 条活动查询,强制关闭中...");
|
|
||||||
if (manager.getDataSource() instanceof BeeDataSource) {
|
|
||||||
BeeDataSource dataSource = (BeeDataSource) manager.getDataSource();
|
|
||||||
dataSource.close(); //Close bee connection pool
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getRegistry().getManagers().clear(); // release all managers
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebugging() {
|
public boolean isDebugging() {
|
||||||
return getConfiguration().isDebugEnabled();
|
return getConfiguration().DEBUG.getNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static @NotNull MineSQLBukkit getInstance() {
|
||||||
@NotNull
|
|
||||||
public MineSQLRegistry getRegistry() {
|
|
||||||
return this.registry;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull
|
|
||||||
Map<String, DBConfiguration> readConfigurations() {
|
|
||||||
return getConfiguration().getDBConfigurations();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull
|
|
||||||
Map<String, Properties> readProperties() {
|
|
||||||
if (!getConfiguration().isPropertiesEnabled()) return new HashMap<>();
|
|
||||||
String propertiesFolder = getConfiguration().getPropertiesFolder();
|
|
||||||
if (propertiesFolder == null || propertiesFolder.length() == 0) return new HashMap<>();
|
|
||||||
|
|
||||||
File file = new File(getDataFolder(), propertiesFolder);
|
|
||||||
if (!file.exists() || !file.isDirectory()) {
|
|
||||||
try {
|
|
||||||
JarResourceUtils.copyFolderFromJar(
|
|
||||||
"db-properties", file,
|
|
||||||
JarResourceUtils.CopyOption.COPY_IF_NOT_EXIST
|
|
||||||
);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
error("初始化properties示例文件失败:" + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return DBPropertiesUtil.readFromFolder(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void outputInfo() {
|
|
||||||
Optional.ofNullable(JarResourceUtils.readResource(this.getResource("PLUGIN_INFO"))).ifPresent(this::log);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MineSQLBukkit getInstance() {
|
|
||||||
return MineSQLBukkit.instance;
|
return MineSQLBukkit.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BukkitConfiguration getConfiguration() {
|
public @NotNull PluginConfiguration getConfiguration() {
|
||||||
return configuration;
|
return this.core.getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PaperCommandManager getCommandManager() {
|
public @NotNull PaperCommandManager getCommandManager() {
|
||||||
return commandManager;
|
return commandManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull File getPluginFolder() {
|
||||||
|
return getDataFolder();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
main: cc.carm.plugin.easysql.EasySQLBukkit
|
main: cc.carm.plugin.minesql.MineSQLBukkit
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
prefix: EasySQL-Plugin
|
|
||||||
name: EasySQL-Plugin
|
prefix: MineSQL
|
||||||
|
name: MineSQL
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
|
|
||||||
website: ${project.url}
|
website: ${project.url}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>easysql-plugin</artifactId>
|
<artifactId>minesql-parent</artifactId>
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<version>0.0.3-SNAPSHOT</version>
|
<version>0.0.3-SNAPSHOT</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
@ -19,12 +19,12 @@
|
|||||||
<maven.deploy.skip>true</maven.deploy.skip>
|
<maven.deploy.skip>true</maven.deploy.skip>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<artifactId>easysql-plugin-bungee</artifactId>
|
<artifactId>minesql-bungee</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>EasySQL-Plugin-Bungee</name>
|
<name>MineSQL-Bungee</name>
|
||||||
<description>轻松(用)SQL的独立运行库Bungee版本插件。</description>
|
<description>轻松(用)SQL的独立运行库Bungee版本插件。</description>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin</url>
|
<url>https://github.com/CarmJos/MineSQL</url>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
@ -48,12 +48,12 @@
|
|||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>GitHub Issues</system>
|
<system>GitHub Issues</system>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin/issues</url>
|
<url>https://github.com/CarmJos/MineSQL/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>GitHub Actions</system>
|
<system>GitHub Actions</system>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin/actions/workflows/maven.yml</url>
|
<url>https://github.com/CarmJos/MineSQL/actions/workflows/maven.yml</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
<artifactId>easysql-plugin-core</artifactId>
|
<artifactId>minesql-core</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -108,7 +108,6 @@
|
|||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -123,60 +122,6 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.2.3</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<finalName>${project.name}-${project.version}</finalName>
|
|
||||||
<outputDirectory>${project.parent.basedir}/asset/</outputDirectory>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
<filters>
|
|
||||||
<filter>
|
|
||||||
<artifact>*:*</artifact>
|
|
||||||
<excludes>
|
|
||||||
<exclude>META-INF/MANIFEST.MF</exclude>
|
|
||||||
<exclude>META-INF/*.txt</exclude>
|
|
||||||
<exclude>acf-minecraft*.properties</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
</filters>
|
|
||||||
<relocations>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.bstats</pattern>
|
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.bstats</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.json</pattern>
|
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.json</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>cc.carm.lib.githubreleases4j</pattern>
|
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.githubreleases4j</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>co.aikar.commands</pattern>
|
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.acf</shadedPattern> <!-- Replace this -->
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>co.aikar.locales</pattern>
|
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.locales</shadedPattern> <!-- Replace this -->
|
|
||||||
</relocation>
|
|
||||||
</relocations>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
package cc.carm.plugin.minesql;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
import net.md_5.bungee.config.Configuration;
|
|
||||||
import net.md_5.bungee.config.ConfigurationProvider;
|
|
||||||
import net.md_5.bungee.config.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
|
|
||||||
public class EasySQLBungee extends Plugin {
|
|
||||||
|
|
||||||
private boolean setup = false;
|
|
||||||
|
|
||||||
private void saveDefaultConfig() {
|
|
||||||
if (!getDataFolder().exists())
|
|
||||||
getDataFolder().mkdir();
|
|
||||||
|
|
||||||
File file = new File(getDataFolder(), "config.yml");
|
|
||||||
|
|
||||||
|
|
||||||
if (!file.exists()) {
|
|
||||||
try (InputStream in = getResourceAsStream("config.yml")) {
|
|
||||||
Files.copy(in, file.toPath());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setup() {
|
|
||||||
if (setup) return;
|
|
||||||
saveDefaultConfig();
|
|
||||||
// 读取配置文件 - 预注册 instance
|
|
||||||
Configuration configuration;
|
|
||||||
try {
|
|
||||||
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Configuration instancesConfig = configuration.getSection("instances");
|
|
||||||
if (instancesConfig != null) {
|
|
||||||
}
|
|
||||||
setup = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoad() {
|
|
||||||
setup();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
setup();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
getLogger().info("Shutting down...");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,93 @@
|
|||||||
|
package cc.carm.plugin.minesql;
|
||||||
|
|
||||||
|
import cc.carm.plugin.minesql.conf.PluginConfiguration;
|
||||||
|
import co.aikar.commands.BungeeCommandManager;
|
||||||
|
import co.aikar.commands.CommandManager;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
import org.bstats.bungeecord.Metrics;
|
||||||
|
import org.bstats.charts.SimplePie;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class MineSQLBungee extends Plugin implements MineSQLPlatform {
|
||||||
|
|
||||||
|
protected static MineSQLBungee instance;
|
||||||
|
|
||||||
|
protected MineSQLCore core;
|
||||||
|
protected BungeeCommandManager commandManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
MineSQLBungee.instance = this;
|
||||||
|
|
||||||
|
getLogger().info("加载基础核心...");
|
||||||
|
this.core = new MineSQLCore(this);
|
||||||
|
|
||||||
|
getLogger().info("初始化MineSQL API...");
|
||||||
|
MineSQL.initializeAPI(this.core);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
getLogger().info("初始化指令管理器...");
|
||||||
|
this.commandManager = new BungeeCommandManager(this);
|
||||||
|
|
||||||
|
getLogger().info("注册相关指令...");
|
||||||
|
this.core.initializeCommands(getCommandManager());
|
||||||
|
|
||||||
|
if (getConfiguration().METRICS.getNotNull()) {
|
||||||
|
getLogger().info("启用统计数据...");
|
||||||
|
Metrics metrics = new Metrics(this, 14076);
|
||||||
|
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().PROPERTIES.ENABLE.getNotNull()) {
|
||||||
|
getLogger().info("开始检查更新,可能需要一小段时间...");
|
||||||
|
getLogger().info(" 如不希望检查更新,可在配置文件中关闭。");
|
||||||
|
ProxyServer.getInstance().getScheduler().runAsync(
|
||||||
|
this, () -> this.core.checkUpdate(getDescription().getVersion())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
getLogger().info("已禁用检查更新,跳过。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
getLogger().info("终止全部数据库连接...");
|
||||||
|
this.core.getRegistry().shutdownAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MineSQLBungee getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Logger getLogger() {
|
||||||
|
return super.getLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull PluginConfiguration getConfiguration() {
|
||||||
|
return this.core.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull File getPluginFolder() {
|
||||||
|
return getDataFolder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
|
||||||
|
return this.commandManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
8
platforms/bungee/src/main/resources/bungee.yml
Normal file
8
platforms/bungee/src/main/resources/bungee.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
main: cc.carm.plugin.minesql.MineSQLBungee
|
||||||
|
name: MineSQL
|
||||||
|
version: ${project.version}
|
||||||
|
|
||||||
|
website: ${project.url}
|
||||||
|
description: ${project.description}
|
||||||
|
|
||||||
|
author: "CarmJos"
|
@ -1,184 +0,0 @@
|
|||||||
package cc.carm.plugin.minesql;
|
|
||||||
|
|
||||||
import cc.carm.lib.easysql.api.SQLManager;
|
|
||||||
import cc.carm.plugin.minesql.api.DBConfiguration;
|
|
||||||
import cc.carm.plugin.minesql.configuration.PluginConfiguration;
|
|
||||||
import cc.carm.plugin.minesql.util.DBPropertiesUtil;
|
|
||||||
import cc.carm.plugin.minesql.util.JarResourceUtils;
|
|
||||||
import cn.beecp.BeeDataSource;
|
|
||||||
import com.google.common.io.MoreFiles;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.bstats.charts.SimplePie;
|
|
||||||
import org.bstats.sponge.Metrics;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.spongepowered.api.Server;
|
|
||||||
import org.spongepowered.api.config.ConfigDir;
|
|
||||||
import org.spongepowered.api.event.Listener;
|
|
||||||
import org.spongepowered.api.event.lifecycle.StoppingEngineEvent;
|
|
||||||
import org.spongepowered.configurate.ConfigurateException;
|
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
|
|
||||||
import org.spongepowered.plugin.PluginContainer;
|
|
||||||
import org.spongepowered.plugin.builtin.jvm.Plugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 2022/6/20<br>
|
|
||||||
* MineSQL<br>
|
|
||||||
*
|
|
||||||
* @author huanmeng_qwq
|
|
||||||
*/
|
|
||||||
@Plugin("easysql-plugin")
|
|
||||||
public class MineSQLSponge implements MineSQLPlatform {
|
|
||||||
@Inject
|
|
||||||
@ConfigDir(sharedRoot = false)
|
|
||||||
private Path configDirectory;
|
|
||||||
@Inject
|
|
||||||
private org.apache.logging.log4j.Logger logger;
|
|
||||||
|
|
||||||
private static MineSQLSponge instance;
|
|
||||||
private ConfigurationNode root;
|
|
||||||
private PluginConfiguration configuration;
|
|
||||||
private MineSQLRegistry registry;
|
|
||||||
private PluginContainer pluginContainer;
|
|
||||||
|
|
||||||
private final Metrics metrics;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public MineSQLSponge(Metrics.Factory factory, PluginContainer pluginContainer) {
|
|
||||||
this.metrics = factory.make(14075);
|
|
||||||
instance = this;
|
|
||||||
HoconConfigurationLoader loader = HoconConfigurationLoader.builder().path(resolveConfig()).build();
|
|
||||||
try {
|
|
||||||
this.root = loader.load();
|
|
||||||
this.configuration = new SpongeConfiguration(root);
|
|
||||||
this.registry = new MineSQLRegistry(this);
|
|
||||||
this.pluginContainer = pluginContainer;
|
|
||||||
enable();
|
|
||||||
} catch (ConfigurateException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
|
||||||
public void disable(StoppingEngineEvent<Server> e) {
|
|
||||||
getLog().info("终止全部数据库连接...");
|
|
||||||
for (String dbName : new HashSet<>(getRegistry().list().keySet())) {
|
|
||||||
getLog().info(" 正在关闭数据库 " + dbName + "...");
|
|
||||||
SQLManager manager = getRegistry().get(dbName);
|
|
||||||
getRegistry().shutdown(manager, activeQueries -> {
|
|
||||||
getLog().info(" 数据库 " + dbName + " 仍有有 " + activeQueries + " 条活动查询,强制关闭中...");
|
|
||||||
if (manager.getDataSource() instanceof BeeDataSource) {
|
|
||||||
BeeDataSource dataSource = (BeeDataSource) manager.getDataSource();
|
|
||||||
dataSource.close(); //Close bee connection pool
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getRegistry().getManagers().clear(); // release all managers
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void enable() {
|
|
||||||
/*
|
|
||||||
//todo acf-commands not support sponge8
|
|
||||||
getLog().info("初始化指令管理器...");
|
|
||||||
getLog().info("注册相关指令...");
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (getConfiguration().isMetricsEnabled()) {
|
|
||||||
getLog().info("启用统计数据...");
|
|
||||||
metrics.addCustomChart(new SimplePie("update_check",
|
|
||||||
() -> getConfiguration().isUpdateCheckerEnabled() ? "ENABLED" : "DISABLED")
|
|
||||||
);
|
|
||||||
metrics.addCustomChart(new SimplePie("properties_configuration",
|
|
||||||
() -> getConfiguration().isPropertiesEnabled() ? "ENABLED" : "DISABLED")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getConfiguration().isUpdateCheckerEnabled()) {
|
|
||||||
getLog().info("开始检查更新...");
|
|
||||||
getRegistry().checkUpdate(pluginContainer.metadata().version().getQualifier());
|
|
||||||
} else {
|
|
||||||
getLog().info("已禁用检查更新,跳过。");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Map<String, DBConfiguration> readConfigurations() {
|
|
||||||
return configuration.getDBConfigurations();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Map<String, Properties> readProperties() {
|
|
||||||
if (!getConfiguration().isPropertiesEnabled()) return new HashMap<>();
|
|
||||||
String propertiesFolder = getConfiguration().getPropertiesFolder();
|
|
||||||
if (propertiesFolder == null || propertiesFolder.length() == 0) return new HashMap<>();
|
|
||||||
|
|
||||||
File file = new File(configDirectory.toFile(), propertiesFolder);
|
|
||||||
if (!file.exists() || !file.isDirectory()) {
|
|
||||||
try {
|
|
||||||
JarResourceUtils.copyFolderFromJar(
|
|
||||||
"db-properties", file,
|
|
||||||
JarResourceUtils.CopyOption.COPY_IF_NOT_EXIST
|
|
||||||
);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.error("初始化properties示例文件失败:" + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return DBPropertiesUtil.readFromFolder(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private Path resolveConfig() {
|
|
||||||
Path path = configDirectory.resolve("easysql.conf");
|
|
||||||
if (!Files.exists(path)) {
|
|
||||||
try {
|
|
||||||
//noinspection UnstableApiUsage
|
|
||||||
MoreFiles.createParentDirectories(configDirectory);
|
|
||||||
try (InputStream is = getClass().getClassLoader().getResourceAsStream("easysql.conf")) {
|
|
||||||
Files.copy(is, path);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfigurationNode getRootConfig() {
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PluginConfiguration getConfiguration() {
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull MineSQLRegistry getRegistry() {
|
|
||||||
return registry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public java.util.logging.Logger getLogger() {
|
|
||||||
return java.util.logging.Logger.getLogger("easysql-plugin");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MineSQLSponge getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Logger getLog() {
|
|
||||||
return logger;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
package cc.carm.plugin.minesql;
|
|
||||||
|
|
||||||
import cc.carm.plugin.minesql.api.DBConfiguration;
|
|
||||||
import cc.carm.plugin.minesql.api.SQLDriverType;
|
|
||||||
import cc.carm.plugin.minesql.configuration.PluginConfiguration;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 2022/6/20<br>
|
|
||||||
* MineSQL<br>
|
|
||||||
*
|
|
||||||
* @author huanmeng_qwq
|
|
||||||
*/
|
|
||||||
public class SpongeConfiguration implements PluginConfiguration {
|
|
||||||
private final ConfigurationNode config;
|
|
||||||
|
|
||||||
public SpongeConfiguration(ConfigurationNode config) {
|
|
||||||
this.config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDebugEnabled() {
|
|
||||||
return config.node("debug").getBoolean(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isMetricsEnabled() {
|
|
||||||
return config.node("metrics").getBoolean(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isUpdateCheckerEnabled() {
|
|
||||||
return config.node("check-update").getBoolean(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPropertiesEnabled() {
|
|
||||||
return config.node("properties", "enable").getBoolean(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPropertiesFolder() {
|
|
||||||
return config.node("properties", "folder").getString("db-properties/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Map<String, DBConfiguration> getDBConfigurations() {
|
|
||||||
Map<String, DBConfiguration> dbConfigurations = new LinkedHashMap<>();
|
|
||||||
ConfigurationNode dbConfigurationsSection = config.node("databases");
|
|
||||||
if (dbConfigurationsSection != null) {
|
|
||||||
for (Map.Entry<Object, ? extends ConfigurationNode> dbEntry : dbConfigurationsSection.childrenMap().entrySet()) {
|
|
||||||
if (dbEntry.getKey().toString().startsWith("example-")) continue;
|
|
||||||
ConfigurationNode dbSection = dbEntry.getValue();
|
|
||||||
if (dbSection == null) continue;
|
|
||||||
|
|
||||||
String driverString = dbSection.getString("driver-type");
|
|
||||||
SQLDriverType driverType = SQLDriverType.parse(driverString);
|
|
||||||
if (driverType == null) {
|
|
||||||
MineSQLSponge.getInstance().getLog().error("不存在预设的驱动类型 " + driverString + "," + " 请检查配置文件 databases." + dbEntry + "。");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String host = dbSection.getString("host");
|
|
||||||
if (host == null) {
|
|
||||||
MineSQLSponge.getInstance().getLog().error("地址配置不得为空," + " 请检查配置文件 databases." + dbEntry + "。");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int port = dbSection.node("port").getInt(-1);
|
|
||||||
if (port < 0) {
|
|
||||||
MineSQLSponge.getInstance().getLog().error("端口未配置正确," + " 请检查配置文件 databases." + dbEntry + "。");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
DBConfiguration dbConfiguration = DBConfiguration.create(driverType, host + ":" + port);
|
|
||||||
|
|
||||||
String username = dbSection.getString("username");
|
|
||||||
String password = dbSection.getString("password");
|
|
||||||
|
|
||||||
dbConfiguration.setUsername(username);
|
|
||||||
dbConfiguration.setPassword(password);
|
|
||||||
dbConfigurations.put(dbEntry.getKey().toString(), dbConfiguration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dbConfigurations;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
debug = false
|
|
||||||
metrics = false
|
|
||||||
check-update = true
|
|
||||||
properties {
|
|
||||||
enable = true
|
|
||||||
folder = "db-properties/"
|
|
||||||
}
|
|
||||||
databases {
|
|
||||||
example-test {
|
|
||||||
driver-type = "MYSQL"
|
|
||||||
host = "localhost"
|
|
||||||
port = -1
|
|
||||||
username = "root"
|
|
||||||
password = "root"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>easysql-plugin</artifactId>
|
<artifactId>minesql-parent</artifactId>
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<version>0.0.3-SNAPSHOT</version>
|
<version>0.0.3-SNAPSHOT</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
@ -19,12 +19,12 @@
|
|||||||
<maven.deploy.skip>true</maven.deploy.skip>
|
<maven.deploy.skip>true</maven.deploy.skip>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<artifactId>easysql-plugin-velocity</artifactId>
|
<artifactId>minesql-velocity</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>EasySQL-Plugin-Velocity</name>
|
<name>MineSQL-Velocity</name>
|
||||||
<description>轻松(用)SQL的独立运行库Velocity版本插件。</description>
|
<description>轻松(用)SQL的独立运行库Velocity版本插件。</description>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin</url>
|
<url>https://github.com/CarmJos/MineSQL</url>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
@ -48,12 +48,12 @@
|
|||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>GitHub Issues</system>
|
<system>GitHub Issues</system>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin/issues</url>
|
<url>https://github.com/CarmJos/MineSQL/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>GitHub Actions</system>
|
<system>GitHub Actions</system>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin/actions/workflows/maven.yml</url>
|
<url>https://github.com/CarmJos/MineSQL/actions/workflows/maven.yml</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
<artifactId>easysql-plugin-core</artifactId>
|
<artifactId>minesql-core</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -97,9 +97,9 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -114,37 +114,6 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.2.3</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<finalName>${project.name}-${project.version}</finalName>
|
|
||||||
<outputDirectory>${project.parent.basedir}/asset/</outputDirectory>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
<filters>
|
|
||||||
<filter>
|
|
||||||
<artifact>*:*</artifact>
|
|
||||||
<excludes>
|
|
||||||
<exclude>META-INF/MANIFEST.MF</exclude>
|
|
||||||
<exclude>META-INF/*.txt</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
</filters>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
package cc.carm.plugin.minesql;
|
|
||||||
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
|
||||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
|
||||||
import com.velocitypowered.api.plugin.Plugin;
|
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
|
|
||||||
@Plugin(id = "easysql-plugin", name = "EasySQL-Plugin",
|
|
||||||
version = "1.0.0",
|
|
||||||
description = "EasySQL Plugin For Velocity",
|
|
||||||
url = "https://github.com/CarmJos/EasySQL-Plugin",
|
|
||||||
authors = {"CarmJos", "GhostChu"}
|
|
||||||
)
|
|
||||||
public class EasySQLVelocity {
|
|
||||||
|
|
||||||
private static EasySQLVelocity instance;
|
|
||||||
|
|
||||||
private final ProxyServer server;
|
|
||||||
private final Logger logger;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public EasySQLVelocity(ProxyServer server, Logger logger) {
|
|
||||||
instance = this;
|
|
||||||
this.server = server;
|
|
||||||
this.logger = logger;
|
|
||||||
// register listeners
|
|
||||||
server.getEventManager().register(this, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EasySQLVelocity getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProxyServer getServer() {
|
|
||||||
return server;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Logger getLogger() {
|
|
||||||
return logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onInitialize(ProxyInitializeEvent event) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,130 @@
|
|||||||
|
package cc.carm.plugin.minesql;
|
||||||
|
|
||||||
|
|
||||||
|
import cc.carm.plugin.minesql.conf.PluginConfiguration;
|
||||||
|
import co.aikar.commands.CommandManager;
|
||||||
|
import co.aikar.commands.VelocityCommandManager;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
|
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||||
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
|
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 org.bstats.charts.SimplePie;
|
||||||
|
import org.bstats.velocity.Metrics;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
|
@Plugin(id = "minesql", name = "MineSQL (EasySQL-Plugin)", version = "1.0.0",
|
||||||
|
description = "EasySQL Plugin For Velocity",
|
||||||
|
url = "https://github.com/CarmJos/MineSQL",
|
||||||
|
authors = {"CarmJos", "GhostChu"}
|
||||||
|
)
|
||||||
|
public class MineSQLVelocity implements MineSQLPlatform {
|
||||||
|
|
||||||
|
private static MineSQLVelocity instance;
|
||||||
|
|
||||||
|
private final ProxyServer server;
|
||||||
|
private final Logger logger;
|
||||||
|
private final File dataFolder;
|
||||||
|
|
||||||
|
private final Metrics.Factory metricsFactory;
|
||||||
|
|
||||||
|
protected MineSQLCore core;
|
||||||
|
protected VelocityCommandManager commandManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public MineSQLVelocity(ProxyServer server, Logger logger,
|
||||||
|
@DataDirectory Path dataDirectory,
|
||||||
|
Metrics.Factory metricsFactory) {
|
||||||
|
instance = this;
|
||||||
|
this.server = server;
|
||||||
|
this.logger = logger;
|
||||||
|
this.dataFolder = dataDirectory.toFile();
|
||||||
|
this.metricsFactory = metricsFactory;
|
||||||
|
|
||||||
|
getLogger().info("加载基础核心...");
|
||||||
|
this.core = new MineSQLCore(this);
|
||||||
|
|
||||||
|
getLogger().info("初始化MineSQL API...");
|
||||||
|
MineSQL.initializeAPI(this.core);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
|
public void onInitialize(ProxyInitializeEvent event) {
|
||||||
|
|
||||||
|
getLogger().info("初始化指令管理器...");
|
||||||
|
this.commandManager = new VelocityCommandManager(server, this);
|
||||||
|
|
||||||
|
getLogger().info("注册相关指令...");
|
||||||
|
this.core.initializeCommands(getCommandManager());
|
||||||
|
|
||||||
|
if (getConfiguration().METRICS.getNotNull()) {
|
||||||
|
getLogger().info("启用统计数据...");
|
||||||
|
Metrics metrics = this.metricsFactory.make(this, 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().PROPERTIES.ENABLE.getNotNull()) {
|
||||||
|
getLogger().info("开始检查更新,可能需要一小段时间...");
|
||||||
|
getLogger().info(" 如不希望检查更新,可在配置文件中关闭。");
|
||||||
|
server.getScheduler().buildTask(this, () -> this.core.checkUpdate(getVersion())).schedule();
|
||||||
|
} else {
|
||||||
|
getLogger().info("已禁用检查更新,跳过。");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe(order = PostOrder.LAST)
|
||||||
|
public void onShutdown(ProxyShutdownEvent event) {
|
||||||
|
getLogger().info("终止全部数据库连接...");
|
||||||
|
this.core.getRegistry().shutdownAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MineSQLVelocity getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProxyServer getServer() {
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return this.server.getPluginManager().getPlugin("minesql")
|
||||||
|
.map(PluginContainer::getDescription)
|
||||||
|
.flatMap(PluginDescription::getVersion).orElse("1.0.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull File getPluginFolder() {
|
||||||
|
return this.dataFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull Logger getLogger() {
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull CommandManager<?, ?, ?, ?, ?, ?> getCommandManager() {
|
||||||
|
return commandManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull PluginConfiguration getConfiguration() {
|
||||||
|
return this.core.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -3,13 +3,11 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>easysql-plugin</artifactId>
|
<artifactId>minesql-parent</artifactId>
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<version>0.0.3-SNAPSHOT</version>
|
<version>0.0.3-SNAPSHOT</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
||||||
@ -18,75 +16,28 @@
|
|||||||
<maven.javadoc.skip>true</maven.javadoc.skip>
|
<maven.javadoc.skip>true</maven.javadoc.skip>
|
||||||
<maven.deploy.skip>true</maven.deploy.skip>
|
<maven.deploy.skip>true</maven.deploy.skip>
|
||||||
</properties>
|
</properties>
|
||||||
|
<artifactId>minesql-plugin</artifactId>
|
||||||
<artifactId>easysql-plugin-sponge</artifactId>
|
|
||||||
|
|
||||||
<name>EasySQL-Plugin-Sponge</name>
|
|
||||||
<description>轻松(用)SQL的独立运行库Sponge版本插件。</description>
|
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin</url>
|
|
||||||
|
|
||||||
<developers>
|
|
||||||
<developer>
|
|
||||||
<id>CarmJos</id>
|
|
||||||
<name>Carm Jos</name>
|
|
||||||
<email>carm@carm.cc</email>
|
|
||||||
<url>https://www.carm.cc</url>
|
|
||||||
<roles>
|
|
||||||
<role>Main Developer</role>
|
|
||||||
<role>Designer</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>http://repo.spongepowered.org/maven</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
<artifactId>easysql-plugin-core</artifactId>
|
<artifactId>minesql-bukkit</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spongepowered</groupId>
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
<artifactId>spongeapi</artifactId>
|
<artifactId>minesql-bungee</artifactId>
|
||||||
<version>8.0.0</version>
|
<version>${project.parent.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>ninja.leaping.configurate</groupId>
|
|
||||||
<artifactId>configurate-hocon</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
<artifactId>bstats-sponge</artifactId>
|
<artifactId>minesql-velocity</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>${project.parent.version}</version>
|
||||||
<optional>true</optional>
|
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -94,22 +45,6 @@
|
|||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<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>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
@ -122,19 +57,11 @@
|
|||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<finalName>${project.name}-${project.version}</finalName>
|
<finalName>${project.parent.name}-${project.parent.version}</finalName>
|
||||||
<outputDirectory>${project.parent.basedir}/asset/</outputDirectory>
|
<outputDirectory>${project.parent.basedir}/.asset/</outputDirectory>
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
<filters>
|
|
||||||
<filter>
|
|
||||||
<artifact>*:*</artifact>
|
|
||||||
<excludes>
|
|
||||||
<exclude>META-INF/MANIFEST.MF</exclude>
|
|
||||||
<exclude>META-INF/*.txt</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
</filters>
|
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.bstats</pattern>
|
<pattern>org.bstats</pattern>
|
||||||
@ -144,6 +71,10 @@
|
|||||||
<pattern>org.json</pattern>
|
<pattern>org.json</pattern>
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.json</shadedPattern>
|
<shadedPattern>cc.carm.plugin.minesql.lib.json</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>cc.carm.lib.easyplugin</pattern>
|
||||||
|
<shadedPattern>cc.carm.plugin.minesql.lib.easyplugin</shadedPattern>
|
||||||
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>cc.carm.lib.githubreleases4j</pattern>
|
<pattern>cc.carm.lib.githubreleases4j</pattern>
|
||||||
<shadedPattern>cc.carm.plugin.minesql.lib.githubreleases4j</shadedPattern>
|
<shadedPattern>cc.carm.plugin.minesql.lib.githubreleases4j</shadedPattern>
|
||||||
@ -157,6 +88,24 @@
|
|||||||
<shadedPattern>cc.carm.plugin.minesql.lib.locales</shadedPattern> <!-- Replace this -->
|
<shadedPattern>cc.carm.plugin.minesql.lib.locales</shadedPattern> <!-- Replace this -->
|
||||||
</relocation>
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
|
<filters>
|
||||||
|
<filter>
|
||||||
|
<artifact>co.aikar:*</artifact>
|
||||||
|
<excludes>
|
||||||
|
<exclude>META-INF/MANIFEST.MF</exclude>
|
||||||
|
<exclude>META-INF/*.txt</exclude>
|
||||||
|
<exclude>acf-core*.properties</exclude>
|
||||||
|
<exclude>acf-minecraft*.properties</exclude>
|
||||||
|
</excludes>
|
||||||
|
</filter>
|
||||||
|
<filter>
|
||||||
|
<artifact>*:*</artifact>
|
||||||
|
<excludes>
|
||||||
|
<exclude>META-INF/MANIFEST.MF</exclude>
|
||||||
|
<exclude>META-INF/*.txt</exclude>
|
||||||
|
</excludes>
|
||||||
|
</filter>
|
||||||
|
</filters>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
90
pom.xml
90
pom.xml
@ -11,18 +11,18 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
|
|
||||||
<easysql.version>0.3.8</easysql.version>
|
<deps.easysql.version>0.4.6</deps.easysql.version>
|
||||||
<easyplugin.version>1.3.8</easyplugin.version>
|
<deps.easyconf.version>3.3.1</deps.easyconf.version>
|
||||||
|
<deps.easyplugin.version>1.4.18</deps.easyplugin.version>
|
||||||
<beecp.version>3.3.2</beecp.version>
|
<deps.beecp.version>3.3.9</deps.beecp.version>
|
||||||
<mysql-driver.version>8.0.28</mysql-driver.version>
|
|
||||||
<mariadb-driver.version>3.0.3</mariadb-driver.version>
|
|
||||||
<h2-driver.version>2.1.210</h2-driver.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>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<artifactId>easysql-plugin</artifactId>
|
<artifactId>minesql-parent</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>0.0.3-SNAPSHOT</version>
|
<version>0.0.3-SNAPSHOT</version>
|
||||||
<modules>
|
<modules>
|
||||||
@ -32,12 +32,12 @@
|
|||||||
<module>platforms/bukkit</module>
|
<module>platforms/bukkit</module>
|
||||||
<module>platforms/bungee</module>
|
<module>platforms/bungee</module>
|
||||||
<module>platforms/velocity</module>
|
<module>platforms/velocity</module>
|
||||||
<module>platforms/sponge</module>
|
<module>plugin</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<name>EasySQL-Plugin</name>
|
<name>MineSQL</name>
|
||||||
<description>轻松(用)SQL的独立运行库插件,支持多种服务端,适用于MineCraft全版本。</description>
|
<description>轻松(用)SQL的独立运行库插件,支持多种服务端,适用于MineCraft全版本。</description>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin</url>
|
<url>https://github.com/CarmJos/MineSQL</url>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
@ -50,6 +50,16 @@
|
|||||||
<role>Designer</role>
|
<role>Designer</role>
|
||||||
</roles>
|
</roles>
|
||||||
</developer>
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>Ghost-Chu</id>
|
||||||
|
<name>鬼畜</name>
|
||||||
|
<url>https://github.com/Ghost-Chu/</url>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>huanmeng_qwq</id>
|
||||||
|
<name>幻梦</name>
|
||||||
|
<url>https://github.com/huanmeng-qwq/</url>
|
||||||
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
@ -61,31 +71,25 @@
|
|||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>GitHub Issues</system>
|
<system>GitHub Issues</system>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin/issues</url>
|
<url>https://github.com/CarmJos/MineSQL/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>GitHub Actions</system>
|
<system>GitHub Actions</system>
|
||||||
<url>https://github.com/CarmJos/EasySQL-Plugin/actions/workflows/maven.yml</url>
|
<url>https://github.com/CarmJos/MineSQL/actions/workflows/maven.yml</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<downloadUrl>https://github.com/CarmJos/EasySQL-Plugin/releases</downloadUrl>
|
<downloadUrl>https://github.com/CarmJos/MineSQL/releases</downloadUrl>
|
||||||
<repository>
|
<repository>
|
||||||
<id>github</id>
|
<id>github</id>
|
||||||
<name>GitHub Packages</name>
|
<name>GitHub Packages</name>
|
||||||
<url>https://maven.pkg.github.com/CarmJos/EasySQL-Plugin</url>
|
<url>https://maven.pkg.github.com/CarmJos/MineSQL</url>
|
||||||
</repository>
|
</repository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|
||||||
<repository>
|
|
||||||
<id>carm-repo</id>
|
|
||||||
<name>Carm's Repo</name>
|
|
||||||
<url>https://repo.carm.cc/repository/maven-public/</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>aikar</id>
|
<id>aikar</id>
|
||||||
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
||||||
@ -96,6 +100,12 @@
|
|||||||
<url>https://repo1.maven.org/maven2/</url>
|
<url>https://repo1.maven.org/maven2/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>carm-repo</id>
|
||||||
|
<name>Carm's Repo</name>
|
||||||
|
<url>https://repo.carm.cc/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -103,7 +113,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains</groupId>
|
<groupId>org.jetbrains</groupId>
|
||||||
<artifactId>annotations</artifactId>
|
<artifactId>annotations</artifactId>
|
||||||
<version>23.0.0</version>
|
<version>23.1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -124,7 +134,7 @@
|
|||||||
<!--项目地址 https://github.com/Chris2018998/BeeCP -->
|
<!--项目地址 https://github.com/Chris2018998/BeeCP -->
|
||||||
<groupId>com.github.chris2018998</groupId>
|
<groupId>com.github.chris2018998</groupId>
|
||||||
<artifactId>beecp</artifactId>
|
<artifactId>beecp</artifactId>
|
||||||
<version>${beecp.version}</version>
|
<version>${deps.beecp.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -136,13 +146,37 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easysql-api</artifactId>
|
<artifactId>easysql-api</artifactId>
|
||||||
<version>${easysql.version}</version>
|
<version>${deps.easysql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easysql-impl</artifactId>
|
<artifactId>easysql-impl</artifactId>
|
||||||
<version>${easysql.version}</version>
|
<version>${deps.easysql.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyconfiguration-core</artifactId>
|
||||||
|
<version>${deps.easyconf.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyconfiguration-yaml</artifactId>
|
||||||
|
<version>${deps.easyconf.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyplugin-utils</artifactId>
|
||||||
|
<version>${deps.easyplugin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyplugin-githubchecker</artifactId>
|
||||||
|
<version>${deps.easyplugin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
|
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
|
||||||
@ -156,21 +190,21 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mariadb.jdbc</groupId>
|
<groupId>org.mariadb.jdbc</groupId>
|
||||||
<artifactId>mariadb-java-client</artifactId>
|
<artifactId>mariadb-java-client</artifactId>
|
||||||
<version>${mariadb-driver.version}</version>
|
<version>${deps.mariadb-driver.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
|
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>${mysql-driver.version}</version>
|
<version>${deps.mysql-driver.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
|
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>${h2-driver.version}</version>
|
<version>${deps.h2-driver.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
Loading…
Reference in New Issue
Block a user