mirror of
https://github.com/CarmJos/EasyPlugin.git
synced 2026-06-05 00:58:17 +08:00
Compare commits
79 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fbc153c9e9 | |||
| 3c7508c348 | |||
| 5fa255d7c7 | |||
| ce1122712d | |||
| 45426e947b | |||
| 7e3a2ea13e | |||
| 226121c1df | |||
| 94c9cc382d | |||
| 892371f702 | |||
| 12ff00e1d9 | |||
| 10f5961ccd | |||
| d8cbf2825d | |||
| f4292e761a | |||
| 47018fbf7d | |||
| dd277e99e8 | |||
| b3078553e7 | |||
| e67e23a24c | |||
| 30e57e3945 | |||
| acea995996 | |||
| 511d8d77c4 | |||
| 96ff3398c8 | |||
| 42860c332f | |||
| 5ea196b6df | |||
| fe34bbc17d | |||
| c575805c72 | |||
| 9c73fa81bc | |||
| 5a61c2db14 | |||
| d15204a38e | |||
| dcbf1678ba | |||
| 116f3419f2 | |||
| 29321f2b25 | |||
| ef453d9481 | |||
| d0d36023c8 | |||
| 4fa3ffaa93 | |||
| 6ba1be457f | |||
| f170d654d6 | |||
| ff4da6b73e | |||
| d39951bf65 | |||
| 90a276c1c1 | |||
| f15e0a5bec | |||
| 2ac6fc1485 | |||
| 7701efa34f | |||
| ff25446fd4 | |||
| 40b66740e0 | |||
| af79d41cf6 | |||
| 6fad72c44f | |||
| a7ed8bc4fd | |||
| b18e6ec3d3 | |||
| 3d9748c48e | |||
| aaba1a8097 | |||
| 47966b0be3 | |||
| b1b6b95a07 | |||
| 55263a4d5b | |||
| d5632d371b | |||
| 43643ba423 | |||
| 80042aead7 | |||
| 024efc7690 | |||
| 54bf188c5c | |||
| 471bdab090 | |||
| 2628cb5c6a | |||
| f7f382a874 | |||
| c3119bb49a | |||
| b753a5c331 | |||
| eb073ce9dc | |||
| b2b5c41b86 | |||
| 422d93eb1f | |||
| 7be28a2c82 | |||
| fc948e7e24 | |||
| 33bef6b265 | |||
| 30832fc62b | |||
| 1713fb1324 | |||
| f216aba5e3 | |||
| d3e1142e2e | |||
| 334d52dcfc | |||
| 803ccca769 | |||
| ab83bf6f64 | |||
| 940ff42da2 | |||
| eaae64cc41 | |||
| d77b9f696d |
@@ -0,0 +1,3 @@
|
||||
# 欢迎使用 EasyPlugin !
|
||||
|
||||
这个项目刚刚创建,详细的Javadoc与开发指南还在补充,请给我一点时间~
|
||||
@@ -0,0 +1,9 @@
|
||||
# EasyPlugin Javadoc
|
||||
|
||||
基于 [Github Pages](https://pages.github.com/) 搭建,请访问 [JavaDoc](https://carmjos.github.io/EasyPlugin) 。
|
||||
|
||||
## 如何实现?
|
||||
|
||||
若您也想通过 [Github Actions](https://docs.github.com/en/actions/learn-github-actions)
|
||||
自动部署项目的Javadoc到 [Github Pages](https://pages.github.com/) ,
|
||||
可以参考我的文章 [《自动部署Javadoc到Github Pages》](https://pages.carm.cc/doc/javadoc-in-github.html) 。
|
||||
@@ -0,0 +1,2 @@
|
||||
#github: [ CarmJos ]
|
||||
custom: [ 'https://donate.carm.cc' ]
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: 问题提交
|
||||
about: 描述问题并提交,帮助我们对其进行检查与修复。
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### **问题简述**
|
||||
|
||||
用简短的话语描述一下大概问题。
|
||||
|
||||
### **问题来源**
|
||||
|
||||
描述一下通过哪些操作才发现的问题,如:
|
||||
1. 使用了 ...
|
||||
2. 输入了 ...
|
||||
3. 出现了报错 ...
|
||||
|
||||
### **预期结果**(可选)
|
||||
|
||||
如果问题不发生,应该是什么情况
|
||||
|
||||
### **问题截图/问题报错**
|
||||
|
||||
如果有报错或输出,请提供截图。
|
||||
|
||||
### **操作环境**
|
||||
|
||||
- 系统环境: `Windows 10` / `Ubuntu` / `...`
|
||||
- Java版本: `JDK11` / `OPENJDK8` / `JRE8` / `...`
|
||||
- 服务端版本: 请在后台输入 `version` 并复制相关输出。
|
||||
|
||||
|
||||
### **其他补充**
|
||||
|
||||
如有其他补充,可以在这里描述。
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: 功能需求
|
||||
about: 希望我们提供更多的功能。
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### **功能简述**
|
||||
简单的描述一下你想要的功能
|
||||
|
||||
### **需求来源**
|
||||
简单的描述一下为什么需要这个功能。
|
||||
|
||||
### **功能参考**(可选)
|
||||
如果有相关功能的参考,如文本、截图,请提供给我们。
|
||||
|
||||
### **附加内容**
|
||||
如果有什么小细节需要重点注意,请在这里告诉我们。
|
||||
@@ -0,0 +1,98 @@
|
||||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||
|
||||
name: Project Deployment
|
||||
|
||||
on:
|
||||
# 支持手动触发构建
|
||||
workflow_dispatch:
|
||||
release:
|
||||
# 创建release的时候触发
|
||||
types: [ published ]
|
||||
|
||||
jobs:
|
||||
maven-deploy:
|
||||
|
||||
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
|
||||
server-id: github
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_TOKEN
|
||||
|
||||
- name: "Maven Deploy"
|
||||
run: mvn -B deploy --file pom.xml -DskipTests
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ github.repository_owner }}
|
||||
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
|
||||
|
||||
javadoc-deploy:
|
||||
|
||||
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:aggregate --file pom.xml -DskipTests
|
||||
|
||||
- name: "Copy Javadoc"
|
||||
run: |
|
||||
rm -rf docs
|
||||
mkdir -vp docs
|
||||
cp -vrf target/site/apidocs/* docs/
|
||||
cp -vrf .documentation/javadoc/JAVADOC-README.md docs/README.md
|
||||
|
||||
- name: "Generate Sitemap"
|
||||
id: sitemap
|
||||
uses: cicirello/generate-sitemap@v1
|
||||
with:
|
||||
base-url-path: https://carmjos.github.io/EasyPlugin
|
||||
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 'CarmJos'
|
||||
git config --global user.email 'carm@carm.cc'
|
||||
|
||||
- name: Commit documentation changes
|
||||
run: |
|
||||
cd docs
|
||||
git init
|
||||
git remote add origin git@github.com:CarmJos/EasyPlugin.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
|
||||
@@ -0,0 +1,31 @@
|
||||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||
|
||||
name: Project Build & Tests
|
||||
|
||||
on:
|
||||
# 支持手动触发构建
|
||||
workflow_dispatch:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: "Set up JDK"
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
cache: maven
|
||||
java-version: '11'
|
||||
distribution: 'adopt'
|
||||
server-id: github
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_TOKEN
|
||||
- name: "Package"
|
||||
run: mvn -B package --file pom.xml -Dmaven.javadoc.skip=true
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ github.repository_owner }}
|
||||
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
@@ -0,0 +1,4 @@
|
||||
/.idea/
|
||||
/target/
|
||||
/*/target/
|
||||
**.iml
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Carm
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,27 +1,174 @@
|
||||
# EasyPlugin Repository
|
||||
|
||||
采用github的repo分支进行依赖,随项目发布而自动更新。
|
||||
|
||||
其他依赖方式见主页介绍。
|
||||
|
||||
## 依赖方式
|
||||
|
||||
### Maven
|
||||
|
||||
```xml
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>EasyPlugin</id>
|
||||
<name>GitHub Branch Repository</name>
|
||||
<url>https://github.com/CarmJos/EasyPlugin/blob/repo/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
```text
|
||||
______ ____ __ _
|
||||
/ ____/___ ________ __ / __ \/ /_ ______ _(_)___
|
||||
/ __/ / __ `/ ___/ / / / / /_/ / / / / / __ `/ / __ \
|
||||
/ /___/ /_/ (__ ) /_/ / / ____/ / /_/ / /_/ / / / / /
|
||||
/_____/\__,_/____/\__, / /_/ /_/\__,_/\__, /_/_/ /_/
|
||||
/____/ /____/
|
||||
```
|
||||
|
||||
### Gradle
|
||||
# EasyPlugin
|
||||
|
||||
[](https://github.com/CarmJos/EasyPlugin/releases)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://github.com/CarmJos/EasyPlugin/actions/workflows/maven.yml)
|
||||
[](https://www.codefactor.io/repository/github/carmjos/EasyPlugin)
|
||||

|
||||

|
||||
|
||||
轻松(做)插件,旨在于方便快捷的使用Bukkit实现MC中的一些功能。
|
||||
|
||||
## 优势
|
||||
|
||||
- 轻便独立的功能模块,按需使用,避免大量打包!
|
||||
- 详细的Javadoc与使用文档,轻松上手,方便使用!
|
||||
- 持续的更新与优化,需求不止,更新不止!
|
||||
- 如需新功能支持,请通过 [Issues](https://github.com/CarmJos/EasyPlugin/issues) 提交功能需求。
|
||||
|
||||
## 内容
|
||||
|
||||
项目初创不久,加 * 的仍在开发更新中...
|
||||
|
||||
### 集合部分 (`/collection`)
|
||||
|
||||
- All [`easyplugin-all`](collection/all)
|
||||
- Common [`easyplugin-common`](collection/common)
|
||||
|
||||
### 主要部分 (`/base`)
|
||||
|
||||
- Main [`easyplugin-main`](base/main)
|
||||
- Command [`easyplugin-command`](base/command)
|
||||
- ~~Messages*~~ (已独立项目到 [**EasyMessages**](https://github.com/CarmJos/EasyMessages))
|
||||
- ~~Configuration~~ (已独立项目到 [**MineConfiguration**](https://github.com/CarmJos/MineConfiguration))
|
||||
- ~~Database~~ (已独立项目到 [**EasySQL**](https://github.com/CarmJos/EasySQL))
|
||||
- GUI [`easyplugin-gui`](base/main)
|
||||
|
||||
### 附属部分 (`/extension`)
|
||||
|
||||
- [PlaceholderAPI](https://www.spigotmc.org/resources/6245/)* [`easyplugin-placeholderapi`](extension/papi)
|
||||
- [Vault](https://github.com/MilkBowl/VaultAPI)* [`easyplugin-vault`](extension/vault)
|
||||
|
||||
## 开发
|
||||
|
||||
详细开发介绍请 [点击这里](.documentation/README.md) , JavaDoc(最新Release) 请 [点击这里](https://carmjos.github.io/EasyPlugin) 。
|
||||
|
||||
### 示例代码
|
||||
|
||||
您可以 [点击这里](https://github.com/CarmJos/UltraDepository) 查看实例项目演示,更多演示详见 [开发介绍](.documentation/README.md) 。
|
||||
|
||||
### 依赖方式
|
||||
|
||||
<details>
|
||||
<summary>展开查看 Maven 依赖方式</summary>
|
||||
|
||||
```xml
|
||||
|
||||
<project>
|
||||
<repositories>
|
||||
|
||||
<repository>
|
||||
<!--采用github依赖库,安全稳定,但需要配置 (推荐)-->
|
||||
<id>EasyPlugin</id>
|
||||
<name>GitHub Packages</name>
|
||||
<url>https://maven.pkg.github.com/CarmJos/EasyPlugin</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<!--采用我的私人依赖库,简单方便,但可能因为变故而无法使用-->
|
||||
<id>carm-repo</id>
|
||||
<name>Carm's Repo</name>
|
||||
<url>https://repo.carm.cc/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!--大全集版本,包含项目内所有模块-->
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-all</artifactId>
|
||||
<version>[LATEST RELEASE]</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!--常用接口集,包含除附属插件模块外的所有模块-->
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-common</artifactId>
|
||||
<version>[LATEST RELEASE]</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!--插件主要接口模块,包含方便的插件入口类与相关工具类-->
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-main</artifactId>
|
||||
<version>[LATEST RELEASE]</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 其他模块自行选择,详见 “内容”-->
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>展开查看 Gradle 依赖方式</summary>
|
||||
|
||||
```groovy
|
||||
repositories {
|
||||
maven { url 'https://github.com/CarmJos/EasyPlugin/blob/repo/' }
|
||||
// 采用github依赖库,安全稳定,但需要配置 (推荐)
|
||||
maven { url 'https://maven.pkg.github.com/CarmJos/EasyPlugin' }
|
||||
|
||||
// 采用我的私人依赖库,简单方便,但可能因为变故而无法使用
|
||||
maven { url 'https://repo.carm.cc/repository/maven-public/' }
|
||||
}
|
||||
```
|
||||
|
||||
dependencies {
|
||||
|
||||
//大全集版本,包含项目内所有模块
|
||||
api "cc.carm.lib:easyplugin-all:[LATEST RELEASE]"
|
||||
|
||||
//常用接口集,包含除附属插件模块外的所有模块
|
||||
api "cc.carm.lib:easyplugin-common:[LATEST RELEASE]"
|
||||
|
||||
//插件主要接口模块,包含方便的插件入口类与相关工具类
|
||||
api "cc.carm.lib:easyplugin-main:[LATEST RELEASE]"
|
||||
|
||||
// 其他模块自行选择,详见 “内容”
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## 支持与捐赠
|
||||
|
||||
若您觉得本插件做的不错,您可以通过捐赠支持我!
|
||||
|
||||
感谢您对开源项目的支持!
|
||||
|
||||
<img height=25% width=25% src="https://raw.githubusercontent.com/CarmJos/CarmJos/main/img/donate-code.jpg" alt=""/>
|
||||
|
||||
## 开源协议
|
||||
|
||||
本项目源码采用 [The MIT License](https://opensource.org/licenses/MIT) 开源协议。
|
||||
<details>
|
||||
<summary>关于 MIT 协议</summary>
|
||||
|
||||
> MIT 协议可能是几大开源协议中最宽松的一个,核心条款是:
|
||||
>
|
||||
> 该软件及其相关文档对所有人免费,可以任意处置,包括使用,复制,修改,合并,发表,分发,再授权,或者销售。唯一的限制是,软件中必须包含上述版 权和许可提示。
|
||||
>
|
||||
> 这意味着:
|
||||
> - 你可以自由使用,复制,修改,可以用于自己的项目。
|
||||
> - 可以免费分发或用来盈利。
|
||||
> - 唯一的限制是必须包含许可声明。
|
||||
>
|
||||
> MIT 协议是所有开源许可中最宽松的一个,除了必须包含许可声明外,再无任何限制。
|
||||
>
|
||||
> *以上文字来自 [五种开源协议GPL,LGPL,BSD,MIT,Apache](https://www.oschina.net/question/54100_9455) 。*
|
||||
</details>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.4.1</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>easyplugin-command</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,136 @@
|
||||
|
||||
package cc.carm.lib.easyplugin.command;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class CommandHandler implements TabExecutor, NamedExecutor {
|
||||
|
||||
protected final @NotNull JavaPlugin plugin;
|
||||
protected final @NotNull String cmd;
|
||||
|
||||
protected final @NotNull Map<String, SubCommand> registeredCommands = new HashMap<>();
|
||||
protected final @NotNull Map<String, CommandHandler> registeredHandlers = new HashMap<>();
|
||||
|
||||
public CommandHandler(@NotNull JavaPlugin plugin) {
|
||||
this(plugin, plugin.getName());
|
||||
}
|
||||
|
||||
public CommandHandler(@NotNull JavaPlugin plugin, @NotNull String cmd) {
|
||||
this.plugin = plugin;
|
||||
this.cmd = cmd;
|
||||
}
|
||||
|
||||
public abstract void noArgs(CommandSender sender);
|
||||
|
||||
public abstract void unknownCommand(CommandSender sender, String[] args);
|
||||
|
||||
public abstract void noPermission(CommandSender sender);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.cmd;
|
||||
}
|
||||
|
||||
public void registerSubCommand(SubCommand command) {
|
||||
for (String alias : command.getAliases()) {
|
||||
if (this.registeredCommands.containsKey(alias)) {
|
||||
this.plugin.getLogger().warning("Conflicting command aliases '" + alias + "' for '" + command.getName() + "', overwriting.");
|
||||
}
|
||||
this.registeredCommands.put(alias, command);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerHandler(CommandHandler handler) {
|
||||
for (String alias : handler.getAliases()) {
|
||||
if (this.registeredCommands.containsKey(alias)) {
|
||||
this.plugin.getLogger().warning("Conflicting command aliases '" + alias + "' for '" + handler.getName() + "', overwriting.");
|
||||
}
|
||||
this.registeredHandlers.put(alias, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
this.noArgs(sender);
|
||||
} else {
|
||||
String sub = args[0].toLowerCase();
|
||||
CommandHandler handler = this.registeredHandlers.get(sub);
|
||||
if (handler != null) {
|
||||
if (!handler.hasPermission(sender)) {
|
||||
this.noPermission(sender);
|
||||
} else {
|
||||
handler.onCommand(sender, command, label, this.shortenArgs(args));
|
||||
}
|
||||
} else {
|
||||
SubCommand subCommand = this.registeredCommands.get(sub);
|
||||
if (subCommand == null) {
|
||||
this.unknownCommand(sender, args);
|
||||
} else if (!subCommand.hasPermission(sender)) {
|
||||
this.noPermission(sender);
|
||||
} else {
|
||||
try {
|
||||
subCommand.execute(this.plugin, sender, this.shortenArgs(args));
|
||||
} catch (ArrayIndexOutOfBoundsException var9) {
|
||||
this.unknownCommand(sender, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
if (args.length == 0) return Collections.emptyList();
|
||||
|
||||
String input = args[0].toLowerCase();
|
||||
if (args.length == 1) {
|
||||
return getExecutors().stream()
|
||||
.filter(e -> e.hasPermission(sender))
|
||||
.map(NamedExecutor::getName)
|
||||
.filter(s -> StringUtil.startsWithIgnoreCase(s, input))
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
|
||||
CommandHandler handler = this.registeredHandlers.get(input);
|
||||
if (handler != null && handler.hasPermission(sender)) {
|
||||
return handler.onTabComplete(sender, command, alias, this.shortenArgs(args));
|
||||
}
|
||||
|
||||
SubCommand subCommand = this.registeredCommands.get(input);
|
||||
if (subCommand != null && subCommand.hasPermission(sender)) {
|
||||
return subCommand.tabComplete(this.plugin, sender, this.shortenArgs(args));
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<NamedExecutor> getExecutors() {
|
||||
Set<NamedExecutor> executors = new HashSet<>();
|
||||
executors.addAll(this.registeredHandlers.values());
|
||||
executors.addAll(this.registeredCommands.values());
|
||||
List<NamedExecutor> sortedExecutors = new ArrayList<>(executors);
|
||||
sortedExecutors.sort(Comparator.comparing(NamedExecutor::getName));
|
||||
return sortedExecutors;
|
||||
}
|
||||
|
||||
protected String[] shortenArgs(String[] args) {
|
||||
if (args.length == 0) {
|
||||
return args;
|
||||
} else {
|
||||
List<String> argList = new ArrayList<>(Arrays.asList(args).subList(1, args.length));
|
||||
return argList.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cc.carm.lib.easyplugin.command;
|
||||
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public interface NamedExecutor {
|
||||
|
||||
String getName();
|
||||
|
||||
default List<String> getAliases() {
|
||||
return Collections.singletonList(getName());
|
||||
}
|
||||
|
||||
default boolean hasPermission(Permissible permissible) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package cc.carm.lib.easyplugin.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SimpleCompleter {
|
||||
|
||||
public static @NotNull List<String> objects(@NotNull String input, List<?> objects) {
|
||||
return objects(input, objects.size(), objects);
|
||||
}
|
||||
|
||||
public static @NotNull List<String> objects(@NotNull String input, int limit, List<?> objects) {
|
||||
return objects.stream().filter(Objects::nonNull).map(Object::toString)
|
||||
.filter(s -> StringUtil.startsWithIgnoreCase(s, input))
|
||||
.limit(Math.min(0, limit)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static @NotNull List<String> text(@NotNull String input, String... texts) {
|
||||
return text(input, texts.length, texts);
|
||||
}
|
||||
|
||||
public static @NotNull List<String> text(@NotNull String input, int limit, String... texts) {
|
||||
return text(input, limit, Arrays.asList(texts));
|
||||
}
|
||||
|
||||
public static @NotNull List<String> text(@NotNull String input, List<String> texts) {
|
||||
return text(input, texts.size(), texts);
|
||||
}
|
||||
|
||||
public static @NotNull List<String> text(@NotNull String input, int limit, List<String> texts) {
|
||||
return objects(input, limit, texts);
|
||||
}
|
||||
|
||||
public static @NotNull List<String> onlinePlayers(@NotNull String input) {
|
||||
return onlinePlayers(input, 10);
|
||||
}
|
||||
|
||||
public static @NotNull List<String> onlinePlayers(@NotNull String input, int limit) {
|
||||
return text(input, limit, Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public static @NotNull List<String> allPlayers(@NotNull String input) {
|
||||
return allPlayers(input, 10);
|
||||
}
|
||||
|
||||
public static @NotNull List<String> allPlayers(@NotNull String input, int limit) {
|
||||
return text(input, limit, Arrays.stream(Bukkit.getOfflinePlayers()).map(OfflinePlayer::getName).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public static @NotNull List<String> worlds(@NotNull String input) {
|
||||
return worlds(input, 10);
|
||||
}
|
||||
|
||||
public static @NotNull List<String> worlds(@NotNull String input, int limit) {
|
||||
return text(input, limit, Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public static @NotNull List<String> materials(@NotNull String input) {
|
||||
return materials(input, 10);
|
||||
}
|
||||
|
||||
public static @NotNull List<String> materials(@NotNull String input, int limit) {
|
||||
return text(input, limit, Arrays.stream(Material.values()).map(Enum::name).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public static @NotNull List<String> effects(@NotNull String input) {
|
||||
return effects(input, 10);
|
||||
}
|
||||
|
||||
public static @NotNull List<String> effects(@NotNull String input, int limit) {
|
||||
return text(input, limit, Arrays.stream(PotionEffectType.values()).map(PotionEffectType::getName).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cc.carm.lib.easyplugin.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public abstract class SubCommand implements NamedExecutor {
|
||||
private final String name;
|
||||
|
||||
public SubCommand(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public abstract Void execute(JavaPlugin plugin, CommandSender sender, String[] args);
|
||||
|
||||
public List<String> tabComplete(JavaPlugin plugin, CommandSender sender, String[] args) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.5.14</version>
|
||||
<version>1.4.1</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -65,7 +65,22 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-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-source-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,211 @@
|
||||
package cc.carm.lib.easyplugin.gui;
|
||||
|
||||
import cc.carm.lib.easyplugin.utils.ColorParser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class GUI {
|
||||
|
||||
private static JavaPlugin plugin;
|
||||
private static final HashMap<UUID, GUI> openedGUIs = new HashMap<>();
|
||||
|
||||
public static void initialize(JavaPlugin plugin) {
|
||||
GUI.plugin = plugin;
|
||||
}
|
||||
|
||||
public static JavaPlugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public static HashMap<UUID, GUI> getOpenedGUIs() {
|
||||
return openedGUIs;
|
||||
}
|
||||
|
||||
protected GUIType type;
|
||||
protected String name;
|
||||
public HashMap<Integer, GUIItem> items;
|
||||
public Inventory inv;
|
||||
|
||||
/**
|
||||
* 当玩家点击目标GUI时是否取消
|
||||
*/
|
||||
boolean cancelOnTarget = true;
|
||||
|
||||
/**
|
||||
* 当玩家点击自己背包时是否取消
|
||||
*/
|
||||
boolean cancelOnSelf = true;
|
||||
|
||||
/**
|
||||
* 当玩家点击界面外时是否取消
|
||||
*/
|
||||
boolean cancelOnOuter = true;
|
||||
|
||||
Map<String, Object> flags;
|
||||
|
||||
GUIListener listener;
|
||||
|
||||
public GUI(GUIType type, String name) {
|
||||
this.type = type;
|
||||
this.name = ColorParser.parse(name);
|
||||
this.items = new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
public HashMap<@NotNull Integer, @NotNull GUIItem> getItems() {
|
||||
return new HashMap<>(items);
|
||||
}
|
||||
|
||||
public final void setItem(int index, @Nullable GUIItem item) {
|
||||
if (item == null) {
|
||||
this.items.remove(index);
|
||||
} else {
|
||||
this.items.put(index, item);
|
||||
}
|
||||
}
|
||||
|
||||
public void setItem(GUIItem item, int... index) {
|
||||
for (int i : index) {
|
||||
setItem(i, item);
|
||||
}
|
||||
}
|
||||
|
||||
public GUIItem getItem(int index) {
|
||||
return this.items.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新玩家箱子的视图
|
||||
*/
|
||||
public void updateView() {
|
||||
if (this.inv != null) {
|
||||
List<HumanEntity> viewers = this.inv.getViewers();
|
||||
IntStream.range(0, this.inv.getSize()).forEach(index -> inv.setItem(index, new ItemStack(Material.AIR)));
|
||||
getItems().forEach((index, item) -> inv.setItem(index, item.getDisplay()));
|
||||
viewers.forEach(p -> ((Player) p).updateInventory());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否取消点击GUI内物品的事件
|
||||
* 如果不取消,玩家可以从GUI中拿取物品。
|
||||
*
|
||||
* @param b 是否取消
|
||||
*/
|
||||
public void setCancelOnTarget(boolean b) {
|
||||
this.cancelOnTarget = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否取消点击自己背包内物品的事件
|
||||
* 如果不取消,玩家可以从自己的背包中拿取物品。
|
||||
*
|
||||
* @param b 是否取消
|
||||
*/
|
||||
public void setCancelOnSelf(boolean b) {
|
||||
this.cancelOnSelf = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否取消点击GUI外的事件
|
||||
* 如果不取消,玩家可以把物品从GUI或背包中丢出去
|
||||
*
|
||||
* @param b 是否取消
|
||||
*/
|
||||
public void setCancelOnOuter(boolean b) {
|
||||
this.cancelOnOuter = b;
|
||||
}
|
||||
|
||||
public void addFlag(String flag, Object obj) {
|
||||
if (this.flags == null) this.flags = new HashMap<>();
|
||||
this.flags.put(flag, obj);
|
||||
}
|
||||
|
||||
public Object getFlag(String flag) {
|
||||
if (this.flags == null) return null;
|
||||
else
|
||||
return this.flags.get(flag);
|
||||
}
|
||||
|
||||
public void setFlag(String flag, Object obj) {
|
||||
if (this.flags == null) this.flags = new HashMap<>();
|
||||
this.flags.replace(flag, obj);
|
||||
}
|
||||
|
||||
public void removeFlag(String flag) {
|
||||
if (this.flags == null) this.flags = new HashMap<>();
|
||||
this.flags.remove(flag);
|
||||
}
|
||||
|
||||
public void rawClickListener(InventoryClickEvent event) {
|
||||
}
|
||||
|
||||
public void openGUI(Player player) {
|
||||
if (this.type == GUIType.CANCEL) { throw new IllegalStateException("被取消或不存在的GUI"); }
|
||||
|
||||
Inventory inv = Bukkit.createInventory(null, this.type.getSize(), this.name);
|
||||
IntStream.range(0, inv.getSize()).forEach(index -> inv.setItem(index, new ItemStack(Material.AIR)));
|
||||
getItems().forEach((index, item) -> inv.setItem(index, item.getDisplay()));
|
||||
|
||||
GUI previous = getOpenedGUI(player);
|
||||
if(previous != null){
|
||||
previous.listener.close(player);
|
||||
}
|
||||
|
||||
setOpenedGUI(player, this);
|
||||
|
||||
this.inv = inv;
|
||||
player.openInventory(inv);
|
||||
|
||||
if (listener == null) {
|
||||
Bukkit.getPluginManager().registerEvents(listener = new GUIListener(this), getPlugin());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拖动GUI内物品是执行的代码
|
||||
*
|
||||
* @param event InventoryDragEvent
|
||||
*/
|
||||
public void onDrag(InventoryDragEvent event) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭GUI时执行的代码
|
||||
*/
|
||||
public void onClose() {
|
||||
}
|
||||
|
||||
|
||||
public static void setOpenedGUI(Player player, GUI gui) {
|
||||
getOpenedGUIs().put(player.getUniqueId(), gui);
|
||||
}
|
||||
|
||||
public static boolean hasOpenedGUI(Player player) {
|
||||
return getOpenedGUIs().containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static GUI getOpenedGUI(Player player) {
|
||||
return getOpenedGUIs().get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static void removeOpenedGUI(Player player) {
|
||||
getOpenedGUIs().remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package cc.carm.lib.easyplugin.gui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class GUIItem {
|
||||
|
||||
ItemStack display;
|
||||
boolean actionActive = true;
|
||||
|
||||
public Set<GUIClickAction> actions = new HashSet<>();
|
||||
public Set<GUIClickAction> actionsIgnoreActive = new HashSet<>();
|
||||
|
||||
public GUIItem(ItemStack display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public final ItemStack getDisplay() {
|
||||
return this.display;
|
||||
}
|
||||
|
||||
public final void setDisplay(ItemStack display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public final boolean isActionActive() {
|
||||
return this.actionActive;
|
||||
}
|
||||
|
||||
public final void setActionActive(boolean b) {
|
||||
actionActive = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家点击GUI后执行的代码
|
||||
*
|
||||
* @param type 点击的类型
|
||||
*/
|
||||
public void onClick(ClickType type) {
|
||||
|
||||
}
|
||||
|
||||
public void addClickAction(GUIClickAction action) {
|
||||
actions.add(action);
|
||||
}
|
||||
|
||||
public void addActionIgnoreActive(GUIClickAction action) {
|
||||
actionsIgnoreActive.add(action);
|
||||
}
|
||||
|
||||
public void rawClickAction(InventoryClickEvent event) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家点击GUI后执行的代码
|
||||
*
|
||||
* @param player 点击GUI的玩家
|
||||
*/
|
||||
public void customAction(Player player) {
|
||||
|
||||
}
|
||||
|
||||
public abstract static class GUIClickAction {
|
||||
public abstract void run(ClickType type, Player player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package cc.carm.lib.easyplugin.gui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class GUIListener implements Listener {
|
||||
|
||||
GUI currentGUI;
|
||||
|
||||
public GUIListener(GUI gui) {
|
||||
this.currentGUI = gui;
|
||||
}
|
||||
|
||||
public GUI getCurrentGUI() {
|
||||
return currentGUI;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClickEvent(InventoryClickEvent event) {
|
||||
if (!(event.getWhoClicked() instanceof Player)) return;
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (!GUI.hasOpenedGUI(player)) return;
|
||||
if (GUI.getOpenedGUI(player) != getCurrentGUI()) return;
|
||||
|
||||
getCurrentGUI().rawClickListener(event);
|
||||
|
||||
if (event.getSlot() == -999 && getCurrentGUI().cancelOnOuter) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getClickedInventory() == null) return;
|
||||
|
||||
if (event.getClickedInventory().equals(getCurrentGUI().inv)) {
|
||||
|
||||
if (getCurrentGUI().cancelOnTarget) event.setCancelled(true);
|
||||
|
||||
if (event.getSlot() != -999) {
|
||||
GUIItem clickedItem = getCurrentGUI().getItem(event.getSlot());
|
||||
if (clickedItem != null) {
|
||||
if (clickedItem.isActionActive()) {
|
||||
clickedItem.onClick(event.getClick());
|
||||
clickedItem.rawClickAction(event);
|
||||
clickedItem.actions.forEach(action -> action.run(event.getClick(), player));
|
||||
}
|
||||
clickedItem.actionsIgnoreActive.forEach(action -> action.run(event.getClick(), player));
|
||||
}
|
||||
}
|
||||
|
||||
} else if (event.getClickedInventory().equals(player.getInventory()) && getCurrentGUI().cancelOnSelf) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDrag(InventoryDragEvent e) {
|
||||
if (!(e.getWhoClicked() instanceof Player)) return;
|
||||
if (e.getInventory().equals(getCurrentGUI().inv)
|
||||
|| e.getInventory().equals(e.getWhoClicked().getInventory())) {
|
||||
getCurrentGUI().onDrag(e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryCloseEvent(InventoryCloseEvent event) {
|
||||
if (!(event.getPlayer() instanceof Player)) return;
|
||||
if (!event.getInventory().equals(getCurrentGUI().inv)) return;
|
||||
|
||||
close((Player) event.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
protected void close(Player p){
|
||||
HandlerList.unregisterAll(this);
|
||||
getCurrentGUI().listener = null;
|
||||
GUI.removeOpenedGUI(p);
|
||||
getCurrentGUI().onClose();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeave(PlayerQuitEvent event) {
|
||||
GUI.removeOpenedGUI(event.getPlayer());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cc.carm.lib.easyplugin.gui;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public enum GUIType {
|
||||
|
||||
ONE_BY_NINE(1, 9),
|
||||
TWO_BY_NINE(2, 18),
|
||||
THREE_BY_NINE(3, 27),
|
||||
FOUR_BY_NINE(4, 36),
|
||||
FIVE_BY_NINE(5, 45),
|
||||
SIX_BY_NINE(6, 54),
|
||||
CANCEL(0, 0);
|
||||
|
||||
int lines;
|
||||
int size;
|
||||
|
||||
GUIType(int lines, int size) {
|
||||
this.lines = lines;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public int getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static GUIType getBySize(int size) {
|
||||
return Arrays.stream(values()).filter(type -> type.getSize() == size).findFirst().orElse(CANCEL);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static GUIType getByLines(int lines) {
|
||||
return Arrays.stream(values()).filter(type -> type.getLines() == lines).findFirst().orElse(CANCEL);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static GUIType getByName(String name) {
|
||||
return Arrays.stream(values()).filter(type -> type.name().equalsIgnoreCase(name)).findFirst().orElse(CANCEL);
|
||||
}
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package cc.carm.lib.easyplugin.gui.configuration;
|
||||
|
||||
import cc.carm.lib.easyplugin.gui.GUIItem;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class GUIActionConfiguration {
|
||||
|
||||
|
||||
@Nullable ClickType clickType;
|
||||
final @NotNull GUIActionType actionType;
|
||||
final @Nullable String actionContent;
|
||||
|
||||
public GUIActionConfiguration(@Nullable ClickType clickType,
|
||||
@NotNull GUIActionType actionType,
|
||||
@Nullable String actionContent) {
|
||||
this.clickType = clickType;
|
||||
this.actionType = actionType;
|
||||
this.actionContent = actionContent;
|
||||
}
|
||||
|
||||
public @Nullable ClickType getClickType() {
|
||||
return clickType;
|
||||
}
|
||||
|
||||
public @NotNull GUIActionType getActionType() {
|
||||
return actionType;
|
||||
}
|
||||
|
||||
public @Nullable String getActionContent() {
|
||||
return actionContent;
|
||||
}
|
||||
|
||||
public void checkAction(Player player, ClickType type) {
|
||||
if (getClickType() == null || getClickType() == type) executeAction(player);
|
||||
}
|
||||
|
||||
public void executeAction(Player targetPlayer) {
|
||||
getActionType().getExecutor().accept(targetPlayer, getActionContent());
|
||||
}
|
||||
|
||||
public GUIItem.GUIClickAction toClickAction() {
|
||||
return new GUIItem.GUIClickAction() {
|
||||
@Override
|
||||
public void run(ClickType type, Player player) {
|
||||
checkAction(player, type);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package cc.carm.lib.easyplugin.gui.configuration;
|
||||
|
||||
import cc.carm.lib.easyplugin.utils.MessageUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public enum GUIActionType {
|
||||
|
||||
/**
|
||||
* 以玩家聊天的形式执行
|
||||
* 若内容以 “/" 开头,则会以玩家身份执行命令。
|
||||
*/
|
||||
CHAT((player, string) -> {
|
||||
if (string == null) return;
|
||||
MessageUtils.setPlaceholders(player, Collections.singletonList(string)).forEach(player::chat);
|
||||
}),
|
||||
|
||||
/**
|
||||
* 以后台的形式执行指令
|
||||
* 指令内容不需要以“/”开头。
|
||||
*/
|
||||
CONSOLE((player, string) -> {
|
||||
if (string == null) return;
|
||||
MessageUtils.setPlaceholders(player, Collections.singletonList(string))
|
||||
.forEach(message -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), message));
|
||||
}),
|
||||
|
||||
/**
|
||||
* 向玩家发送消息。
|
||||
*/
|
||||
MESSAGE(MessageUtils::send),
|
||||
|
||||
/**
|
||||
* 向玩家发送声音。
|
||||
* 允许配置音量与音调
|
||||
* <ul>
|
||||
* <li>SOUND_NAME</li>
|
||||
* <li>SOUND_NAME:VOLUME</li>
|
||||
* <li>SOUND_NAME:VOLUME:PITCH</li>
|
||||
* </ul>
|
||||
*/
|
||||
SOUND((player, string) -> {
|
||||
if (string == null) return;
|
||||
try {
|
||||
String[] args = string.contains(":") ? string.split(":") : new String[]{string};
|
||||
Sound sound = Arrays.stream(Sound.values())
|
||||
.filter(s -> s.name().equals(args[0]))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
if (sound == null) return;
|
||||
float volume = args.length > 1 ? Float.parseFloat(args[1]) : 1F;
|
||||
float pitch = args.length > 2 ? Float.parseFloat(args[2]) : 1F;
|
||||
|
||||
player.playSound(player.getLocation(), sound, volume, pitch);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
* 为玩家关闭GUI。
|
||||
*/
|
||||
CLOSE((player, string) -> player.closeInventory());
|
||||
|
||||
BiConsumer<@NotNull Player, @Nullable String> executor;
|
||||
|
||||
|
||||
GUIActionType(BiConsumer<@NotNull Player, @Nullable String> executor) {
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
public BiConsumer<@NotNull Player, @Nullable String> getExecutor() {
|
||||
return executor;
|
||||
}
|
||||
|
||||
public static GUIActionType readActionType(String string) {
|
||||
return Arrays.stream(GUIActionType.values())
|
||||
.filter(action -> action.name().equalsIgnoreCase(string))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package cc.carm.lib.easyplugin.gui.configuration;
|
||||
|
||||
import cc.carm.lib.easyplugin.gui.GUI;
|
||||
import cc.carm.lib.easyplugin.gui.GUIType;
|
||||
import cc.carm.lib.easyplugin.utils.ColorParser;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUIConfiguration {
|
||||
|
||||
String title;
|
||||
int lines;
|
||||
|
||||
List<GUIItemConfiguration> guiItems;
|
||||
|
||||
public GUIConfiguration(String title, int lines, List<GUIItemConfiguration> guiItems) {
|
||||
this.title = title;
|
||||
this.lines = lines;
|
||||
this.guiItems = guiItems;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return ColorParser.parse(title);
|
||||
}
|
||||
|
||||
public int getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
public GUIType getGUIType() {
|
||||
return Optional.of(GUIType.getByLines(lines))
|
||||
.map(type -> type == GUIType.CANCEL ? GUIType.SIX_BY_NINE : type)
|
||||
.get();
|
||||
}
|
||||
|
||||
public List<GUIItemConfiguration> getGuiItems() {
|
||||
return guiItems;
|
||||
}
|
||||
|
||||
public void setupItems(Player player, GUI gui) {
|
||||
getGuiItems().forEach(itemConfiguration -> itemConfiguration.setupItems(player, gui));
|
||||
}
|
||||
|
||||
|
||||
public static GUIConfiguration readConfiguration(@Nullable ConfigurationSection section) {
|
||||
if (section == null) return new GUIConfiguration("name", 6, new ArrayList<>());
|
||||
|
||||
String title = section.getString("title", "");
|
||||
int lines = section.getInt("lines", 6);
|
||||
ConfigurationSection itemsSection = section.getConfigurationSection("items");
|
||||
if (itemsSection == null) return new GUIConfiguration(title, lines, new ArrayList<>());
|
||||
|
||||
return new GUIConfiguration(
|
||||
title, lines, itemsSection.getKeys(false).stream()
|
||||
.map(key -> GUIItemConfiguration.readFrom(itemsSection.getConfigurationSection(key)))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
public static ClickType readClickType(String type) {
|
||||
return Arrays.stream(ClickType.values())
|
||||
.filter(click -> click.name().equalsIgnoreCase(type))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package cc.carm.lib.easyplugin.gui.configuration;
|
||||
|
||||
import cc.carm.lib.easyplugin.gui.GUI;
|
||||
import cc.carm.lib.easyplugin.gui.GUIItem;
|
||||
import cc.carm.lib.easyplugin.utils.ItemStackFactory;
|
||||
import cc.carm.lib.easyplugin.utils.MessageUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class GUIItemConfiguration {
|
||||
|
||||
Material material;
|
||||
int data;
|
||||
String name;
|
||||
@NotNull List<String> lore;
|
||||
|
||||
@NotNull List<Integer> slots;
|
||||
@NotNull List<GUIActionConfiguration> actions;
|
||||
|
||||
public GUIItemConfiguration(Material material, int data,
|
||||
String name, @NotNull List<String> lore,
|
||||
@NotNull List<GUIActionConfiguration> actions,
|
||||
@NotNull List<Integer> slots) {
|
||||
this.material = material;
|
||||
this.data = data;
|
||||
this.name = name;
|
||||
this.lore = lore;
|
||||
this.slots = slots;
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
public void setupItems(Player player, GUI gui) {
|
||||
ItemStackFactory icon = new ItemStackFactory(this.material);
|
||||
icon.setDurability(this.data);
|
||||
if (this.name != null) icon.setDisplayName(this.name);
|
||||
icon.setLore(MessageUtils.setPlaceholders(player, this.lore));
|
||||
|
||||
GUIItem item = new GUIItem(icon.toItemStack());
|
||||
this.actions.stream().map(GUIActionConfiguration::toClickAction).forEach(item::addClickAction);
|
||||
this.slots.forEach(slot -> gui.setItem(slot, item));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GUIItemConfiguration readFrom(@Nullable ConfigurationSection itemSection) {
|
||||
if (itemSection == null) return null;
|
||||
Material material = Optional.ofNullable(Material.matchMaterial(itemSection.getString("material", "STONE"))).orElse(Material.STONE);
|
||||
int data = itemSection.getInt("data", 0);
|
||||
String name = itemSection.getString("name");
|
||||
List<String> lore = itemSection.getStringList("lore");
|
||||
|
||||
List<Integer> slots = itemSection.getIntegerList("slots");
|
||||
int slot = itemSection.getInt("slot", 0);
|
||||
|
||||
List<String> actionsString = itemSection.getStringList("actions");
|
||||
List<GUIActionConfiguration> actions = new ArrayList<>();
|
||||
for (String actionString : actionsString) {
|
||||
int prefixStart = actionString.indexOf("[");
|
||||
int prefixEnd = actionString.indexOf("]");
|
||||
if (prefixStart < 0 || prefixEnd < 0) continue;
|
||||
|
||||
String prefix = actionString.substring(prefixStart + 1, prefixEnd);
|
||||
ClickType clickType = null;
|
||||
GUIActionType actionType;
|
||||
if (prefix.contains(":")) {
|
||||
String[] args = prefix.split(":");
|
||||
clickType = GUIConfiguration.readClickType(args[0]);
|
||||
actionType = GUIActionType.readActionType(args[1]);
|
||||
} else {
|
||||
actionType = GUIActionType.readActionType(prefix);
|
||||
}
|
||||
|
||||
if (actionType == null) continue;
|
||||
actions.add(new GUIActionConfiguration(clickType, actionType, actionString.substring(prefixEnd + 1).trim()));
|
||||
}
|
||||
|
||||
return new GUIItemConfiguration(
|
||||
material, data, name, lore, actions,
|
||||
slots.size() > 0 ? slots : Collections.singletonList(slot)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package cc.carm.lib.easyplugin.gui.paged;
|
||||
|
||||
import cc.carm.lib.easyplugin.gui.GUIItem;
|
||||
import cc.carm.lib.easyplugin.gui.GUIType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class AutoPagedGUI extends CommonPagedGUI {
|
||||
|
||||
public static Function<Player, ItemStack> defaultPreviousPage = null;
|
||||
public static Function<Player, ItemStack> defaultNextPage = null;
|
||||
|
||||
ItemStack previousPageUI;
|
||||
ItemStack nextPageUI;
|
||||
int previousPageSlot = -1;
|
||||
int nextPageSlot = -1;
|
||||
|
||||
public AutoPagedGUI(GUIType type, String name, int[] range) {
|
||||
super(type, name, range);
|
||||
}
|
||||
|
||||
public AutoPagedGUI(GUIType type, String name, int a, int b) {
|
||||
super(type, name, a, b);
|
||||
}
|
||||
|
||||
public void setPreviousPageUI(ItemStack lastPageUI) {
|
||||
this.previousPageUI = lastPageUI;
|
||||
}
|
||||
|
||||
public void setNextPageUI(ItemStack nextPageUI) {
|
||||
this.nextPageUI = nextPageUI;
|
||||
}
|
||||
|
||||
public void setPreviousPageSlot(int slot) {
|
||||
this.previousPageSlot = slot;
|
||||
}
|
||||
|
||||
public void setNextPageSlot(int slot) {
|
||||
this.nextPageSlot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openGUI(Player user) {
|
||||
if (previousPageSlot >= 0) {
|
||||
if (hasPreviousPage()) {
|
||||
setItem(previousPageSlot, new GUIItem(
|
||||
previousPageUI == null ? getDefaultPreviousPage(user) : previousPageUI) {
|
||||
@Override
|
||||
public void onClick(ClickType type) {
|
||||
if (type == ClickType.RIGHT) {
|
||||
goFirstPage();
|
||||
} else {
|
||||
goPreviousPage();
|
||||
}
|
||||
openGUI(user);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
setItem(previousPageSlot, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (nextPageSlot >= 0) {
|
||||
if (hasNextPage()) {
|
||||
setItem(nextPageSlot, new GUIItem(
|
||||
nextPageUI == null ? getDefaultNextPage(user) : nextPageUI) {
|
||||
@Override
|
||||
public void onClick(ClickType type) {
|
||||
if (type == ClickType.RIGHT) {
|
||||
goLastPage();
|
||||
} else {
|
||||
goNextPage();
|
||||
}
|
||||
openGUI(user);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
setItem(nextPageSlot, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
super.openGUI(user);
|
||||
}
|
||||
|
||||
private static ItemStack getDefaultNextPage(Player player) {
|
||||
return defaultNextPage != null ? defaultNextPage.apply(player) : null;
|
||||
}
|
||||
|
||||
private static ItemStack getDefaultPreviousPage(Player player) {
|
||||
return defaultPreviousPage != null ? defaultPreviousPage.apply(player) : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package cc.carm.lib.easyplugin.gui.paged;
|
||||
|
||||
|
||||
import cc.carm.lib.easyplugin.gui.GUIItem;
|
||||
import cc.carm.lib.easyplugin.gui.GUIType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CommonPagedGUI extends PagedGUI {
|
||||
|
||||
private int[] range;
|
||||
|
||||
private CommonPagedGUI(GUIType type, String name) {
|
||||
super(type, name);
|
||||
}
|
||||
|
||||
public CommonPagedGUI(GUIType type, String Name, int a, int b) {
|
||||
this(type, Name, toRange(type, a, b));
|
||||
}
|
||||
|
||||
public CommonPagedGUI(GUIType type, String Name, int[] range) {
|
||||
super(type, Name);
|
||||
Arrays.sort(range);
|
||||
this.range = range;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
int[] matrix = new int[]{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
18, 19, 20, 21, 22, 23, 24, 25, 26,
|
||||
27, 28, 29, 30, 31, 32, 33, 34, 35,
|
||||
36, 37, 38, 39, 40, 41, 42, 43, 44,
|
||||
45, 46, 47, 48, 49, 50, 51, 52, 53
|
||||
}
|
||||
*/
|
||||
|
||||
private static int[] toRange(GUIType type, int a, int b) {
|
||||
if (a > b) {
|
||||
a = a ^ b;
|
||||
b = a ^ b;
|
||||
a = a ^ b;
|
||||
}
|
||||
|
||||
int lineA = getLine(a);
|
||||
int columnA = getColumn(a);
|
||||
int lineB = getLine(b);
|
||||
int columnB = getColumn(b);
|
||||
|
||||
if (lineB > type.getLines())
|
||||
throw new IndexOutOfBoundsException("页面内容范围超过了GUI的大小");
|
||||
|
||||
int[] range = new int[(lineB - lineA + 1) * (columnB - columnA + 1)];
|
||||
|
||||
for (int i = 0, l = 0; i < type.getSize(); i++) {
|
||||
int li = getLine(i);
|
||||
int ci = getColumn(i);
|
||||
if (li >= lineA && li <= lineB && ci >= columnA && ci <= columnB) {
|
||||
range[l] = i;
|
||||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
private static int getLine(int i) {
|
||||
return i / 9 + 1;
|
||||
}
|
||||
|
||||
private static int getColumn(int i) {
|
||||
return i % 9 + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPreviousPage() {
|
||||
return page > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNextPage() {
|
||||
return page < getLastPageNumber();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 前往第一页
|
||||
*/
|
||||
public void goFirstPage() {
|
||||
if (hasPreviousPage())
|
||||
this.page = 1;
|
||||
else
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 前往最后一页
|
||||
*/
|
||||
public void goLastPage() {
|
||||
if (hasNextPage())
|
||||
this.page = getLastPageNumber();
|
||||
else
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 得到最后一页的页码
|
||||
*
|
||||
* @return 最后一页的页码
|
||||
*/
|
||||
public int getLastPageNumber() {
|
||||
return (this.container.size() / range.length) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到第一页的页码
|
||||
*
|
||||
* @return 第一页页码(默认为1)
|
||||
*/
|
||||
public int getFirstPageNumber() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void openGUI(Player player) {
|
||||
if (container.isEmpty()) {
|
||||
super.openGUI(player);
|
||||
return;
|
||||
}
|
||||
List<GUIItem> list = new ArrayList<>();
|
||||
int start = (page - 1) * range.length;
|
||||
for (int i = start; i < start + range.length; i++) {
|
||||
if (i < container.size()) {
|
||||
list.add(container.get(i));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
Arrays.stream(range).forEach(index -> setItem(index, null));
|
||||
for (int index : range) {
|
||||
if (i < list.size()) {
|
||||
setItem(index, list.get(i));
|
||||
i++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.openGUI(player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package cc.carm.lib.easyplugin.gui.paged;
|
||||
|
||||
|
||||
import cc.carm.lib.easyplugin.gui.GUI;
|
||||
import cc.carm.lib.easyplugin.gui.GUIItem;
|
||||
import cc.carm.lib.easyplugin.gui.GUIType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class PagedGUI extends GUI {
|
||||
|
||||
List<GUIItem> container = new ArrayList<>();
|
||||
public int page = 1;
|
||||
|
||||
public PagedGUI(GUIType type, String name) {
|
||||
super(type, name);
|
||||
}
|
||||
|
||||
public int addItem(GUIItem i) {
|
||||
container.add(i);
|
||||
return container.size() - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从GUI中移除一个物品
|
||||
*
|
||||
* @param item 物品
|
||||
*/
|
||||
public void removeItem(GUIItem item) {
|
||||
container.remove(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从GUI中移除一个物品
|
||||
*
|
||||
* @param slot 物品格子数
|
||||
*/
|
||||
public void removeItem(int slot) {
|
||||
container.remove(slot);
|
||||
}
|
||||
|
||||
public List<GUIItem> getItemsContainer() {
|
||||
return new ArrayList<>(container);
|
||||
}
|
||||
|
||||
/**
|
||||
* 前往上一页
|
||||
*/
|
||||
public void goPreviousPage() {
|
||||
if (hasPreviousPage())
|
||||
page--;
|
||||
else
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 前往下一页
|
||||
*/
|
||||
public void goNextPage() {
|
||||
if (hasNextPage())
|
||||
page++;
|
||||
else
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return 是否有上一页
|
||||
*/
|
||||
public abstract boolean hasPreviousPage();
|
||||
|
||||
/**
|
||||
* @return 是否有下一页
|
||||
*/
|
||||
public abstract boolean hasNextPage();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
|
||||
import cc.carm.lib.easyplugin.gui.configuration.GUIActionType;
|
||||
import cc.carm.lib.easyplugin.gui.configuration.GUIConfiguration;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ActionReadTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
List<String> actions = Arrays.asList(
|
||||
"[CHAT] 123123",
|
||||
"[SHIFT_LEFT:CHAT] /test qwq",
|
||||
"[CONSOLE] say hello",
|
||||
"[CLOSE]"
|
||||
);
|
||||
|
||||
for (String actionString : actions) {
|
||||
int prefixStart = actionString.indexOf("[");
|
||||
int prefixEnd = actionString.indexOf("]");
|
||||
if (prefixStart < 0 || prefixEnd < 0) continue;
|
||||
|
||||
String prefix = actionString.substring(prefixStart + 1, prefixEnd);
|
||||
ClickType clickType = null;
|
||||
GUIActionType actionType;
|
||||
if (prefix.contains(":")) {
|
||||
String[] args = prefix.split(":");
|
||||
clickType = GUIConfiguration.readClickType(args[0]);
|
||||
actionType = GUIActionType.readActionType(args[1]);
|
||||
} else {
|
||||
actionType = GUIActionType.readActionType(prefix);
|
||||
}
|
||||
|
||||
if (actionType == null) {
|
||||
System.out.println("# " + actionString);
|
||||
System.out.println("- actionType is Null");
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.println("# " + actionType.name() + " " + (clickType == null ? "" : clickType.name()));
|
||||
System.out.println("- " + actionString.substring(prefixEnd + 1).trim());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.5.14</version>
|
||||
<version>1.4.1</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -22,7 +22,7 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EasyPlugin-Main</name>
|
||||
<description>轻松插件主要接口模块,包含便捷的插件入口类与相关工具类。</description>
|
||||
<description>轻松插件主要接口模块,包含方便的插件入口类与相关工具类。</description>
|
||||
<url>https://github.com/CarmJos/EasyPlugin</url>
|
||||
|
||||
<developers>
|
||||
@@ -53,16 +53,10 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>easyplugin-utils</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -74,6 +68,18 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-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-source-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package cc.carm.lib.easyplugin;
|
||||
|
||||
import cc.carm.lib.easyplugin.i18n.EasyPluginMessageProvider;
|
||||
import cc.carm.lib.easyplugin.utils.JarResourceUtils;
|
||||
import cc.carm.lib.easyplugin.utils.SchedulerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class EasyPlugin extends JavaPlugin {
|
||||
|
||||
protected EasyPluginMessageProvider messageProvider;
|
||||
|
||||
public EasyPlugin() {
|
||||
this(EasyPluginMessageProvider.ZH_CN);
|
||||
}
|
||||
|
||||
public EasyPlugin(EasyPluginMessageProvider messageProvider) {
|
||||
this.messageProvider = messageProvider;
|
||||
}
|
||||
|
||||
private SchedulerUtils scheduler;
|
||||
private boolean initialized = false;
|
||||
|
||||
@Override
|
||||
public final void onLoad() {
|
||||
scheduler = new SchedulerUtils(this);
|
||||
if (!hasOverride("load")) return;
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
log(messageProvider.loading(this));
|
||||
load();
|
||||
log(messageProvider.loaded(this, startTime));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onEnable() {
|
||||
outputInfo();
|
||||
|
||||
log(messageProvider.enabling(this));
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
if (!(this.initialized = initialize())) {
|
||||
setEnabled(false);
|
||||
log(messageProvider.enableFailure(this, startTime));
|
||||
return;
|
||||
}
|
||||
|
||||
log(messageProvider.enableSuccess(this, startTime));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void onDisable() {
|
||||
if (!hasOverride("shutdown") || !isInitialized()) return;
|
||||
outputInfo();
|
||||
|
||||
log(messageProvider.disabling(this));
|
||||
long startTime = System.currentTimeMillis();
|
||||
shutdown();
|
||||
log(messageProvider.disabled(this, startTime));
|
||||
}
|
||||
|
||||
protected void load() {
|
||||
}
|
||||
|
||||
protected abstract boolean initialize();
|
||||
|
||||
protected void shutdown() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写以展示插件的相关信息,如插件横幅、下载地址等。
|
||||
*/
|
||||
public void outputInfo() {
|
||||
Optional.ofNullable(JarResourceUtils.readResource(this.getResource("PLUGIN_INFO"))).ifPresent(this::log);
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
public boolean isDebugging() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public SchedulerUtils getScheduler() {
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
public void registerListener(@NotNull Listener... listeners) {
|
||||
Arrays.stream(listeners).forEach(listener -> Bukkit.getPluginManager().registerEvents(listener, this));
|
||||
}
|
||||
|
||||
public void registerCommand(String commandName,
|
||||
@NotNull CommandExecutor executor) {
|
||||
registerCommand(commandName, executor, executor instanceof TabCompleter ? (TabCompleter) executor : null);
|
||||
}
|
||||
|
||||
public void registerCommand(String commandName,
|
||||
@NotNull CommandExecutor executor,
|
||||
@Nullable TabCompleter tabCompleter) {
|
||||
PluginCommand command = Bukkit.getPluginCommand(commandName);
|
||||
if (command == null) return;
|
||||
command.setExecutor(executor);
|
||||
if (tabCompleter != null) command.setTabCompleter(tabCompleter);
|
||||
}
|
||||
|
||||
public void print(@Nullable String prefix, @Nullable String... messages) {
|
||||
messageProvider.print(this, prefix, messages);
|
||||
}
|
||||
|
||||
public void log(@Nullable String... messages) {
|
||||
print(null, messages);
|
||||
}
|
||||
|
||||
public void error(String... messages) {
|
||||
print("&c[ERROR] &r", messages);
|
||||
}
|
||||
|
||||
public void debug(@Nullable String... messages) {
|
||||
if (isDebugging()) print("&8[DEBUG] &r", messages);
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
private boolean hasOverride(String methodName) {
|
||||
Map<Method, Method> methodMap = new HashMap<>();
|
||||
Arrays.stream(EasyPlugin.class.getDeclaredMethods())
|
||||
.filter(method -> method.getName().equals(methodName))
|
||||
.forEach(method -> Arrays.stream(getClass().getDeclaredMethods())
|
||||
.filter(extend -> extend.getName().equals(methodName))
|
||||
.filter(extend -> extend.getReturnType().equals(method.getReturnType()))
|
||||
.filter(extend -> extend.getParameterTypes().length == method.getParameterTypes().length)
|
||||
.findFirst().ifPresent(extendMethod -> methodMap.put(method, extendMethod))
|
||||
);
|
||||
return !methodMap.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package cc.carm.lib.easyplugin.i18n;
|
||||
|
||||
import cc.carm.lib.easyplugin.utils.ColorParser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public interface EasyPluginMessageProvider {
|
||||
|
||||
EasyPluginMessageProvider ZH_CN = new zh_CN();
|
||||
EasyPluginMessageProvider EN_US = new en_US();
|
||||
|
||||
String loading(Plugin plugin);
|
||||
|
||||
String loaded(Plugin plugin, long startMillis);
|
||||
|
||||
String enabling(Plugin plugin);
|
||||
|
||||
String enableSuccess(Plugin plugin, long startMillis);
|
||||
|
||||
String enableFailure(Plugin plugin, long startMillis);
|
||||
|
||||
String disabling(Plugin plugin);
|
||||
|
||||
String disabled(Plugin plugin, long startMillis);
|
||||
|
||||
default void print(@NotNull Plugin plugin, @Nullable String prefix, @Nullable String... messages) {
|
||||
Arrays.stream(messages)
|
||||
.map(message -> "[" + plugin.getName() + "] " + (prefix == null ? "" : prefix) + message)
|
||||
.map(ColorParser::parse)
|
||||
.forEach(message -> Bukkit.getConsoleSender().sendMessage(message));
|
||||
}
|
||||
|
||||
class zh_CN implements EasyPluginMessageProvider {
|
||||
|
||||
@Override
|
||||
public String loading(Plugin plugin) {
|
||||
return "&f" + plugin.getName() + " " + plugin.getDescription().getVersion() + " 开始加载...";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String loaded(Plugin plugin, long startMillis) {
|
||||
return "&f加载完成 ,共耗时 " + (System.currentTimeMillis() - startMillis) + " ms 。";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String enabling(Plugin plugin) {
|
||||
return "&f" + plugin.getName() + " " + plugin.getDescription().getVersion() + " 开始启动...";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String enableSuccess(Plugin plugin, long startMillis) {
|
||||
return "&a启用完成! &f共耗时 " + (System.currentTimeMillis() - startMillis) + " ms 。";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String enableFailure(Plugin plugin, long startMillis) {
|
||||
return "&c启用失败! &f已耗时 " + (System.currentTimeMillis() - startMillis) + " ms 。";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String disabling(Plugin plugin) {
|
||||
return "&f" + plugin.getName() + " " + plugin.getDescription().getVersion() + " 开始卸载...";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String disabled(Plugin plugin, long startMillis) {
|
||||
return "&f卸载完成! 共耗时 " + (System.currentTimeMillis() - startMillis) + " ms 。";
|
||||
}
|
||||
}
|
||||
|
||||
class en_US implements EasyPluginMessageProvider {
|
||||
|
||||
@Override
|
||||
public String loading(Plugin plugin) {
|
||||
return "&f" + plugin.getName() + " " + plugin.getDescription().getVersion() + " loading...";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String loaded(Plugin plugin, long startMillis) {
|
||||
return "&fLoaded after " + (System.currentTimeMillis() - startMillis) + " ms.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String enabling(Plugin plugin) {
|
||||
return "&f" + plugin.getName() + " " + plugin.getDescription().getVersion() + " enabling...";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String enableSuccess(Plugin plugin, long startMillis) {
|
||||
return "&aEnabled successfully!&f Cost " + (System.currentTimeMillis() - startMillis) + " ms.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String enableFailure(Plugin plugin, long startMillis) {
|
||||
return "&cEnabled failed after " + (System.currentTimeMillis() - startMillis) + " ms.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String disabling(Plugin plugin) {
|
||||
return "&f" + plugin.getName() + " " + plugin.getDescription().getVersion() + " begin to shutdown...";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String disabled(Plugin plugin, long startMillis) {
|
||||
return "&fShutdown successfully, cost " + (System.currentTimeMillis() - startMillis) + " ms.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cc.carm.lib.easyplugin.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ColorParser {
|
||||
|
||||
public static final Pattern HEX_PATTERN = Pattern.compile("&\\(&?#([0-9a-fA-F]{6})\\)");
|
||||
|
||||
public static String parse(String text) {
|
||||
return parseBaseColor(parseHexColor(text));
|
||||
}
|
||||
|
||||
public static String[] parse(String... texts) {
|
||||
return parse(Arrays.asList(texts)).toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static List<String> parse(List<String> texts) {
|
||||
return texts.stream().map(ColorParser::parse).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static String parseBaseColor(final String text) {
|
||||
return text.replaceAll("&", "§").replace("§§", "&");
|
||||
}
|
||||
|
||||
public static String parseHexColor(String text) {
|
||||
Matcher matcher = HEX_PATTERN.matcher(text);
|
||||
while (matcher.find()) {
|
||||
text = matcher.replaceFirst(buildHexColor(matcher.group(1)).toLowerCase());
|
||||
matcher.reset(text);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static String buildHexColor(String hexCode) {
|
||||
return Arrays.stream(hexCode.split(""))
|
||||
.map(s -> '§' + s)
|
||||
.collect(Collectors.joining("", '§' + "x", ""));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package cc.carm.lib.easyplugin.utils;
|
||||
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemStackFactory {
|
||||
ItemStack item;
|
||||
|
||||
private ItemStackFactory() {
|
||||
}
|
||||
|
||||
public ItemStackFactory(ItemStack is) {
|
||||
this.item = is.clone();
|
||||
}
|
||||
|
||||
public ItemStackFactory(Material type) {
|
||||
this(type, 1);
|
||||
}
|
||||
|
||||
public ItemStackFactory(Material type, int amount) {
|
||||
this(type, amount, (short) 0);
|
||||
}
|
||||
|
||||
public ItemStackFactory(Material type, int amount, short data) {
|
||||
this.item = new ItemStack(type, amount, data);
|
||||
}
|
||||
|
||||
public ItemStackFactory(Material type, int amount, int data) {
|
||||
this(type, amount, (short) data);
|
||||
}
|
||||
|
||||
public ItemStack toItemStack() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public ItemStackFactory setType(Material type) {
|
||||
this.item.setType(type);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackFactory setDurability(int i) {
|
||||
ItemMeta im = this.item.getItemMeta();
|
||||
if (im instanceof Damageable) {
|
||||
((Damageable) im).setDamage(i);
|
||||
this.item.setItemMeta(im);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackFactory setAmount(int a) {
|
||||
this.item.setAmount(a);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackFactory setDisplayName(@NotNull String name) {
|
||||
ItemMeta im = this.item.getItemMeta();
|
||||
if (im != null) {
|
||||
im.setDisplayName(ColorParser.parse(name));
|
||||
this.item.setItemMeta(im);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackFactory setLore(@NotNull List<String> loreList) {
|
||||
ItemMeta im = this.item.getItemMeta();
|
||||
if (im != null) {
|
||||
im.setLore(
|
||||
loreList.stream()
|
||||
.map(ColorParser::parse)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
this.item.setItemMeta(im);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackFactory addLore(@NotNull String s) {
|
||||
ItemMeta im = this.item.getItemMeta();
|
||||
if (im != null) {
|
||||
List<String> lore = im.getLore() != null ? im.getLore() : new ArrayList<>();
|
||||
lore.add(ColorParser.parse(s));
|
||||
im.setLore(lore);
|
||||
this.item.setItemMeta(im);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackFactory addEnchant(@NotNull Enchantment enchant, int level, boolean ignoreLevelRestriction) {
|
||||
ItemMeta im = this.item.getItemMeta();
|
||||
if (im != null) {
|
||||
im.addEnchant(enchant, level, ignoreLevelRestriction);
|
||||
this.item.setItemMeta(im);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackFactory removeEnchant(@NotNull Enchantment enchant) {
|
||||
ItemMeta im = this.item.getItemMeta();
|
||||
if (im != null) {
|
||||
im.removeEnchant(enchant);
|
||||
this.item.setItemMeta(im);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackFactory addFlag(@NotNull ItemFlag flag) {
|
||||
ItemMeta im = this.item.getItemMeta();
|
||||
if (im != null) {
|
||||
im.addItemFlags(flag);
|
||||
this.item.setItemMeta(im);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackFactory removeFlag(@NotNull ItemFlag flag) {
|
||||
ItemMeta im = this.item.getItemMeta();
|
||||
if (im != null) {
|
||||
im.removeItemFlags(flag);
|
||||
this.item.setItemMeta(im);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackFactory setUnbreakable(boolean unbreakable) {
|
||||
ItemMeta im = this.item.getItemMeta();
|
||||
if (im != null) {
|
||||
im.setUnbreakable(unbreakable);
|
||||
this.item.setItemMeta(im);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package cc.carm.lib.easyplugin.utils;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package cc.carm.lib.easyplugin.utils;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MessageUtils {
|
||||
|
||||
public static boolean hasPlaceholderAPI() {
|
||||
return Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
|
||||
}
|
||||
|
||||
public static void send(@Nullable CommandSender sender, String... messages) {
|
||||
send(sender, Arrays.asList(messages));
|
||||
}
|
||||
|
||||
public static void send(@Nullable CommandSender sender, List<String> messages) {
|
||||
if (messages == null || messages.isEmpty() || sender == null) return;
|
||||
for (String s : messages) {
|
||||
sender.sendMessage(ColorParser.parse(s));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendWithPlaceholders(CommandSender sender, String... messages) {
|
||||
sendWithPlaceholders(sender, Arrays.asList(messages));
|
||||
}
|
||||
|
||||
public static void sendWithPlaceholders(@Nullable CommandSender sender, List<String> messages) {
|
||||
if (messages == null || messages.isEmpty() || sender == null) return;
|
||||
send(sender, setPlaceholders(sender, messages));
|
||||
}
|
||||
|
||||
public static void sendWithPlaceholders(@Nullable CommandSender sender, List<String> messages, String param, Object value) {
|
||||
sendWithPlaceholders(sender, messages, new String[]{param}, new Object[]{value});
|
||||
}
|
||||
|
||||
public static void sendWithPlaceholders(@Nullable CommandSender sender, List<String> messages, String[] params, Object[] values) {
|
||||
sendWithPlaceholders(sender, setCustomParams(messages, params, values));
|
||||
}
|
||||
|
||||
public static String setPlaceholders(@Nullable CommandSender sender, @Nullable String message) {
|
||||
if (message == null || sender == null) return message;
|
||||
if (hasPlaceholderAPI() && sender instanceof Player) {
|
||||
return PlaceholderAPI.setPlaceholders((Player) sender, message);
|
||||
} else {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Contract("_, !null -> !null")
|
||||
public static List<String> setPlaceholders(@Nullable CommandSender sender,
|
||||
@Nullable List<String> messages) {
|
||||
if (messages == null || messages.isEmpty() || sender == null) return messages;
|
||||
if (hasPlaceholderAPI() && sender instanceof Player) {
|
||||
return PlaceholderAPI.setPlaceholders((Player) sender, messages);
|
||||
} else {
|
||||
return messages;
|
||||
}
|
||||
}
|
||||
|
||||
public static String setPlaceholders(@Nullable CommandSender sender,
|
||||
@NotNull String message,
|
||||
@Nullable String[] params,
|
||||
@Nullable Object[] values) {
|
||||
return setPlaceholders(sender, setCustomParams(message, params, values));
|
||||
}
|
||||
|
||||
public static List<String> setPlaceholders(@Nullable CommandSender sender,
|
||||
@NotNull List<String> messages,
|
||||
@Nullable String[] params,
|
||||
@Nullable Object[] values) {
|
||||
return setPlaceholders(sender, setCustomParams(messages, params, values));
|
||||
}
|
||||
|
||||
public static String setCustomParams(@NotNull String message,
|
||||
@NotNull String param,
|
||||
@NotNull Object value) {
|
||||
return setCustomParams(message, new String[]{param}, new Object[]{value});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Contract("!null, _, _-> !null ; null, _, _->null ")
|
||||
public static String setCustomParams(@Nullable String message,
|
||||
@Nullable String[] params,
|
||||
@Nullable Object[] values) {
|
||||
if (message == null) return null;
|
||||
if (params == null || values == null) return message;
|
||||
if (params.length != values.length) return message;
|
||||
|
||||
HashMap<String, Object> paramsMap = new HashMap<>();
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
paramsMap.put(params[i], values[i]);
|
||||
}
|
||||
return setCustomParams(message, paramsMap);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String setCustomParams(@NotNull String message, @NotNull HashMap<String, Object> params) {
|
||||
String afterMessage = message;
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
afterMessage = afterMessage.replace(entry.getKey(), entry.getValue().toString());
|
||||
}
|
||||
return afterMessage;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<String> setCustomParams(@NotNull List<String> messages,
|
||||
@NotNull String param,
|
||||
@NotNull Object value) {
|
||||
return setCustomParams(messages, new String[]{param}, new Object[]{value});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<String> setCustomParams(@NotNull List<String> messages,
|
||||
@Nullable String[] params,
|
||||
@Nullable Object[] values) {
|
||||
if (params == null || values == null) return messages;
|
||||
if (params.length != values.length) return messages;
|
||||
HashMap<String, Object> paramsMap = new HashMap<>();
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
paramsMap.put(params[i], values[i]);
|
||||
}
|
||||
return setCustomParams(messages, paramsMap);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<String> setCustomParams(List<String> messages, HashMap<String, Object> params) {
|
||||
return messages.stream()
|
||||
.map(message -> setCustomParams(message, params))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
package cc.carm.lib.easyplugin.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public class SchedulerUtils {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
public SchedulerUtils(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private JavaPlugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在服务端主线程中执行一个任务
|
||||
*
|
||||
* @param runnable 需要执行的任务
|
||||
*/
|
||||
public void run(Runnable runnable) {
|
||||
Bukkit.getScheduler().runTask(getPlugin(), runnable);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 异步执行一个任务。
|
||||
*
|
||||
* @param runnable 需要执行的任务
|
||||
*/
|
||||
public void runAsync(Runnable runnable) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在主线程延时执行一个任务。
|
||||
*
|
||||
* @param delay 延迟的ticks
|
||||
* @param runnable 需要执行的任务
|
||||
*/
|
||||
public void runLater(long delay, Runnable runnable) {
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), runnable, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步延时执行一个任务。
|
||||
*
|
||||
* @param delay 延迟的ticks
|
||||
* @param runnable 需要执行的任务
|
||||
*/
|
||||
public void runLaterAsync(long delay, Runnable runnable) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(getPlugin(), runnable, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* 间隔一段时间按顺序执行列表中的任务
|
||||
*
|
||||
* @param interval 间隔时间
|
||||
* @param tasks 任务列表
|
||||
*/
|
||||
public void runAtInterval(long interval, Runnable... tasks) {
|
||||
runAtInterval(0L, interval, tasks);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 间隔一段时间按顺序执行列表中的任务
|
||||
*
|
||||
* @param delay 延迟时间
|
||||
* @param interval 间隔时间
|
||||
* @param tasks 任务列表
|
||||
*/
|
||||
public void runAtInterval(long delay, long interval, Runnable... tasks) {
|
||||
new BukkitRunnable() {
|
||||
private int index;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.index >= tasks.length) {
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
tasks[index].run();
|
||||
index++;
|
||||
}
|
||||
}.runTaskTimer(getPlugin(), delay, interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* 间隔一段时间按顺序异步执行列表中的任务
|
||||
*
|
||||
* @param interval 间隔时间
|
||||
* @param tasks 任务列表
|
||||
*/
|
||||
public void runAtIntervalAsync(long interval, Runnable... tasks) {
|
||||
runAtIntervalAsync(0L, interval, tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
* 间隔一段时间按顺序异步执行列表中的任务
|
||||
*
|
||||
* @param delay 延迟时间
|
||||
* @param interval 间隔时间
|
||||
* @param tasks 任务列表
|
||||
*/
|
||||
public void runAtIntervalAsync(long delay, long interval, Runnable... tasks) {
|
||||
new BukkitRunnable() {
|
||||
private int index;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.index >= tasks.length) {
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
tasks[index].run();
|
||||
index++;
|
||||
}
|
||||
}.runTaskTimerAsynchronously(getPlugin(), delay, interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重复执行一个任务。
|
||||
*
|
||||
* @param repetitions 重复次数
|
||||
* @param interval 间隔时间
|
||||
* @param task 任务
|
||||
* @param onComplete 结束时执行的任务
|
||||
*/
|
||||
public void repeat(int repetitions, long interval, Runnable task, Runnable onComplete) {
|
||||
new BukkitRunnable() {
|
||||
private int index;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
index++;
|
||||
if (this.index >= repetitions) {
|
||||
this.cancel();
|
||||
if (onComplete == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
onComplete.run();
|
||||
return;
|
||||
}
|
||||
|
||||
task.run();
|
||||
}
|
||||
}.runTaskTimer(getPlugin(), 0L, interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重复执行一个任务。
|
||||
*
|
||||
* @param repetitions 重复次数
|
||||
* @param interval 间隔时间
|
||||
* @param task 任务
|
||||
* @param onComplete 结束时执行的任务
|
||||
*/
|
||||
public void repeatAsync(int repetitions, long interval, Runnable task, Runnable onComplete) {
|
||||
new BukkitRunnable() {
|
||||
private int index;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
index++;
|
||||
if (this.index >= repetitions) {
|
||||
this.cancel();
|
||||
if (onComplete == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
onComplete.run();
|
||||
return;
|
||||
}
|
||||
|
||||
task.run();
|
||||
}
|
||||
}.runTaskTimerAsynchronously(getPlugin(), 0L, interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在满足某个条件时,重复执行一个任务。
|
||||
*
|
||||
* @param interval 重复间隔时间
|
||||
* @param predicate 条件
|
||||
* @param task 任务
|
||||
* @param onComplete 结束时执行的任务
|
||||
*/
|
||||
public void repeatWhile(long interval, Callable<Boolean> predicate, Runnable task, Runnable onComplete) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!predicate.call()) {
|
||||
this.cancel();
|
||||
if (onComplete == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
onComplete.run();
|
||||
return;
|
||||
}
|
||||
|
||||
task.run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(getPlugin(), 0L, interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在满足某个条件时,重复执行一个任务。
|
||||
*
|
||||
* @param interval 重复间隔时间
|
||||
* @param predicate 条件
|
||||
* @param task 任务
|
||||
* @param onComplete 结束时执行的任务
|
||||
*/
|
||||
public void repeatWhileAsync(long interval, Callable<Boolean> predicate, Runnable task, Runnable onComplete) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!predicate.call()) {
|
||||
this.cancel();
|
||||
if (onComplete == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
onComplete.run();
|
||||
return;
|
||||
}
|
||||
|
||||
task.run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}.runTaskTimerAsynchronously(getPlugin(), 0L, interval);
|
||||
}
|
||||
|
||||
public interface Task {
|
||||
void start(Runnable onComplete);
|
||||
}
|
||||
|
||||
public class TaskBuilder {
|
||||
private final Queue<Task> taskList;
|
||||
|
||||
public TaskBuilder() {
|
||||
this.taskList = new LinkedList<>();
|
||||
}
|
||||
|
||||
public TaskBuilder append(TaskBuilder builder) {
|
||||
this.taskList.addAll(builder.taskList);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskBuilder appendDelay(long delay) {
|
||||
this.taskList.add(onComplete -> SchedulerUtils.this.runLater(delay, onComplete));
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskBuilder appendTask(Runnable task) {
|
||||
this.taskList.add(onComplete ->
|
||||
{
|
||||
task.run();
|
||||
onComplete.run();
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskBuilder appendTask(Task task) {
|
||||
this.taskList.add(task);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskBuilder appendDelayedTask(long delay, Runnable task) {
|
||||
this.taskList.add(onComplete -> SchedulerUtils.this.runLater(delay, () ->
|
||||
{
|
||||
task.run();
|
||||
onComplete.run();
|
||||
}));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskBuilder appendTasks(long delay, long interval, Runnable... tasks) {
|
||||
this.taskList.add(onComplete ->
|
||||
{
|
||||
Runnable[] runnables = Arrays.copyOf(tasks, tasks.length + 1);
|
||||
runnables[runnables.length - 1] = onComplete;
|
||||
SchedulerUtils.this.runAtInterval(delay, interval, runnables);
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskBuilder appendRepeatingTask(int repetitions, long interval, Runnable task) {
|
||||
this.taskList.add(onComplete -> SchedulerUtils.this.repeat(repetitions, interval, task, onComplete));
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskBuilder appendConditionalRepeatingTask(long interval, Callable<Boolean> predicate, Runnable task) {
|
||||
this.taskList.add(onComplete -> SchedulerUtils.this.repeatWhile(interval, predicate, task, onComplete));
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskBuilder waitFor(Callable<Boolean> predicate) {
|
||||
this.taskList.add(onComplete -> new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!predicate.call()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.cancel();
|
||||
onComplete.run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(getPlugin(), 0L, 1L));
|
||||
return this;
|
||||
}
|
||||
|
||||
public void runTasks() {
|
||||
this.startNext();
|
||||
}
|
||||
|
||||
private void startNext() {
|
||||
Task task = this.taskList.poll();
|
||||
if (task == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
task.start(this::startNext);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
eb52a0f93e62d00bdbb1b29b4220948c
|
||||
@@ -1 +0,0 @@
|
||||
b6a72282875791de781656b25572d92f84e8dfda
|
||||
@@ -1 +0,0 @@
|
||||
5b570f9fddbe9b704a5b3ad97e8dcbf2
|
||||
@@ -1 +0,0 @@
|
||||
195d155d28b64e5aab0ccd590d162374b30b3c66
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-all</artifactId>
|
||||
<versioning>
|
||||
<release>1.5.14</release>
|
||||
<versions>
|
||||
<version>1.5.14</version>
|
||||
</versions>
|
||||
<lastUpdated>20250609154843</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
@@ -1 +0,0 @@
|
||||
3a3e69a78fa01b357c15c349bd7a43e9
|
||||
@@ -1 +0,0 @@
|
||||
f4d882a8e9f5169580f235c04c714faeab6e828a
|
||||
@@ -1 +0,0 @@
|
||||
61d32c92e7a3db25566c45f0a36d00d4
|
||||
@@ -1 +0,0 @@
|
||||
efa803ceb03ecfd636cdcb5fc563c973c50256fa
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-bom</artifactId>
|
||||
<versioning>
|
||||
<release>1.5.14</release>
|
||||
<versions>
|
||||
<version>1.5.14</version>
|
||||
</versions>
|
||||
<lastUpdated>20250609154843</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
@@ -1 +0,0 @@
|
||||
b2b9256acb4791aca9355f72fc284d9f
|
||||
@@ -1 +0,0 @@
|
||||
ed55e982827d080048023f205f6a0d922c51036b
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
1f74830b0422fe36823c2e2141a6b26e
|
||||
@@ -1 +0,0 @@
|
||||
d7dd7a8972027f1938493e1de7aaf0206d4c6c3a
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
0979768257a22ac2e424c6c68b57a922
|
||||
@@ -1 +0,0 @@
|
||||
bddd6e4e150492a4861f2bd2035bfd300caff3d2
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
d5ecbf90b1b075d600da6f01bd5655fd
|
||||
@@ -1 +0,0 @@
|
||||
f2123c09d2c6829e5f3146feb3dacfb191fed44f
|
||||
@@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<version>1.5.14</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
</properties>
|
||||
<artifactId>easyplugin-color</artifactId>
|
||||
|
||||
<name>EasyPlugin-Color</name>
|
||||
<description>轻松插件颜色模块,支持简单便捷的颜色解析器,包括基本颜色、RGB颜色与RGB渐变颜色。</description>
|
||||
<url>https://github.com/CarmJos/EasyPlugin</url>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>CarmJos</id>
|
||||
<name>Carm Jos</name>
|
||||
<email>carm@carm.cc</email>
|
||||
<url>https://www.carm.cc</url>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The MIT License</name>
|
||||
<url>https://opensource.org/licenses/MIT</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub Issues</system>
|
||||
<url>https://github.com/CarmJos/EasyPlugin/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<ciManagement>
|
||||
<system>GitHub Actions</system>
|
||||
<url>https://github.com/CarmJos/EasyPlugin/actions/workflows/maven.yml</url>
|
||||
</ciManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1 +0,0 @@
|
||||
3bbb8b99df80ee3156691d988420bc2b
|
||||
@@ -1 +0,0 @@
|
||||
bd4a5a5091df8081f34736d955fd4e758abc8252
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-color</artifactId>
|
||||
<versioning>
|
||||
<release>1.5.14</release>
|
||||
<versions>
|
||||
<version>1.5.14</version>
|
||||
</versions>
|
||||
<lastUpdated>20250609154843</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
@@ -1 +0,0 @@
|
||||
d266bf037b3074908b277192fb8ecd21
|
||||
@@ -1 +0,0 @@
|
||||
687ed1a08b0178957f5a9e4ac91d70a965ad9a2e
|
||||
BIN
Binary file not shown.
-1
@@ -1 +0,0 @@
|
||||
76eb754d9c6659b8c18000d8456ffd5b
|
||||
-1
@@ -1 +0,0 @@
|
||||
cf4f46d4bfc7ac06f9c8aaf06a75a8763e1f9fb2
|
||||
BIN
Binary file not shown.
-1
@@ -1 +0,0 @@
|
||||
61107bc08a63b6dce2481ba32853b68c
|
||||
-1
@@ -1 +0,0 @@
|
||||
188a058f8cb9bf240eabfe1051997053226e55eb
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
a6cdd09fbbac814baae4cea762462ad6
|
||||
@@ -1 +0,0 @@
|
||||
64517d4f854bb61b52cf9a2ca6ca854c19f83f5b
|
||||
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<version>1.5.14</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
</properties>
|
||||
<artifactId>easyplugin-command-alias</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EasyPlugin-Command-Alias</name>
|
||||
<description>轻松插件指令别名映射模块,支持将插件内复杂的子指令简化为一个单独的指令,方便玩家使用。</description>
|
||||
<url>https://github.com/CarmJos/EasyPlugin</url>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>CarmJos</id>
|
||||
<name>Carm Jos</name>
|
||||
<email>carm@carm.cc</email>
|
||||
<url>https://www.carm.cc</url>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The MIT License</name>
|
||||
<url>https://opensource.org/licenses/MIT</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub Issues</system>
|
||||
<url>https://github.com/CarmJos/EasyPlugin/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<ciManagement>
|
||||
<system>GitHub Actions</system>
|
||||
<url>https://github.com/CarmJos/EasyPlugin/actions/workflows/maven.yml</url>
|
||||
</ciManagement>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1 +0,0 @@
|
||||
6fb3304684a8d185a226ef7550f84986
|
||||
@@ -1 +0,0 @@
|
||||
368c34d296c94d2a64cf28912808fe805457d1d4
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-command-alias</artifactId>
|
||||
<versioning>
|
||||
<release>1.5.14</release>
|
||||
<versions>
|
||||
<version>1.5.14</version>
|
||||
</versions>
|
||||
<lastUpdated>20250609154843</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
@@ -1 +0,0 @@
|
||||
f4f4c19f893c8ab5403212068b8381ce
|
||||
@@ -1 +0,0 @@
|
||||
c5776e6a85bb29765bb5a1f50487e0a2e5f757e0
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
ea260f00a915be15102c09e39ee4416d
|
||||
@@ -1 +0,0 @@
|
||||
39d88db0c947385867cd2b125cbf1e21fe5190d3
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
ab2b22df5ea384d56d62ae07599270a8
|
||||
@@ -1 +0,0 @@
|
||||
44bc9c819a2da737133299135f838a3508fda6f3
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
4cef299bc9d1264096ec9bce89be2c5c
|
||||
@@ -1 +0,0 @@
|
||||
00c52df0129b12ebcff5379a44ce0a25df531e60
|
||||
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.5.14</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
</properties>
|
||||
<artifactId>easyplugin-command</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EasyPlugin-Command</name>
|
||||
<description>轻松插件指令接口模块,方便快捷的编写子指令。</description>
|
||||
<url>https://github.com/CarmJos/EasyPlugin</url>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>CarmJos</id>
|
||||
<name>Carm Jos</name>
|
||||
<email>carm@carm.cc</email>
|
||||
<url>https://www.carm.cc</url>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The MIT License</name>
|
||||
<url>https://opensource.org/licenses/MIT</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub Issues</system>
|
||||
<url>https://github.com/CarmJos/EasyPlugin/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<ciManagement>
|
||||
<system>GitHub Actions</system>
|
||||
<url>https://github.com/CarmJos/EasyPlugin/actions/workflows/maven.yml</url>
|
||||
</ciManagement>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1 +0,0 @@
|
||||
51b75189294be1fb2b7601bbffb9f79a
|
||||
@@ -1 +0,0 @@
|
||||
c525c2dfe524c31d1126e9f8400f4ccfc953404e
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-command</artifactId>
|
||||
<versioning>
|
||||
<release>1.5.14</release>
|
||||
<versions>
|
||||
<version>1.5.14</version>
|
||||
</versions>
|
||||
<lastUpdated>20250609154843</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
@@ -1 +0,0 @@
|
||||
1ea950121ace481353911309a56214de
|
||||
@@ -1 +0,0 @@
|
||||
7048d1d479c63db3fde61c7aee308d00ba18218f
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
a8fbde3c7532a4ae53d9a02295624514
|
||||
@@ -1 +0,0 @@
|
||||
bd4eb77e726ff86ef6f12f748ba8b515369e7e95
|
||||
@@ -1 +0,0 @@
|
||||
0e5b6b0d1bb8b08662c53322e763602c
|
||||
@@ -1 +0,0 @@
|
||||
18bfda4e5af6691278b1352f10898c1564d85401
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-common</artifactId>
|
||||
<versioning>
|
||||
<release>1.5.14</release>
|
||||
<versions>
|
||||
<version>1.5.14</version>
|
||||
</versions>
|
||||
<lastUpdated>20250609154843</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user