mirror of
https://github.com/CarmJos/UserPrefix.git
synced 2026-06-05 09:01:39 +08:00
Compare commits
105 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b2eaf2519 | |||
| 75ee308174 | |||
| bed1651027 | |||
| 7dde64e699 | |||
| 9b88142676 | |||
| e0cfd87ac6 | |||
| fd764fa348 | |||
| 480cebd16a | |||
| 6cd25cf94a | |||
| 72071492b3 | |||
| b334c3476e | |||
| c94ed28b98 | |||
| 72aa4e3a82 | |||
| acc92d5fb4 | |||
| bc002f9a07 | |||
| f11749d4da | |||
| a52b703a75 | |||
| 86775cdbcd | |||
| 8951b7ac90 | |||
| 89b520b8d3 | |||
| b57ff5b2c5 | |||
| b4469f93d0 | |||
| d91dd6c7bd | |||
| ebd9f9fbfc | |||
| f5d256b5c4 | |||
| e43ce22551 | |||
| f821ab88ed | |||
| b03bb4a476 | |||
| 86326a168b | |||
| 672641259e | |||
| 5fc46eed8f | |||
| 50ded3fa11 | |||
| 951fe67117 | |||
| 442374da0a | |||
| 77a277ba58 | |||
| 1ead1a0692 | |||
| f519fa43df | |||
| da63cf8b1c | |||
| 9527e9fcbb | |||
| 5befd40706 | |||
| e1bedba01b | |||
| 5809659155 | |||
| e5013b76e0 | |||
| 6604cec136 | |||
| c7f3286d81 | |||
| 5ed6f1a301 | |||
| 9864d5a75e | |||
| 2b8a7e7545 | |||
| 25b961b913 | |||
| 8e8427a937 | |||
| 748335a962 | |||
| 1e0fd2bcd4 | |||
| 04caf2df73 | |||
| 0eba124f08 | |||
| d54349da98 | |||
| eab9b2385c | |||
| 003884d772 | |||
| 610242ff62 | |||
| 289ab87273 | |||
| 46c1c03113 | |||
| 5ddde2aa99 | |||
| 38a9b0866c | |||
| e7b5b78d66 | |||
| ca83cc63a5 | |||
| 3c19c8165f | |||
| 844f59af20 | |||
| 4d42982659 | |||
| f272456079 | |||
| 50be238b36 | |||
| b7341290ec | |||
| af59a8cb4b | |||
| 30f4ca9af1 | |||
| 61350cde57 | |||
| ba3c7d5c32 | |||
| 3b06ca8109 | |||
| 5edde945d1 | |||
| 4de8863ab6 | |||
| 3c40419437 | |||
| d18ce24841 | |||
| 0b62bcd1ef | |||
| e2aadfde23 | |||
| 4ca145dbef | |||
| 1b8d499d28 | |||
| 0c182a8ed3 | |||
| 66e2302fd0 | |||
| 824a65b21c | |||
| 2c49377c33 | |||
| a0f8382830 | |||
| 675bbe4cf2 | |||
| 3b8fd6febf | |||
| d8282b9641 | |||
| ad616e5470 | |||
| f741723204 | |||
| 54f526300a | |||
| 5a0e5b8e96 | |||
| c89a9c6ccc | |||
| e321a1ec66 | |||
| 9054161135 | |||
| 53281b80e3 | |||
| 12489fe1a8 | |||
| 7d62f68662 | |||
| 4cc50c21d5 | |||
| 0d25490d0f | |||
| a805aba42e | |||
| 2a0d6b8582 |
@@ -38,11 +38,11 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v1
|
uses: github/codeql-action/init@v4
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
@@ -53,7 +53,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v1
|
uses: github/codeql-action/autobuild@v4
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
@@ -67,4 +67,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v1
|
uses: github/codeql-action/analyze@v4
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v6
|
||||||
- name: "Set up JDK"
|
- name: "Set up JDK"
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
rm -rf docs
|
rm -rf docs
|
||||||
mkdir -vp docs
|
mkdir -vp docs
|
||||||
cp -vrf target/apidocs/* docs/
|
cp -vrf target/reports/apidocs/* docs/
|
||||||
cp -vrf .documentation/JAVADOC-README.md docs/README.md
|
cp -vrf .documentation/JAVADOC-README.md docs/README.md
|
||||||
|
|
||||||
- name: "Generate the Javadoc sitemap"
|
- name: "Generate the Javadoc sitemap"
|
||||||
@@ -88,3 +88,26 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd docs
|
cd docs
|
||||||
git push origin HEAD:gh-pages --force
|
git push origin HEAD:gh-pages --force
|
||||||
|
|
||||||
|
- name: "Modrinth Publish"
|
||||||
|
id: publish-modrinth
|
||||||
|
uses: Kir-Antipov/mc-publish@v3.3
|
||||||
|
with:
|
||||||
|
modrinth-id: tLcVHCPk
|
||||||
|
modrinth-featured: true
|
||||||
|
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
||||||
|
files: |
|
||||||
|
asset/*.jar
|
||||||
|
loaders: |
|
||||||
|
spigot
|
||||||
|
paper
|
||||||
|
purpur
|
||||||
|
folia
|
||||||
|
bukkit
|
||||||
|
game-versions: |
|
||||||
|
>=1.8 <=1.21.8
|
||||||
|
game-version-filter: releases
|
||||||
|
java: |
|
||||||
|
8
|
||||||
|
dependencies: |
|
||||||
|
placeholderapi(recommended)
|
||||||
@@ -14,9 +14,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v6
|
||||||
- name: "Set up JDK"
|
- name: "Set up JDK"
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
@@ -37,7 +37,8 @@ jobs:
|
|||||||
cp -vrf asset/*.jar artifacts
|
cp -vrf asset/*.jar artifacts
|
||||||
|
|
||||||
- name: "Upload artifact"
|
- name: "Upload artifact"
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Artifact
|
name: Artifact
|
||||||
path: artifacts
|
path: artifacts
|
||||||
|
include-hidden-files: true
|
||||||
+2
-2
@@ -20,8 +20,6 @@ development.
|
|||||||
|
|
||||||
> This plugin has been published on [SpigotMC](https://www.spigotmc.org/resources/userprefix.96277/) .
|
> This plugin has been published on [SpigotMC](https://www.spigotmc.org/resources/userprefix.96277/) .
|
||||||
|
|
||||||
> 本插件已在 [MCBBS](https://www.mcbbs.net/forum.php?mod=viewthread&tid=1261503) 上发布,欢迎中文用户来这里下载。
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||

|

|
||||||
@@ -49,6 +47,8 @@ For development dependencies, please see [Dependencies](https://github.com/Carm
|
|||||||
- Support PlaceholderAPI variables!
|
- Support PlaceholderAPI variables!
|
||||||
- Support [Hex Color](https://www.hexcolortool.com/)! (Version 1.16 and above) `&(#Color)`
|
- Support [Hex Color](https://www.hexcolortool.com/)! (Version 1.16 and above) `&(#Color)`
|
||||||
- Example: LightSlateBlue `&(#8470FF)` 、 DarkSlateBlue `&(#483D8B)`
|
- Example: LightSlateBlue `&(#8470FF)` 、 DarkSlateBlue `&(#483D8B)`
|
||||||
|
- Support Gradient Color! (Version 1.16 and above) `&<#Color1>Message&<#Color2>`
|
||||||
|
- Example: `&<#8470FF>Hello World!&<#483D8B>`
|
||||||
|
|
||||||
## Notice
|
## Notice
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ README LANGUAGES [ [**中文**](README.md) | [English](README-en.md) ]
|
|||||||
|
|
||||||
本插件基于Spigot实现,**理论上支持全版本**。
|
本插件基于Spigot实现,**理论上支持全版本**。
|
||||||
|
|
||||||
> 本插件已在 [MCBBS](https://www.mcbbs.net/forum.php?mod=viewthread&tid=1261503)
|
> 本插件已在 [SpigotMC](https://www.spigotmc.org/resources/userprefix-hex-color-support-all-version.96277/) 上发布。
|
||||||
> 与 [SpigotMC](https://www.spigotmc.org/resources/userprefix-hex-color-support-all-version.96277/) 上发布。
|
|
||||||
|
|
||||||
## 示例
|
## 示例
|
||||||
|
|
||||||
@@ -40,11 +39,15 @@ README LANGUAGES [ [**中文**](README.md) | [English](README-en.md) ]
|
|||||||
- TabList自动按照前缀的权重排序 (如有冲突可关掉)
|
- TabList自动按照前缀的权重排序 (如有冲突可关掉)
|
||||||
- 玩家头顶前缀显示 (如有冲突可关掉)
|
- 玩家头顶前缀显示 (如有冲突可关掉)
|
||||||
- 简单的聊天变量修改功能!(不推荐使用) `[自 v2.1.0 版本起]`
|
- 简单的聊天变量修改功能!(不推荐使用) `[自 v2.1.0 版本起]`
|
||||||
|
- 支持动态前缀内容轮换!`[自 v3.3.0 版本起]`
|
||||||
- 自动排序,且可翻页的GUI!
|
- 自动排序,且可翻页的GUI!
|
||||||
- 支持PlaceholderAPI变量!(凡支持的都可以使用,如BungeeTabListPlus)
|
- 支持PlaceholderAPI变量!(凡支持的都可以使用,如BungeeTabListPlus)
|
||||||
- 支持[Hex颜色](https://www.hexcolortool.com/)!(1.16以上版本) `[自 v1.2.3 版本起]`
|
- 支持[Hex颜色](https://www.hexcolortool.com/)!(1.16以上版本) `[自 v1.2.3 版本起]`
|
||||||
- 格式: `&(#颜色代码)`
|
- 格式: `&(#颜色代码)`
|
||||||
- 示例: LightSlateBlue `&(#8470FF)` 、 DarkSlateBlue `&(#483D8B)`
|
- 示例: LightSlateBlue `&(#8470FF)` 、 DarkSlateBlue `&(#483D8B)`
|
||||||
|
- 支持渐变色!(1.16以上版本) `[自 v1.2.3 版本起]`
|
||||||
|
- 格式: `&<#颜色代码1>消息内容&<#颜色代码2>`
|
||||||
|
- 示例: `&<#8470FF>Hello World!&<#483D8B>`
|
||||||
|
|
||||||
## 注意事项
|
## 注意事项
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -13,13 +13,13 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||||
|
|
||||||
<deps.easyplugin.version>1.5.2</deps.easyplugin.version>
|
<deps.easyplugin.version>1.5.14</deps.easyplugin.version>
|
||||||
<deps.mineconfig.version>2.4.0</deps.mineconfig.version>
|
<deps.mineconfig.version>3.1.3</deps.mineconfig.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<artifactId>userprefix</artifactId>
|
<artifactId>userprefix</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.3.1</version>
|
||||||
|
|
||||||
<name>UserPrefix</name>
|
<name>UserPrefix</name>
|
||||||
<description>轻便、高效、实时的用户前缀系统。</description>
|
<description>轻便、高效、实时的用户前缀系统。</description>
|
||||||
@@ -81,6 +81,12 @@
|
|||||||
<url>https://repo.lucko.me/</url>
|
<url>https://repo.lucko.me/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>minecraft-libraries</id>
|
||||||
|
<name>Minecraft Libraries</name>
|
||||||
|
<url>https://libraries.minecraft.net/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>EasyPlugin</id>
|
<id>EasyPlugin</id>
|
||||||
<url>https://raw.githubusercontent.com/CarmJos/EasyPlugin/repo/</url>
|
<url>https://raw.githubusercontent.com/CarmJos/EasyPlugin/repo/</url>
|
||||||
@@ -152,40 +158,65 @@
|
|||||||
<version>${deps.mineconfig.version}</version>
|
<version>${deps.mineconfig.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.cryptomorin.xseries</groupId>
|
||||||
|
<artifactId>XSeries</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.github.cryptomorin</groupId>
|
||||||
|
<artifactId>XSeries</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.cryptomorin</groupId>
|
||||||
|
<artifactId>XSeries</artifactId>
|
||||||
|
<version>13.8.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>authlib</artifactId>
|
||||||
|
<version>6.0.54</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.17-R0.1-SNAPSHOT</version>
|
<version>1.19-R0.1-20220725.090125-47</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.clip</groupId>
|
<groupId>me.clip</groupId>
|
||||||
<artifactId>placeholderapi</artifactId>
|
<artifactId>placeholderapi</artifactId>
|
||||||
<version>2.10.9</version>
|
<version>2.12.2</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.luckperms</groupId>
|
<groupId>net.luckperms</groupId>
|
||||||
<artifactId>api</artifactId>
|
<artifactId>api</artifactId>
|
||||||
<version>5.4</version>
|
<version>5.5</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>org.bstats</groupId>
|
||||||
<artifactId>bstats-bukkit</artifactId>
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.2.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains</groupId>
|
<groupId>org.jetbrains</groupId>
|
||||||
<artifactId>annotations</artifactId>
|
<artifactId>annotations</artifactId>
|
||||||
<version>23.0.0</version>
|
<version>26.1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -202,7 +233,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-clean-plugin</artifactId>
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
<version>2.5</version>
|
<version>3.5.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<filesets>
|
<filesets>
|
||||||
<fileset>
|
<fileset>
|
||||||
@@ -225,7 +256,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.15.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${project.jdk.version}</source>
|
<source>${project.jdk.version}</source>
|
||||||
<target>${project.jdk.version}</target>
|
<target>${project.jdk.version}</target>
|
||||||
@@ -236,12 +267,12 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.5.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.4.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@@ -254,7 +285,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.2.3</version>
|
<version>3.6.2</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@@ -281,6 +312,10 @@
|
|||||||
<pattern>org.json</pattern>
|
<pattern>org.json</pattern>
|
||||||
<shadedPattern>${project.package}.lib.json</shadedPattern>
|
<shadedPattern>${project.package}.lib.json</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.cryptomorin.xseries</pattern>
|
||||||
|
<shadedPattern>${project.package}.lib.xseries</shadedPattern>
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
<filters>
|
<filters>
|
||||||
<filter>
|
<filter>
|
||||||
@@ -296,7 +331,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.12.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<classifier>javadoc</classifier>
|
<classifier>javadoc</classifier>
|
||||||
<links>
|
<links>
|
||||||
@@ -323,7 +358,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.22.1</version>
|
<version>3.5.6</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<useSystemClassLoader>false</useSystemClassLoader>
|
<useSystemClassLoader>false</useSystemClassLoader>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": [
|
||||||
|
"config:base","mergeConfidence:all-badges"
|
||||||
|
],
|
||||||
|
"packageRules": [
|
||||||
|
{
|
||||||
|
"description": "Automerge non-major updates",
|
||||||
|
"matchUpdateTypes": ["minor", "patch"],
|
||||||
|
"automerge": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ import cc.carm.lib.easyplugin.utils.MessageUtils;
|
|||||||
import cc.carm.plugin.userprefix.command.AdminCommand;
|
import cc.carm.plugin.userprefix.command.AdminCommand;
|
||||||
import cc.carm.plugin.userprefix.command.UserCommand;
|
import cc.carm.plugin.userprefix.command.UserCommand;
|
||||||
import cc.carm.plugin.userprefix.conf.PluginConfig;
|
import cc.carm.plugin.userprefix.conf.PluginConfig;
|
||||||
|
import cc.carm.plugin.userprefix.folia.FoliaScheduler;
|
||||||
import cc.carm.plugin.userprefix.hooker.UserPrefixExpansion;
|
import cc.carm.plugin.userprefix.hooker.UserPrefixExpansion;
|
||||||
import cc.carm.plugin.userprefix.listener.ChatListener;
|
import cc.carm.plugin.userprefix.listener.ChatListener;
|
||||||
import cc.carm.plugin.userprefix.listener.UserListener;
|
import cc.carm.plugin.userprefix.listener.UserListener;
|
||||||
@@ -28,6 +29,9 @@ public class Main extends EasyPlugin {
|
|||||||
|
|
||||||
private static Main instance;
|
private static Main instance;
|
||||||
|
|
||||||
|
protected FoliaScheduler foliaScheduler;
|
||||||
|
protected boolean onFolia;
|
||||||
|
|
||||||
protected ConfigManager configManager;
|
protected ConfigManager configManager;
|
||||||
protected PrefixManager prefixManager;
|
protected PrefixManager prefixManager;
|
||||||
protected UserManager userManager;
|
protected UserManager userManager;
|
||||||
@@ -36,6 +40,14 @@ public class Main extends EasyPlugin {
|
|||||||
protected boolean initialize() {
|
protected boolean initialize() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
|
||||||
|
this.onFolia = true;
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
this.onFolia = false;
|
||||||
|
}
|
||||||
|
this.foliaScheduler = new FoliaScheduler(this, this.onFolia);
|
||||||
|
|
||||||
log("加载插件配置...");
|
log("加载插件配置...");
|
||||||
this.configManager = new ConfigManager(getDataFolder());
|
this.configManager = new ConfigManager(getDataFolder());
|
||||||
this.prefixManager = new PrefixManager();
|
this.prefixManager = new PrefixManager();
|
||||||
@@ -61,8 +73,8 @@ public class Main extends EasyPlugin {
|
|||||||
|
|
||||||
log("初始化GUI管理器...");
|
log("初始化GUI管理器...");
|
||||||
GUI.initialize(this);
|
GUI.initialize(this);
|
||||||
AutoPagedGUI.defaultNextPage = (PluginConfig.GUI.BOTTOMS.NEXT_PAGE::getItem);
|
AutoPagedGUI.defaultNextPage = (PluginConfig.GUI.BOTTOMS.NEXT_PAGE::get);
|
||||||
AutoPagedGUI.defaultPreviousPage = (PluginConfig.GUI.BOTTOMS.PREV_PAGE::getItem);
|
AutoPagedGUI.defaultPreviousPage = (PluginConfig.GUI.BOTTOMS.PREV_PAGE::get);
|
||||||
|
|
||||||
if (MessageUtils.hasPlaceholderAPI()) {
|
if (MessageUtils.hasPlaceholderAPI()) {
|
||||||
log("注册变量...");
|
log("注册变量...");
|
||||||
@@ -87,11 +99,14 @@ public class Main extends EasyPlugin {
|
|||||||
|
|
||||||
if (PluginConfig.CHECK_UPDATE.getNotNull()) {
|
if (PluginConfig.CHECK_UPDATE.getNotNull()) {
|
||||||
log("开始检查更新...");
|
log("开始检查更新...");
|
||||||
getScheduler().runAsync(GHUpdateChecker.runner(this));
|
this.foliaScheduler.runAsync(GHUpdateChecker.runner(this));
|
||||||
} else {
|
} else {
|
||||||
log("已禁用检查更新,跳过。");
|
log("已禁用检查更新,跳过。");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PluginConfig.FUNCTIONS.NAME_PREFIX.ENABLE.getNotNull() && this.isOnFolia()) {
|
||||||
|
log("插件正运行在 Folia 服务端上,头顶前缀功能不可用");
|
||||||
|
}
|
||||||
Bukkit.getOnlinePlayers().forEach(userManager::initPlayer); // 适配热重载
|
Bukkit.getOnlinePlayers().forEach(userManager::initPlayer); // 适配热重载
|
||||||
|
|
||||||
log("&7感谢您使用 &3&lUserPrefix " + getDescription().getVersion() + "&7!");
|
log("&7感谢您使用 &3&lUserPrefix " + getDescription().getVersion() + "&7!");
|
||||||
@@ -113,6 +128,14 @@ public class Main extends EasyPlugin {
|
|||||||
log("&7本插件由 &b&lYourCraft &7提供长期支持与维护。");
|
log("&7本插件由 &b&lYourCraft &7提供长期支持与维护。");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOnFolia() {
|
||||||
|
return this.onFolia;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FoliaScheduler getFoliaScheduler() {
|
||||||
|
return this.foliaScheduler;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebugging() {
|
public boolean isDebugging() {
|
||||||
return PluginConfig.DEBUG.getNotNull();
|
return PluginConfig.DEBUG.getNotNull();
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ public class AdminCommand extends CommandHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void noPermission(CommandSender sender) {
|
public Void noPermission(CommandSender sender) {
|
||||||
PluginMessages.COMMAND_USAGE.NO_PERM.send(sender);
|
PluginMessages.COMMAND_USAGE.NO_PERM.sendTo(sender);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Void help(CommandSender sender) {
|
public static Void help(CommandSender sender) {
|
||||||
PluginMessages.COMMAND_USAGE.ADMIN.send(sender);
|
PluginMessages.COMMAND_USAGE.ADMIN.sendTo(sender);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class UserCommand implements CommandExecutor {
|
|||||||
PrefixSelectGUI.open((Player) sender);
|
PrefixSelectGUI.open((Player) sender);
|
||||||
} else {
|
} else {
|
||||||
if (strings.length != 1) {
|
if (strings.length != 1) {
|
||||||
PluginMessages.COMMAND_USAGE.CONSOLE.send(sender);
|
PluginMessages.COMMAND_USAGE.CONSOLE.sendTo(sender);
|
||||||
} else {
|
} else {
|
||||||
Player player = Bukkit.getPlayer(strings[0]);
|
Player player = Bukkit.getPlayer(strings[0]);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class ListCommand extends SubCommand<AdminCommand> {
|
public class ListCommand extends SubCommand<AdminCommand> {
|
||||||
|
|
||||||
public ListCommand(@NotNull AdminCommand parent, String name, String... aliases) {
|
public ListCommand(@NotNull AdminCommand parent, String name, String... aliases) {
|
||||||
@@ -17,12 +19,12 @@ public class ListCommand extends SubCommand<AdminCommand> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void execute(JavaPlugin plugin, CommandSender sender, String[] args) {
|
public Void execute(JavaPlugin plugin, CommandSender sender, String[] args) {
|
||||||
PluginMessages.LIST.HEADER.send(sender);
|
PluginMessages.LIST.HEADER.sendTo(sender);
|
||||||
for (PrefixConfig value : UserPrefixAPI.getPrefixManager().getPrefixes().values()) {
|
for (PrefixConfig value : UserPrefixAPI.getPrefixManager().getPrefixes().values()) {
|
||||||
PluginMessages.LIST.VALUE.send(sender,
|
PluginMessages.LIST.VALUE.sendTo(sender,
|
||||||
value.getWeight(), value.getIdentifier(),
|
value.getWeight(), value.getIdentifier(),
|
||||||
value.getName(), value.getPermission(),
|
value.getName(), Optional.ofNullable(value.getPermission()).orElse("~"),
|
||||||
value.getContent(), sender.getName()
|
value.getContent(sender), sender.getName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ public class ReloadCommand extends SubCommand<AdminCommand> {
|
|||||||
*/
|
*/
|
||||||
UserPrefixAPI.getUserManager().updatePrefixView(onlinePlayer, false);
|
UserPrefixAPI.getUserManager().updatePrefixView(onlinePlayer, false);
|
||||||
}
|
}
|
||||||
PluginMessages.RELOAD.SUCCESS.send(sender, System.currentTimeMillis() - s1, num);
|
PluginMessages.RELOAD.SUCCESS.sendTo(sender, System.currentTimeMillis() - s1, num);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
PluginMessages.RELOAD.FAILED.send(sender, e.getMessage());
|
PluginMessages.RELOAD.FAILED.sendTo(sender, e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class SetCommand extends SubCommand<AdminCommand> {
|
|||||||
|
|
||||||
Player target = Bukkit.getPlayer(args[0]);
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
PluginMessages.NOT_ONLINE.send(sender, args[0]);
|
PluginMessages.NOT_ONLINE.sendTo(sender, args[0]);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,17 +37,17 @@ public class SetCommand extends SubCommand<AdminCommand> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (prefixConfig == null) {
|
if (prefixConfig == null) {
|
||||||
PluginMessages.SET.PREFIX_NOT_FOUND.send(sender, prefixInput);
|
PluginMessages.SET.PREFIX_NOT_FOUND.sendTo(sender, prefixInput);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!prefixConfig.checkPermission(target)) {
|
if (!prefixConfig.checkPermission(target)) {
|
||||||
PluginMessages.SET.NO_PERM.send(sender, target.getName(), prefixConfig.getName());
|
PluginMessages.SET.NO_PERM.sendTo(sender, target.getName(), prefixConfig.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserPrefixAPI.getUserManager().setPrefix(target, prefixConfig, true);
|
UserPrefixAPI.getUserManager().setPrefix(target, prefixConfig, true);
|
||||||
PluginMessages.SET.SUCCESS.send(sender, target.getName(), prefixConfig.getName());
|
PluginMessages.SET.SUCCESS.sendTo(sender, target.getName(), prefixConfig.getName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,103 +1,107 @@
|
|||||||
package cc.carm.plugin.userprefix.conf;
|
package cc.carm.plugin.userprefix.conf;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.core.ConfigurationRoot;
|
import cc.carm.lib.configuration.Configuration;
|
||||||
import cc.carm.lib.configuration.core.annotation.ConfigPath;
|
import cc.carm.lib.configuration.adapter.ValueType;
|
||||||
import cc.carm.lib.configuration.core.annotation.HeaderComment;
|
import cc.carm.lib.configuration.annotation.ConfigPath;
|
||||||
import cc.carm.lib.configuration.core.value.ConfigValue;
|
import cc.carm.lib.configuration.annotation.HeaderComments;
|
||||||
import cc.carm.lib.configuration.core.value.type.ConfiguredList;
|
import cc.carm.lib.configuration.value.standard.ConfiguredList;
|
||||||
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
|
import cc.carm.lib.configuration.value.standard.ConfiguredValue;
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredItem;
|
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredSound;
|
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredSound;
|
||||||
|
import cc.carm.lib.mineconfiguration.bukkit.value.item.ConfiguredItem;
|
||||||
import cc.carm.plugin.userprefix.conf.gui.GUIItems;
|
import cc.carm.plugin.userprefix.conf.gui.GUIItems;
|
||||||
|
import cc.carm.plugin.userprefix.folia.MajorUtil;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
|
|
||||||
public class PluginConfig extends ConfigurationRoot {
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@HeaderComment({"开发者查错模式"})
|
public class PluginConfig implements Configuration {
|
||||||
public static final ConfigValue<Boolean> DEBUG = ConfiguredValue.of(Boolean.class, false);
|
|
||||||
|
|
||||||
@HeaderComment({
|
@HeaderComments({"开发者查错模式"})
|
||||||
|
public static final ConfiguredValue<Boolean> DEBUG = ConfiguredValue.of(Boolean.class, false);
|
||||||
|
|
||||||
|
@HeaderComments({
|
||||||
"统计数据设定",
|
"统计数据设定",
|
||||||
" 该选项用于帮助开发者统计插件版本与使用情况,且绝不会影响性能与使用体验。",
|
" 该选项用于帮助开发者统计插件版本与使用情况,且绝不会影响性能与使用体验。",
|
||||||
" 当然,您也可以选择在这里关闭,或在plugins/bStats下的配置文件中关闭。"
|
" 当然,您也可以选择在这里关闭,或在plugins/bStats下的配置文件中关闭。"
|
||||||
})
|
})
|
||||||
public static final ConfigValue<Boolean> METRICS = ConfiguredValue.of(Boolean.class, true);
|
public static final ConfiguredValue<Boolean> METRICS = ConfiguredValue.of(Boolean.class, true);
|
||||||
|
|
||||||
@HeaderComment({
|
@HeaderComments({
|
||||||
"检查更新设定",
|
"检查更新设定",
|
||||||
"该选项用于插件判断是否要检查更新,若您不希望插件检查更新并提示您,可以选择关闭。",
|
"该选项用于插件判断是否要检查更新,若您不希望插件检查更新并提示您,可以选择关闭。",
|
||||||
"检查更新为异步操作,绝不会影响性能与使用体验。"
|
"检查更新为异步操作,绝不会影响性能与使用体验。"
|
||||||
})
|
})
|
||||||
public static final ConfigValue<Boolean> CHECK_UPDATE = ConfiguredValue.of(Boolean.class, true);
|
public static final ConfiguredValue<Boolean> CHECK_UPDATE = ConfiguredValue.of(Boolean.class, true);
|
||||||
|
|
||||||
@HeaderComment({"自定义存储位置设定", "可以规定到远程文件夹中去加载前缀配置"})
|
@HeaderComments({"自定义存储位置设定", "可以规定到远程文件夹中去加载前缀配置"})
|
||||||
public static final class CUSTOM_STORAGE extends ConfigurationRoot {
|
public static final class CUSTOM_STORAGE implements Configuration {
|
||||||
|
|
||||||
@HeaderComment({"是否启用自定义存储位置"})
|
@HeaderComments({"是否启用自定义存储位置"})
|
||||||
public static final ConfigValue<Boolean> ENABLE = ConfiguredValue.of(Boolean.class, false);
|
public static final ConfiguredValue<Boolean> ENABLE = ConfiguredValue.of(Boolean.class, false);
|
||||||
|
|
||||||
@HeaderComment({
|
@HeaderComments({
|
||||||
"目标存储路径,必须指向一个文件夹。",
|
"目标存储路径,必须指向一个文件夹。",
|
||||||
"默认存储位置为 “插件文件夹”/prefixes",
|
"默认存储位置为 “插件文件夹”/prefixes",
|
||||||
"支持绝对文件路径,如 \"/etc/minecraft/configurations/prefixes/\""
|
"支持绝对文件路径,如 \"/etc/minecraft/configurations/prefixes/\""
|
||||||
})
|
})
|
||||||
public static final ConfigValue<String> PATH = ConfiguredValue.of(String.class, "prefixes/");
|
public static final ConfiguredValue<String> PATH = ConfiguredValue.of(String.class, "prefixes/");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HeaderComment("功能设定")
|
@HeaderComments("功能设定")
|
||||||
public static class FUNCTIONS extends ConfigurationRoot {
|
public static class FUNCTIONS implements Configuration {
|
||||||
|
|
||||||
@ConfigPath("on-name-prefix")
|
@ConfigPath("on-name-prefix")
|
||||||
@HeaderComment({"头顶与TabList前缀功能,该方法用到了玩家名计分板接口,如有冲突请关掉哦~"})
|
@HeaderComments({"头顶与TabList前缀功能,该方法用到了玩家名计分板接口,如有冲突请关掉哦~"})
|
||||||
public static final class NAME_PREFIX extends ConfigurationRoot {
|
public static final class NAME_PREFIX implements Configuration {
|
||||||
|
|
||||||
@HeaderComment("是否开启本功能")
|
@HeaderComments("是否开启本功能")
|
||||||
public static final ConfigValue<Boolean> ENABLE = ConfiguredValue.of(Boolean.class, true);
|
public static final ConfiguredValue<Boolean> ENABLE = ConfiguredValue.of(Boolean.class, true);
|
||||||
|
|
||||||
@HeaderComment("是否按降序排列,即权重越高的前缀显示在越上面;若为false则按升序排列。")
|
@HeaderComments("是否按降序排列,即权重越高的前缀显示在越上面;若为false则按升序排列。")
|
||||||
public static final ConfigValue<Boolean> ORDER_DESC = ConfiguredValue.of(Boolean.class, true);
|
public static final ConfiguredValue<Boolean> ORDER_DESC = ConfiguredValue.of(Boolean.class, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigPath("auto-prefix-use")
|
@ConfigPath("auto-prefix-use")
|
||||||
@HeaderComment("自动使用前缀,即当玩家没有自己选择一个前缀的时候,会自动使用所拥有的的前缀中权重最高的那一个")
|
@HeaderComments("自动使用前缀,即当玩家没有自己选择一个前缀的时候,会自动使用所拥有的的前缀中权重最高的那一个")
|
||||||
public static final ConfigValue<Boolean> AUTO_USE = ConfiguredValue.of(Boolean.class, true);
|
public static final ConfiguredValue<Boolean> AUTO_USE = ConfiguredValue.of(Boolean.class, true);
|
||||||
|
|
||||||
|
|
||||||
@HeaderComment({
|
@HeaderComments({
|
||||||
"聊天功能设定",
|
"聊天功能设定",
|
||||||
"- 我不推荐使用本插件的聊天功能,而是建议使用其他的聊天插件。",
|
"- 我不推荐使用本插件的聊天功能,而是建议使用其他的聊天插件。",
|
||||||
"- 本插件仅仅提供了**最基本**的格式变量支持,不包含其他任何功能。",
|
"- 本插件仅仅提供了**最基本**的格式变量支持,不包含其他任何功能。",
|
||||||
"- 注意聊天格式需要遵守Bukkit原格式,即不得缺失 “%1$s” 和 “%2$s” 。",
|
"- 注意聊天格式需要遵守Bukkit原格式,即不得缺失 “%1$s” 和 “%2$s” 。",
|
||||||
"- 本插件的聊天功能不影响其他插件对聊天事件的操作。"
|
"- 本插件的聊天功能不影响其他插件对聊天事件的操作。"
|
||||||
})
|
})
|
||||||
public static final class CHAT extends ConfigurationRoot {
|
public static final class CHAT implements Configuration {
|
||||||
|
|
||||||
@HeaderComment("是否开启本功能")
|
@HeaderComments("是否开启本功能")
|
||||||
public static final ConfigValue<Boolean> ENABLE = ConfiguredValue.of(Boolean.class, false);
|
public static final ConfiguredValue<Boolean> ENABLE = ConfiguredValue.of(Boolean.class, false);
|
||||||
@HeaderComment({
|
@HeaderComments({
|
||||||
"聊天的格式,注意 “%1$s” 和 “%2$s” 不可缺少。",
|
"聊天的格式,注意 “%1$s” 和 “%2$s” 不可缺少。",
|
||||||
"- %1$s -> 玩家名", "- %2$s -> 聊天内容"
|
"- %1$s -> 玩家名", "- %2$s -> 聊天内容"
|
||||||
})
|
})
|
||||||
public static final ConfigValue<String> FORMAT = ConfiguredValue.of(String.class, "<%1$s> %2$s");
|
public static final ConfiguredValue<String> FORMAT = ConfiguredValue.of(String.class, "<%1$s> %2$s");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HeaderComment({"前缀GUI界面设定"})
|
@HeaderComments({"前缀GUI界面设定"})
|
||||||
public static class GUI extends ConfigurationRoot {
|
public static class GUI implements Configuration {
|
||||||
|
|
||||||
@HeaderComment("GUI的标题")
|
@HeaderComments("GUI的标题")
|
||||||
public static final ConfigValue<String> TITLE = ConfiguredValue.of(String.class, "&f&l我的前缀 &8| 列表");
|
public static final ConfiguredValue<String> TITLE = ConfiguredValue.of(String.class, "&f&l我的前缀 &8| 列表");
|
||||||
|
|
||||||
@HeaderComment("GUI中的基本按钮物品")
|
@HeaderComments("GUI中的基本按钮物品")
|
||||||
public static final class BOTTOMS extends ConfigurationRoot {
|
public static final class BOTTOMS implements Configuration {
|
||||||
|
|
||||||
@HeaderComment("前往下一页的物品 (只有存在下一页时才会显示)")
|
@HeaderComments("前往下一页的物品 (只有存在下一页时才会显示)")
|
||||||
public static final ConfiguredItem NEXT_PAGE = ConfiguredItem.create()
|
public static final ConfiguredItem NEXT_PAGE = ConfiguredItem.create()
|
||||||
.defaultType(Material.ARROW)
|
.defaultType(Material.ARROW)
|
||||||
.defaultName("下一页")
|
.defaultName("下一页")
|
||||||
@@ -105,7 +109,7 @@ public class PluginConfig extends ConfigurationRoot {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ConfigPath("previous-page")
|
@ConfigPath("previous-page")
|
||||||
@HeaderComment({"前往上一页时的物品 (只有当前页不是第一页时才会显示)"})
|
@HeaderComments({"前往上一页时的物品 (只有当前页不是第一页时才会显示)"})
|
||||||
public static final ConfiguredItem PREV_PAGE = ConfiguredItem.create()
|
public static final ConfiguredItem PREV_PAGE = ConfiguredItem.create()
|
||||||
.defaultType(Material.ARROW)
|
.defaultType(Material.ARROW)
|
||||||
.defaultName("上一页")
|
.defaultName("上一页")
|
||||||
@@ -114,18 +118,18 @@ public class PluginConfig extends ConfigurationRoot {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HeaderComment("GUI中的其他按钮物品 (若与现有物品位置冲突,将被覆盖)")
|
@HeaderComments("GUI中的其他按钮物品 (若与现有物品位置冲突,将被覆盖)")
|
||||||
public static final ConfigValue<GUIItems> ITEMS = ConfiguredValue
|
public static final ConfiguredValue<GUIItems> ITEMS = ConfiguredValue
|
||||||
.builder(GUIItems.class).fromSection()
|
.builderOf(GUIItems.class).fromSection()
|
||||||
.defaults(GUIItems::defaults)
|
.defaults(GUIItems::defaults)
|
||||||
.serializeValue(GUIItems::serialize)
|
.serialize(GUIItems::serialize)
|
||||||
.parseValue((v, d) -> GUIItems.parse(v))
|
.parse(GUIItems::parse)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HeaderComment({"相关的声音,留空则不播放声音", "格式为 【声音名:音量:音调】 或 【声音名:音量】 或 【声音名】"})
|
@HeaderComments({"相关的声音,留空则不播放声音", "格式为 【声音名:音量:音调】 或 【声音名:音量】 或 【声音名】"})
|
||||||
public static final class SOUNDS extends ConfigurationRoot {
|
public static final class SOUNDS implements Configuration {
|
||||||
|
|
||||||
public static final ConfiguredSound GUI_OPEN = ConfiguredSound.of("BLOCK_NOTE_BLOCK_PLING", 0.5F, 0.8F);
|
public static final ConfiguredSound GUI_OPEN = ConfiguredSound.of("BLOCK_NOTE_BLOCK_PLING", 0.5F, 0.8F);
|
||||||
public static final ConfiguredSound GUI_CLICK = ConfiguredSound.of("UI_BUTTON_CLICK");
|
public static final ConfiguredSound GUI_CLICK = ConfiguredSound.of("UI_BUTTON_CLICK");
|
||||||
@@ -134,40 +138,70 @@ public class PluginConfig extends ConfigurationRoot {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HeaderComment({"默认前缀配置"})
|
@HeaderComments({"默认前缀配置"})
|
||||||
public static final class DEFAULT_PREFIX extends ConfigurationRoot {
|
public static final class DEFAULT_PREFIX implements Configuration {
|
||||||
|
|
||||||
@HeaderComment("默认前缀的显示名称,用于在消息提示中显示。")
|
@HeaderComments("默认前缀的显示名称,用于在消息提示中显示。")
|
||||||
public static final ConfigValue<String> NAME = ConfiguredValue.of(String.class, "默认前缀");
|
public static final ConfiguredValue<String> NAME = ConfiguredValue.of(String.class, "默认前缀");
|
||||||
|
|
||||||
@HeaderComment({"默认前缀的权重,默认为0。"})
|
@HeaderComments({"默认前缀的描述信息。"})
|
||||||
public static final ConfigValue<Integer> WEIGHT = ConfiguredValue.of(Integer.class, 0);
|
public static final ConfiguredList<String> DESCRIPTION = ConfiguredList.builderOf(String.class).fromString()
|
||||||
|
.defaults("&7这是一个默认前缀", "&7您可以在前缀列表中选择其他前缀")
|
||||||
|
.build();
|
||||||
|
|
||||||
@HeaderComment({"默认前缀的内容,即用于显示的实际前缀"})
|
@HeaderComments({"默认前缀的权重,默认为0。"})
|
||||||
public static final ConfigValue<String> CONTENT = ConfiguredValue.of(String.class, "&r");
|
public static final ConfiguredValue<Integer> WEIGHT = ConfiguredValue.of(Integer.class, 0);
|
||||||
|
|
||||||
@HeaderComment({"选择默认前缀时执行的操作"})
|
@HeaderComments({"默认前缀的内容,即用于显示的实际前缀"})
|
||||||
public static final ConfiguredList<String> ACTIONS = ConfiguredList.builder(String.class).fromString()
|
public static final ConfiguredValue<List<String>> CONTENT = ConfiguredValue
|
||||||
|
.builderOf(ValueType.ofList(String.class))
|
||||||
|
.from(Object.class)
|
||||||
|
.parse(obj -> {
|
||||||
|
if (obj instanceof List<?>) {
|
||||||
|
List<?> list = (List<?>) obj;
|
||||||
|
return list.stream()
|
||||||
|
.map(Object::toString)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
} else return Collections.singletonList(String.valueOf(obj));
|
||||||
|
})
|
||||||
|
.serialize(list -> {
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
} else if (list.size() == 1) {
|
||||||
|
return list.get(0);
|
||||||
|
} else {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.defaults(Collections.singletonList("&r"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
|
||||||
|
@HeaderComments({"默认前缀的切换周期,单位为毫秒。(小于0则表示不进行切换,等于0则代表所及选取)"})
|
||||||
|
public static final ConfiguredValue<Long> PERIOD = ConfiguredValue.of(-1L);
|
||||||
|
|
||||||
|
@HeaderComments({"选择默认前缀时执行的操作"})
|
||||||
|
public static final ConfiguredList<String> ACTIONS = ConfiguredList.builderOf(String.class).fromString()
|
||||||
.defaults("[CONSOLE] " + "say %player_name% 选择了默认前缀")
|
.defaults("[CONSOLE] " + "say %player_name% 选择了默认前缀")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@HeaderComment({"默认前缀的显示物品"})
|
@HeaderComments({"默认前缀的显示物品"})
|
||||||
public static final class ITEM extends ConfigurationRoot {
|
public static final class ITEM implements Configuration {
|
||||||
|
|
||||||
@HeaderComment({"当未选择默认前缀时显示的物品"})
|
@HeaderComments({"当未选择默认前缀时显示的物品"})
|
||||||
public static final ConfiguredItem NOT_USING = ConfiguredItem.create()
|
public static final ConfiguredItem NOT_USING = ConfiguredItem.create()
|
||||||
.defaultType(Material.NAME_TAG)
|
.defaultType(Material.NAME_TAG)
|
||||||
.defaultName("&f默认玩家前缀 &f(点击切换)")
|
.defaultName("&f默认玩家前缀 &f(点击切换)")
|
||||||
.defaultLore("", "&a➥ 点击切换到该前缀")
|
.defaultLore("", "{&f&o }#description#{1,1}", "&a➥ 点击切换到该前缀")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@HeaderComment({"当选择了默认前缀时显示的物品"})
|
@HeaderComments({"当选择了默认前缀时显示的物品"})
|
||||||
public static final ConfiguredItem USING = ConfiguredItem.create()
|
public static final ConfiguredItem USING = ConfiguredItem.create()
|
||||||
.defaultType(Material.NAME_TAG)
|
.defaultType(Material.NAME_TAG)
|
||||||
.defaultEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
.defaultEnchant(MajorUtil.getEnchantProtection(), 1) // 附魔改过名
|
||||||
.defaultFlags(ItemFlag.HIDE_ENCHANTS)
|
.defaultFlags(ItemFlag.HIDE_ENCHANTS)
|
||||||
.defaultName("&f默认玩家前缀")
|
.defaultName("&f默认玩家前缀")
|
||||||
.defaultLore("", "&a✔ 您正在使用该前缀")
|
.defaultLore("", "{&f&o }#description#{1,1}", "&a✔ 您正在使用该前缀")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
package cc.carm.plugin.userprefix.conf;
|
package cc.carm.plugin.userprefix.conf;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.core.ConfigurationRoot;
|
import cc.carm.lib.configuration.Configuration;
|
||||||
import cc.carm.lib.configuration.core.annotation.HeaderComment;
|
import cc.carm.lib.configuration.annotation.HeaderComments;
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessageList;
|
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessage;
|
||||||
|
|
||||||
public class PluginMessages extends ConfigurationRoot {
|
public class PluginMessages implements Configuration {
|
||||||
|
|
||||||
public static final class COMMAND_USAGE extends ConfigurationRoot {
|
public static final class COMMAND_USAGE implements Configuration {
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> CONSOLE = ConfiguredMessageList.asStrings().defaults(
|
public static final ConfiguredMessage<String> CONSOLE = ConfiguredMessage.asString().defaults(
|
||||||
"&f请输入 &b/prefix <玩家ID> &f为指定玩家打开前缀GUI。"
|
"&f请输入 &b/prefix <玩家ID> &f为指定玩家打开前缀GUI。"
|
||||||
).build();
|
).build();
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> ADMIN = ConfiguredMessageList.asStrings().defaults(
|
public static final ConfiguredMessage<String> ADMIN = ConfiguredMessage.asString().defaults(
|
||||||
"&3&l用户前缀系统 &f帮助",
|
"&3&l用户前缀系统 &f帮助",
|
||||||
"&8# &f/upa list",
|
"&8# &f/upa list",
|
||||||
"&8- &7查看当前前缀列表。",
|
"&8- &7查看当前前缀列表。",
|
||||||
@@ -23,52 +23,52 @@ public class PluginMessages extends ConfigurationRoot {
|
|||||||
"&8- &7重载前缀配置。"
|
"&8- &7重载前缀配置。"
|
||||||
).build();
|
).build();
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> NO_PERM = ConfiguredMessageList.asStrings()
|
public static final ConfiguredMessage<String> NO_PERM = ConfiguredMessage.asString()
|
||||||
.defaults("&c&l抱歉!&f但您没有权限使用该指令。")
|
.defaults("&c&l抱歉!&f但您没有权限使用该指令。")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> NOT_ONLINE = ConfiguredMessageList.asStrings()
|
public static final ConfiguredMessage<String> NOT_ONLINE = ConfiguredMessage.asString()
|
||||||
.defaults("&7玩家 &b%(player) &7并不在线。")
|
.defaults("&7玩家 &b%(player) &7并不在线。")
|
||||||
.params("player").build();
|
.params("player").build();
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> SELECTED = ConfiguredMessageList.asStrings()
|
public static final ConfiguredMessage<String> SELECTED = ConfiguredMessage.asString()
|
||||||
.defaults("&7您选择了 &f%(name) &7作为当前显示的前缀。")
|
.defaults("&7您选择了 &f%(name) &7作为当前显示的前缀。")
|
||||||
.params("name").build();
|
.params("name").build();
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> EXPIRED = ConfiguredMessageList.asStrings()
|
public static final ConfiguredMessage<String> EXPIRED = ConfiguredMessage.asString()
|
||||||
.defaults(
|
.defaults(
|
||||||
"&7您先前使用的前缀 &f%(oldName) &7已到期。",
|
"&7您先前使用的前缀 &f%(oldName) &7已到期。",
|
||||||
"&7现在已为您重新调整为 &f%(newName) &7。"
|
"&7现在已为您重新调整为 &f%(newName) &7。"
|
||||||
).params("oldName", "newName").build();
|
).params("oldName", "newName").build();
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> REMOVED = ConfiguredMessageList.asStrings()
|
public static final ConfiguredMessage<String> REMOVED = ConfiguredMessage.asString()
|
||||||
.defaults("&7您先前使用的前缀已被移除,现在已为您重新调整为 &f%(newName) &7。")
|
.defaults("&7您先前使用的前缀已被移除,现在已为您重新调整为 &f%(newName) &7。")
|
||||||
.params("newName").build();
|
.params("newName").build();
|
||||||
|
|
||||||
public static final class RELOAD extends ConfigurationRoot {
|
public static final class RELOAD implements Configuration {
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> SUCCESS = ConfiguredMessageList.asStrings()
|
public static final ConfiguredMessage<String> SUCCESS = ConfiguredMessage.asString()
|
||||||
.defaults("&a&l重载完成!&7耗时 &f%(time)ms&7,共加载了 &b%(count) &7个前缀。")
|
.defaults("&a&l重载完成!&7耗时 &f%(time)ms&7,共加载了 &b%(count) &7个前缀。")
|
||||||
.params("time", "count").build();
|
.params("time", "count").build();
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> FAILED = ConfiguredMessageList.asStrings()
|
public static final ConfiguredMessage<String> FAILED = ConfiguredMessage.asString()
|
||||||
.defaults("&c&l重载出错!&7错误提示为 &8“&r%(error)&8”。")
|
.defaults("&c&l重载出错!&7错误提示为 &8“&r%(error)&8”。")
|
||||||
.params("error").build();
|
.params("error").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class SET extends ConfigurationRoot {
|
public static final class SET implements Configuration {
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> SUCCESS = ConfiguredMessageList.asStrings()
|
public static final ConfiguredMessage<String> SUCCESS = ConfiguredMessage.asString()
|
||||||
.defaults("&a&l设置成功!&7成功设定玩家 &b%(player) &f的前缀为 &r%(prefix) &f。")
|
.defaults("&a&l设置成功!&7成功设定玩家 &b%(player) &f的前缀为 &r%(prefix) &f。")
|
||||||
.params("player", "prefix").build();
|
.params("player", "prefix").build();
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> PREFIX_NOT_FOUND = ConfiguredMessageList.asStrings()
|
public static final ConfiguredMessage<String> PREFIX_NOT_FOUND = ConfiguredMessage.asString()
|
||||||
.defaults("&c&l无法设置!&7不存在ID为 &b%(prefix) &7的前缀。")
|
.defaults("&c&l无法设置!&7不存在ID为 &b%(prefix) &7的前缀。")
|
||||||
.params("prefix").build();
|
.params("prefix").build();
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> NO_PERM = ConfiguredMessageList.asStrings()
|
public static final ConfiguredMessage<String> NO_PERM = ConfiguredMessage.asString()
|
||||||
.defaults("&c&l无法设置!&7玩家 &b%(player) &7并没有前缀 &r%(prefix) &7的前缀。")
|
.defaults("&c&l无法设置!&7玩家 &b%(player) &7并没有前缀 &r%(prefix) &7的前缀。")
|
||||||
.params("player", "prefix")
|
.params("player", "prefix")
|
||||||
.build();
|
.build();
|
||||||
@@ -76,13 +76,13 @@ public class PluginMessages extends ConfigurationRoot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@HeaderComment("管理员使用的 “/upa list” 指令的格式")
|
@HeaderComments("管理员使用的 “/upa list” 指令的格式")
|
||||||
public static final class LIST extends ConfigurationRoot {
|
public static final class LIST implements Configuration {
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> HEADER = ConfiguredMessageList.asStrings()
|
public static final ConfiguredMessage<String> HEADER = ConfiguredMessage.asString()
|
||||||
.defaults("&3&l用户前缀系统 &f前缀列表").build();
|
.defaults("&3&l用户前缀系统 &f前缀列表").build();
|
||||||
|
|
||||||
public static ConfiguredMessageList<String> VALUE = ConfiguredMessageList.asStrings().defaults(
|
public static final ConfiguredMessage<String> VALUE = ConfiguredMessage.asString().defaults(
|
||||||
"&8#%(weight) &f%(identifier)",
|
"&8#%(weight) &f%(identifier)",
|
||||||
"&8- &7显示名 &r%(name) &7权限 &r%(permission)",
|
"&8- &7显示名 &r%(name) &7权限 &r%(permission)",
|
||||||
"&8- &7内容示例&r %(content) %(sender_name)"
|
"&8- &7内容示例&r %(content) %(sender_name)"
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package cc.carm.plugin.userprefix.conf.gui;
|
package cc.carm.plugin.userprefix.conf.gui;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
|
import cc.carm.lib.configuration.source.section.ConfigureSection;
|
||||||
import cc.carm.lib.easyplugin.gui.configuration.GUIActionConfiguration;
|
import cc.carm.lib.easyplugin.gui.configuration.GUIActionConfiguration;
|
||||||
import cc.carm.lib.easyplugin.gui.configuration.GUIActionType;
|
import cc.carm.lib.easyplugin.gui.configuration.GUIActionType;
|
||||||
import cc.carm.lib.easyplugin.gui.configuration.GUIConfiguration;
|
import cc.carm.lib.easyplugin.gui.configuration.GUIConfiguration;
|
||||||
import cc.carm.lib.easyplugin.gui.configuration.GUIItemConfiguration;
|
import cc.carm.lib.easyplugin.gui.configuration.GUIItemConfiguration;
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.source.CraftSectionWrapper;
|
import cc.carm.lib.mineconfiguration.bukkit.source.BukkitSection;
|
||||||
|
import cc.carm.plugin.userprefix.Main;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -33,10 +34,15 @@ public class GUIItems {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GUIItems parse(ConfigurationWrapper<?> section) {
|
public static GUIItems parse(ConfigureSection section) {
|
||||||
if (!(section instanceof CraftSectionWrapper)) return new GUIItems(new LinkedHashMap<>());
|
if (!(section instanceof BukkitSection)) {
|
||||||
CraftSectionWrapper craft = (CraftSectionWrapper) section;
|
Main.severe("Unknown configure source, it should never happened!");
|
||||||
return new GUIItems(GUIConfiguration.readItems(craft.getSource()));
|
Main.severe("Required: " + BukkitSection.class.getSimpleName());
|
||||||
|
Main.severe("Found: " + section.getClass().getSimpleName());
|
||||||
|
return new GUIItems(new LinkedHashMap<>());
|
||||||
|
}
|
||||||
|
BukkitSection craft = (BukkitSection) section;
|
||||||
|
return new GUIItems(GUIConfiguration.readItems(craft.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GUIItems defaults() {
|
public static GUIItems defaults() {
|
||||||
|
|||||||
@@ -1,22 +1,35 @@
|
|||||||
package cc.carm.plugin.userprefix.conf.prefix;
|
package cc.carm.plugin.userprefix.conf.prefix;
|
||||||
|
|
||||||
import cc.carm.lib.easyplugin.gui.configuration.GUIActionConfiguration;
|
import cc.carm.lib.easyplugin.gui.configuration.GUIActionConfiguration;
|
||||||
|
import cc.carm.lib.easyplugin.gui.configuration.GUIActionType;
|
||||||
import cc.carm.lib.easyplugin.utils.ColorParser;
|
import cc.carm.lib.easyplugin.utils.ColorParser;
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.data.ItemConfig;
|
import cc.carm.lib.easyplugin.utils.MessageUtils;
|
||||||
|
import cc.carm.lib.mineconfiguration.bukkit.value.item.PreparedItem;
|
||||||
|
import cc.carm.plugin.userprefix.Main;
|
||||||
import cc.carm.plugin.userprefix.manager.ServiceManager;
|
import cc.carm.plugin.userprefix.manager.ServiceManager;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class PrefixConfig {
|
public class PrefixConfig {
|
||||||
|
|
||||||
|
static final Random RANDOM = new Random();
|
||||||
|
|
||||||
protected final @NotNull String identifier;
|
protected final @NotNull String identifier;
|
||||||
|
|
||||||
protected final @NotNull String name;
|
protected final @NotNull String name;
|
||||||
protected final @NotNull String content;
|
protected final @NotNull List<String> content;
|
||||||
|
protected final @NotNull List<String> description;
|
||||||
|
|
||||||
|
protected final long period; // 内容变更周期,单位为毫秒
|
||||||
|
|
||||||
protected final int weight;
|
protected final int weight;
|
||||||
|
|
||||||
@@ -24,19 +37,50 @@ public class PrefixConfig {
|
|||||||
|
|
||||||
protected final @NotNull List<GUIActionConfiguration> actions;
|
protected final @NotNull List<GUIActionConfiguration> actions;
|
||||||
|
|
||||||
protected final @NotNull ItemConfig itemHasPermission;
|
protected final @NotNull ItemStack itemHasPermission;
|
||||||
protected final @Nullable ItemConfig itemNoPermission;
|
protected final @Nullable ItemStack itemNoPermission;
|
||||||
protected final @Nullable ItemConfig itemWhenUsing;
|
protected final @Nullable ItemStack itemWhenUsing;
|
||||||
|
|
||||||
public PrefixConfig(@NotNull String identifier, @NotNull String name,
|
public PrefixConfig(@NotNull String identifier, @NotNull String name,
|
||||||
@NotNull String content, int weight, @Nullable String permission,
|
@NotNull String content, int weight, @Nullable String permission,
|
||||||
@NotNull List<GUIActionConfiguration> actions,
|
@NotNull List<GUIActionConfiguration> actions,
|
||||||
@NotNull ItemConfig itemHasPermission,
|
@NotNull ItemStack itemHasPermission,
|
||||||
@Nullable ItemConfig itemWhenUsing,
|
@Nullable ItemStack itemWhenUsing,
|
||||||
@Nullable ItemConfig itemNoPermission) {
|
@Nullable ItemStack itemNoPermission) {
|
||||||
|
this(
|
||||||
|
identifier, name, new ArrayList<>(),
|
||||||
|
content, weight, permission, actions,
|
||||||
|
itemHasPermission, itemWhenUsing, itemNoPermission
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrefixConfig(@NotNull String identifier,
|
||||||
|
@NotNull String name, @NotNull List<String> description,
|
||||||
|
@NotNull String content, int weight, @Nullable String permission,
|
||||||
|
@NotNull List<GUIActionConfiguration> actions,
|
||||||
|
@NotNull ItemStack itemHasPermission,
|
||||||
|
@Nullable ItemStack itemWhenUsing,
|
||||||
|
@Nullable ItemStack itemNoPermission) {
|
||||||
|
this(
|
||||||
|
identifier, name, description,
|
||||||
|
Collections.singletonList(content), 0, weight, permission, actions,
|
||||||
|
itemHasPermission, itemWhenUsing, itemNoPermission
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrefixConfig(@NotNull String identifier,
|
||||||
|
@NotNull String name, @NotNull List<String> description,
|
||||||
|
@NotNull List<String> content, long period,
|
||||||
|
int weight, @Nullable String permission,
|
||||||
|
@NotNull List<GUIActionConfiguration> actions,
|
||||||
|
@NotNull ItemStack itemHasPermission,
|
||||||
|
@Nullable ItemStack itemWhenUsing,
|
||||||
|
@Nullable ItemStack itemNoPermission) {
|
||||||
this.identifier = identifier;
|
this.identifier = identifier;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
this.content = content;
|
this.content = content;
|
||||||
|
this.period = period;
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
this.actions = actions;
|
this.actions = actions;
|
||||||
@@ -52,12 +96,31 @@ public class PrefixConfig {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return ColorParser.parse(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getContent() {
|
public List<String> getDescription() {
|
||||||
return ColorParser.parse(content);
|
return ColorParser.parse(description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getContent(CommandSender viewer) {
|
||||||
|
if (content.isEmpty()) return "?";
|
||||||
|
if (period < 0 || content.size() == 1) {
|
||||||
|
return ColorParser.parse(MessageUtils.setPlaceholders(viewer, content.get(0)));
|
||||||
|
}
|
||||||
|
if (period == 0) {
|
||||||
|
// PERIOD 为0时,随机返回一个内容
|
||||||
|
int index = RANDOM.nextInt(content.size());
|
||||||
|
return ColorParser.parse(MessageUtils.setPlaceholders(viewer, content.get(index)));
|
||||||
|
} else {
|
||||||
|
// 可变化的内容,则基于偏移量与时间戳计算目标index
|
||||||
|
long curr = System.currentTimeMillis();
|
||||||
|
long offset = curr % period; // 计算偏移量
|
||||||
|
int index = (int) (offset / (period / content.size())); // 计算索引
|
||||||
|
return ColorParser.parse(MessageUtils.setPlaceholders(viewer, content.get(index)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWeight() {
|
public int getWeight() {
|
||||||
@@ -71,27 +134,55 @@ public class PrefixConfig {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ItemStack getItemHasPermission(@Nullable Player player) {
|
public ItemStack getItemHasPermission(@Nullable Player player) {
|
||||||
return this.itemHasPermission.getItemStack(player);
|
return getItem(player, this.itemHasPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ItemStack getItemNoPermission(@Nullable Player player) {
|
public ItemStack getItemNoPermission(@Nullable Player player) {
|
||||||
if (this.itemNoPermission == null) return null;
|
return getItem(player, this.itemNoPermission);
|
||||||
return this.itemNoPermission.getItemStack(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ItemStack getItemWhenUsing(@Nullable Player player) {
|
public ItemStack getItemWhenUsing(@Nullable Player player) {
|
||||||
if (this.itemWhenUsing == null) return null;
|
return getItem(player, this.itemWhenUsing);
|
||||||
else return this.itemWhenUsing.getItemStack(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Contract("_,!null->!null")
|
||||||
|
protected @Nullable ItemStack getItem(@Nullable Player player, @Nullable ItemStack item) {
|
||||||
|
PreparedItem prepared = PreparedItem.of(item);
|
||||||
|
|
||||||
|
prepared.parser((p, s) -> ColorParser.parse(MessageUtils.setPlaceholders(p, s)));
|
||||||
|
|
||||||
|
if (!getDescription().isEmpty()) {
|
||||||
|
prepared.insert("description", getDescription());
|
||||||
|
prepared.placeholder("description", String.join("\n", getDescription()));
|
||||||
|
}
|
||||||
|
|
||||||
|
prepared.placeholder("name", getName());
|
||||||
|
prepared.placeholder("identifier", getIdentifier());
|
||||||
|
prepared.placeholder("content", getContent(player));
|
||||||
|
prepared.placeholder("permission", getPermission());
|
||||||
|
prepared.placeholder("weight", String.valueOf(getWeight()));
|
||||||
|
prepared.placeholder("hasPermission", String.valueOf(checkPermission(player)));
|
||||||
|
prepared.placeholder("public", String.valueOf(isPublic()));
|
||||||
|
prepared.placeholder("visible", String.valueOf(isVisible(player)));
|
||||||
|
|
||||||
|
return prepared.get(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isPublic() {
|
public boolean isPublic() {
|
||||||
return getPermission() == null;
|
return getPermission() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeActions(@NotNull Player player) {
|
public void executeActions(@NotNull Player player) {
|
||||||
this.actions.forEach(action -> action.executeAction(player));
|
this.actions.forEach(action -> {
|
||||||
|
if (action.getActionType() == GUIActionType.CONSOLE) { // 控制台执行命令必须在全局调度器中执行
|
||||||
|
Main.getInstance().getFoliaScheduler().runGlobal(false, () -> action.executeAction(player));
|
||||||
|
} else {
|
||||||
|
action.executeAction(player);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVisible(Player player) {
|
public boolean isVisible(Player player) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cc.carm.plugin.userprefix.event;
|
|||||||
|
|
||||||
import cc.carm.plugin.userprefix.Main;
|
import cc.carm.plugin.userprefix.Main;
|
||||||
import cc.carm.plugin.userprefix.conf.prefix.PrefixConfig;
|
import cc.carm.plugin.userprefix.conf.prefix.PrefixConfig;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@@ -61,8 +62,11 @@ public class UserPrefixChangeEvent extends UserPrefixEvent implements Cancellabl
|
|||||||
@Nullable PrefixConfig before,
|
@Nullable PrefixConfig before,
|
||||||
@NotNull PrefixConfig after,
|
@NotNull PrefixConfig after,
|
||||||
@Nullable Consumer<@Nullable PrefixConfig> finish) {
|
@Nullable Consumer<@Nullable PrefixConfig> finish) {
|
||||||
Main.getInstance().callSync(new UserPrefixChangeEvent(who, before, after))
|
UserPrefixChangeEvent event = new UserPrefixChangeEvent(who, before, after);
|
||||||
.thenAccept((e) -> Optional.ofNullable(finish).ifPresent(f -> f.accept(e.getAfter())));
|
Main.getInstance().getFoliaScheduler().runGlobal(true, () -> {
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
Optional.ofNullable(finish).ifPresent(f -> f.accept(event.getAfter()));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cc.carm.plugin.userprefix.event;
|
|||||||
|
|
||||||
import cc.carm.plugin.userprefix.Main;
|
import cc.carm.plugin.userprefix.Main;
|
||||||
import cc.carm.plugin.userprefix.conf.prefix.PrefixConfig;
|
import cc.carm.plugin.userprefix.conf.prefix.PrefixConfig;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -30,7 +31,7 @@ public class UserPrefixExpireEvent extends UserPrefixEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void call(@NotNull Player player, @NotNull PrefixConfig currentPrefix) {
|
public static void call(@NotNull Player player, @NotNull PrefixConfig currentPrefix) {
|
||||||
Main.getInstance().callSync(new UserPrefixExpireEvent(player, currentPrefix));
|
Main.getInstance().getFoliaScheduler().runGlobal(true, () -> Bukkit.getPluginManager().callEvent(new UserPrefixExpireEvent(player, currentPrefix)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package cc.carm.plugin.userprefix.folia;
|
||||||
|
|
||||||
|
import cc.carm.plugin.userprefix.Main;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class FoliaScheduler {
|
||||||
|
private final Main plugin;
|
||||||
|
private final boolean folia;
|
||||||
|
|
||||||
|
public FoliaScheduler(Main plugin, boolean folia) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.folia = folia;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runAsync(Runnable task) {
|
||||||
|
if (this.folia) {
|
||||||
|
this.runAsyncFolia(task);
|
||||||
|
} else {
|
||||||
|
this.runAsyncBukkit(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runAsyncBukkit(Runnable task) {
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, task);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runAsyncFolia(Runnable task) {
|
||||||
|
// AsyncScheduler asyncScheduler = Bukkit.getAsyncScheduler();
|
||||||
|
// asyncScheduler.runNow(this.plugin, t -> task.run());
|
||||||
|
|
||||||
|
try {
|
||||||
|
Object asyncScheduler = Bukkit.class.getMethod("getAsyncScheduler")
|
||||||
|
.invoke(null);
|
||||||
|
asyncScheduler.getClass().getMethod("runNow", Plugin.class, Consumer.class)
|
||||||
|
.invoke(asyncScheduler, this.plugin, (Consumer<?>) t -> task.run());
|
||||||
|
} catch (IllegalAccessException | NoSuchMethodException e) {
|
||||||
|
Main.severe("unexpected exception during reflection (#runAsyncFolia), it should never happen!");
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
throw (RuntimeException) e.getTargetException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Folia 上在实体所在的调度器上执行任务,或在 Bukkit 上同步执行任务
|
||||||
|
*
|
||||||
|
* @param entity 实体
|
||||||
|
* @param forceSync 若为 true,Bukkit 下强制同步运行;若为 false,Bukkit 下直接执行
|
||||||
|
* @param task 任务
|
||||||
|
* @see FoliaScheduler#runBukkit(boolean, Runnable)
|
||||||
|
* @see FoliaScheduler#runOnEntityFolia(Entity, Runnable)
|
||||||
|
*/
|
||||||
|
public void runOnEntity(Entity entity, boolean forceSync, Runnable task) {
|
||||||
|
if (this.folia) {
|
||||||
|
this.runOnEntityFolia(entity, task);
|
||||||
|
} else {
|
||||||
|
this.runBukkit(forceSync, task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runOnEntityFolia(Entity entity, Runnable task) {
|
||||||
|
// EntityScheduler entityScheduler = entity.getScheduler();
|
||||||
|
// entityScheduler.run(this.plugin, t -> task.run(), null);
|
||||||
|
try {
|
||||||
|
Object entityScheduler = Entity.class.getMethod("getScheduler")
|
||||||
|
.invoke(entity);
|
||||||
|
entityScheduler.getClass().getMethod("run", Plugin.class, Consumer.class, Runnable.class)
|
||||||
|
.invoke(entityScheduler, this.plugin, (Consumer<?>) t -> task.run(), null);
|
||||||
|
} catch (IllegalAccessException | NoSuchMethodException e) {
|
||||||
|
Main.severe("unexpected exception during reflection (#runOnEntityFolia), it should never happen!");
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
throw (RuntimeException) e.getTargetException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Folia 上在全局调度器上执行任务,或在 Bukkit 上同步执行任务
|
||||||
|
*
|
||||||
|
* @param forceSync 若为 true,Bukkit 下强制同步运行;若为 false,Bukkit 下直接执行
|
||||||
|
* @param task 任务
|
||||||
|
* @see FoliaScheduler#runBukkit(boolean, Runnable)
|
||||||
|
* @see FoliaScheduler#runGlobalFolia(Runnable)
|
||||||
|
*/
|
||||||
|
public void runGlobal(boolean forceSync, Runnable task) {
|
||||||
|
if (this.folia) {
|
||||||
|
this.runGlobalFolia(task);
|
||||||
|
} else {
|
||||||
|
this.runBukkit(forceSync, task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runGlobalFolia(Runnable task) {
|
||||||
|
// GlobalRegionScheduler globalRegionScheduler = Bukkit.getGlobalRegionScheduler();
|
||||||
|
// globalRegionScheduler.execute(this.plugin, task);
|
||||||
|
try {
|
||||||
|
Object globalRegionScheduler = Bukkit.class.getMethod("getGlobalRegionScheduler")
|
||||||
|
.invoke(null);
|
||||||
|
globalRegionScheduler.getClass().getMethod("execute", Plugin.class, Runnable.class)
|
||||||
|
.invoke(globalRegionScheduler, this.plugin, task);
|
||||||
|
} catch (IllegalAccessException | NoSuchMethodException e) {
|
||||||
|
Main.severe("unexpected exception during reflection (#runGlobalFolia), it should never happen!");
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
throw (RuntimeException) e.getTargetException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runBukkit(boolean forceSync, Runnable task) {
|
||||||
|
if (forceSync) {
|
||||||
|
Bukkit.getScheduler().runTask(this.plugin, task);
|
||||||
|
} else {
|
||||||
|
task.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package cc.carm.plugin.userprefix.folia;
|
||||||
|
|
||||||
|
import cc.carm.plugin.userprefix.Main;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
|
||||||
|
public interface MajorUtil {
|
||||||
|
static Enchantment getEnchantProtection() {
|
||||||
|
Class<Enchantment> enchantmentClass = Enchantment.class;
|
||||||
|
try {
|
||||||
|
return (Enchantment) enchantmentClass.getField("PROTECTION_ENVIRONMENTAL").get(null);
|
||||||
|
} catch (NoSuchFieldException e1) {
|
||||||
|
try {
|
||||||
|
return (Enchantment) enchantmentClass.getField("PROTECTION").get(null);
|
||||||
|
} catch (NoSuchFieldException | IllegalAccessException e2) {
|
||||||
|
Main.severe("unexpected exception during reflection (#getEnchantProtection), it should never happen!");
|
||||||
|
throw new RuntimeException(e2);
|
||||||
|
}
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
Main.severe("unexpected exception during reflection (#getEnchantProtection), it should never happen!");
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,7 @@ public class UserPrefixExpansion extends EasyPlaceholder {
|
|||||||
handle("identifier", handlePrefix(PrefixConfig::getIdentifier), "id");
|
handle("identifier", handlePrefix(PrefixConfig::getIdentifier), "id");
|
||||||
handle("prefix", handlePrefix(PrefixConfig::getContent));
|
handle("prefix", handlePrefix(PrefixConfig::getContent));
|
||||||
handle("name", handlePrefix(PrefixConfig::getName));
|
handle("name", handlePrefix(PrefixConfig::getName));
|
||||||
|
handle("description", handlePrefix(p -> String.join("\n", p.getDescription())));
|
||||||
handle("weight", handlePrefix(PrefixConfig::getWeight));
|
handle("weight", handlePrefix(PrefixConfig::getWeight));
|
||||||
handle("amount", handlePlayer(
|
handle("amount", handlePlayer(
|
||||||
(player) -> UserPrefixAPI.getUserManager().getUsablePrefixes(player).size() + 1)
|
(player) -> UserPrefixAPI.getUserManager().getUsablePrefixes(player).size() + 1)
|
||||||
@@ -43,6 +44,18 @@ public class UserPrefixExpansion extends EasyPlaceholder {
|
|||||||
return handlePlayer((player, args) -> handler.apply(UserPrefixAPI.getUserManager().getPrefix(player)));
|
return handlePlayer((player, args) -> handler.apply(UserPrefixAPI.getUserManager().getPrefix(player)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlaceholderHandler handlePrefix(BiFunction<PrefixConfig, Player, Object> handler) {
|
||||||
|
return handlePlayer((player, args) -> handler.apply(UserPrefixAPI.getUserManager().getPrefix(player), player));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is required or else PlaceholderAPI will unregister the Expansion on reload
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean persist() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public PlaceholderHandler handlePlayer(BiFunction<Player, String[], Object> handler) {
|
public PlaceholderHandler handlePlayer(BiFunction<Player, String[], Object> handler) {
|
||||||
return (player, args) -> {
|
return (player, args) -> {
|
||||||
if (player == null || !player.isOnline()) return "Loading...";
|
if (player == null || !player.isOnline()) return "Loading...";
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class UserPermListener {
|
|||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
UserPrefixAPI.getUserManager().checkPrefix(player, true);
|
UserPrefixAPI.getUserManager().checkPrefix(player, true);
|
||||||
if (PrefixSelectGUI.openingUsers.contains(player)) {
|
if (PrefixSelectGUI.openingUsers.contains(player)) {
|
||||||
Main.getInstance().getScheduler().run(() -> {
|
Main.getInstance().getFoliaScheduler().runOnEntity(player, true, () -> {
|
||||||
// 玩家权限更新,同步关闭其GUI,以令其重新打开刷新自己的前缀。
|
// 玩家权限更新,同步关闭其GUI,以令其重新打开刷新自己的前缀。
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
PrefixSelectGUI.removeOpening(player);
|
PrefixSelectGUI.removeOpening(player);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package cc.carm.plugin.userprefix.manager;
|
package cc.carm.plugin.userprefix.manager;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.source.ConfigurationHolder;
|
||||||
import cc.carm.lib.easyplugin.utils.JarResourceUtils;
|
import cc.carm.lib.easyplugin.utils.JarResourceUtils;
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.MineConfiguration;
|
import cc.carm.lib.mineconfiguration.bukkit.MineConfiguration;
|
||||||
import cc.carm.plugin.userprefix.conf.PluginConfig;
|
import cc.carm.plugin.userprefix.conf.PluginConfig;
|
||||||
@@ -11,13 +11,13 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
|
|
||||||
private final ConfigurationProvider<?> configProvider;
|
private final ConfigurationHolder<?> configProvider;
|
||||||
private final ConfigurationProvider<?> messageProvider;
|
private final ConfigurationHolder<?> messageProvider;
|
||||||
|
|
||||||
public ConfigManager(File dataFolder) {
|
public ConfigManager(File dataFolder) {
|
||||||
firstInitialize(dataFolder);
|
firstInitialize(dataFolder);
|
||||||
this.configProvider = MineConfiguration.from(new File(dataFolder, "config.yml"));
|
this.configProvider = MineConfiguration.from(new File(dataFolder, "config.yml"), null);
|
||||||
this.messageProvider = MineConfiguration.from(new File(dataFolder, "messages.yml"));
|
this.messageProvider = MineConfiguration.from(new File(dataFolder, "messages.yml"), null);
|
||||||
this.configProvider.initialize(PluginConfig.class);
|
this.configProvider.initialize(PluginConfig.class);
|
||||||
this.messageProvider.initialize(PluginMessages.class);
|
this.messageProvider.initialize(PluginMessages.class);
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ public class ConfigManager {
|
|||||||
File configFile = new File(dataFolder, "config.yml");
|
File configFile = new File(dataFolder, "config.yml");
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
try {
|
try {
|
||||||
JarResourceUtils.copyFolderFromJar("en_US", dataFolder, JarResourceUtils.CopyOption.COPY_IF_NOT_EXIST);
|
JarResourceUtils.copyFolderFromJar("i18n", dataFolder, JarResourceUtils.CopyOption.COPY_IF_NOT_EXIST);
|
||||||
JarResourceUtils.copyFolderFromJar("prefixes", dataFolder, JarResourceUtils.CopyOption.COPY_IF_NOT_EXIST);
|
JarResourceUtils.copyFolderFromJar("prefixes", dataFolder, JarResourceUtils.CopyOption.COPY_IF_NOT_EXIST);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -35,11 +35,11 @@ public class ConfigManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigurationProvider<?> getConfigProvider() {
|
public ConfigurationHolder<?> getConfigProvider() {
|
||||||
return configProvider;
|
return configProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigurationProvider<?> getMessageProvider() {
|
public ConfigurationHolder<?> getMessageProvider() {
|
||||||
return messageProvider;
|
return messageProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
package cc.carm.plugin.userprefix.manager;
|
package cc.carm.plugin.userprefix.manager;
|
||||||
|
|
||||||
import cc.carm.lib.easyplugin.gui.configuration.GUIActionConfiguration;
|
import cc.carm.lib.easyplugin.gui.configuration.GUIActionConfiguration;
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.data.ItemConfig;
|
import cc.carm.lib.easyplugin.utils.ItemStackFactory;
|
||||||
import cc.carm.plugin.userprefix.Main;
|
import cc.carm.plugin.userprefix.Main;
|
||||||
import cc.carm.plugin.userprefix.conf.PluginConfig;
|
import cc.carm.plugin.userprefix.conf.PluginConfig;
|
||||||
import cc.carm.plugin.userprefix.conf.prefix.PrefixConfig;
|
import cc.carm.plugin.userprefix.conf.prefix.PrefixConfig;
|
||||||
|
import com.cryptomorin.xseries.XItemStack;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -75,13 +77,14 @@ public class PrefixManager {
|
|||||||
this.defaultPrefix = new PrefixConfig(
|
this.defaultPrefix = new PrefixConfig(
|
||||||
"default",
|
"default",
|
||||||
PluginConfig.DEFAULT_PREFIX.NAME.getNotNull(),
|
PluginConfig.DEFAULT_PREFIX.NAME.getNotNull(),
|
||||||
PluginConfig.DEFAULT_PREFIX.CONTENT.getNotNull(),
|
PluginConfig.DEFAULT_PREFIX.DESCRIPTION.getNotNull(),
|
||||||
|
PluginConfig.DEFAULT_PREFIX.CONTENT.resolve(),
|
||||||
|
PluginConfig.DEFAULT_PREFIX.PERIOD.resolve(),
|
||||||
PluginConfig.DEFAULT_PREFIX.WEIGHT.getNotNull(),
|
PluginConfig.DEFAULT_PREFIX.WEIGHT.getNotNull(),
|
||||||
null,
|
null,
|
||||||
readActions(PluginConfig.DEFAULT_PREFIX.ACTIONS.get()),
|
readActions(PluginConfig.DEFAULT_PREFIX.ACTIONS.get()),
|
||||||
PluginConfig.DEFAULT_PREFIX.ITEM.NOT_USING.getNotNull(),
|
PluginConfig.DEFAULT_PREFIX.ITEM.NOT_USING.getNotNull(),
|
||||||
PluginConfig.DEFAULT_PREFIX.ITEM.USING.get(),
|
PluginConfig.DEFAULT_PREFIX.ITEM.USING.get(), null
|
||||||
null
|
|
||||||
);
|
);
|
||||||
Main.debugging(" 完成默认前缀加载 " + defaultPrefix.getName());
|
Main.debugging(" 完成默认前缀加载 " + defaultPrefix.getName());
|
||||||
}
|
}
|
||||||
@@ -124,34 +127,50 @@ public class PrefixManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull PrefixConfig addPrefix(@NotNull File file) throws Exception {
|
public static @NotNull PrefixConfig addPrefix(@NotNull File file) throws Exception {
|
||||||
FileConfiguration configuration = YamlConfiguration.loadConfiguration(file);
|
FileConfiguration conf = YamlConfiguration.loadConfiguration(file);
|
||||||
String identifier = configuration.getString("identifier");
|
String identifier = conf.getString("identifier");
|
||||||
if (identifier == null)
|
if (identifier == null)
|
||||||
throw new Exception("配置文件 " + file.getAbsolutePath() + " 中没有配置前缀的唯一标识。");
|
throw new Exception("配置文件 " + file.getAbsolutePath() + " 中没有配置前缀的唯一标识。");
|
||||||
|
|
||||||
String name = configuration.getString("name");
|
String name = conf.getString("name");
|
||||||
if (name == null) throw new Exception("配置文件 " + file.getAbsolutePath() + " 中没有配置前缀的显示名称。");
|
if (name == null) throw new Exception("配置文件 " + file.getAbsolutePath() + " 中没有配置前缀的显示名称。");
|
||||||
|
|
||||||
|
|
||||||
|
List<String> content = new ArrayList<>();
|
||||||
|
if (conf.isList("content")) {
|
||||||
|
content = conf.getStringList("content");
|
||||||
|
} else {
|
||||||
|
String single = conf.getString("content");
|
||||||
|
if (single != null) content.add(single);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return new PrefixConfig(
|
return new PrefixConfig(
|
||||||
identifier, name,
|
identifier, name,
|
||||||
configuration.getString("content", "&r"),
|
conf.getStringList("description"),
|
||||||
configuration.getInt("weight", 1),
|
content,
|
||||||
configuration.getString("permission"),
|
conf.getLong("period", -1L),
|
||||||
readActions(configuration.getStringList("actions")),
|
conf.getInt("weight", 1),
|
||||||
|
conf.getString("permission"),
|
||||||
|
readActions(conf.getStringList("actions")),
|
||||||
readItem(
|
readItem(
|
||||||
configuration.getConfigurationSection("item.has-perm"),
|
conf.getConfigurationSection("item.has-perm"),
|
||||||
new ItemConfig(Material.STONE, name, Arrays.asList(" ", "§a➥ 点击切换到该前缀"))
|
new ItemStackFactory(Material.STONE)
|
||||||
|
.setDisplayName(name)
|
||||||
|
.addLore("§a➥ 点击切换到该前缀")
|
||||||
|
.toItemStack()
|
||||||
),
|
),
|
||||||
readItem(configuration.getConfigurationSection("item.using"), null),
|
readItem(conf.getConfigurationSection("item.using"), null),
|
||||||
readItem(configuration.getConfigurationSection("item.no-perm"), null)
|
readItem(conf.getConfigurationSection("item.no-perm"), null)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Contract("_,!null->!null")
|
@Contract("_,!null->!null")
|
||||||
protected static ItemConfig readItem(@Nullable ConfigurationSection section, @Nullable ItemConfig defaultValue) throws Exception {
|
protected static ItemStack readItem(@Nullable ConfigurationSection section,
|
||||||
|
@Nullable ItemStack defaultValue) throws Exception {
|
||||||
if (section == null) return defaultValue;
|
if (section == null) return defaultValue;
|
||||||
else return ItemConfig.deserialize(section);
|
else return XItemStack.deserialize(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static List<GUIActionConfiguration> readActions(@NotNull List<String> strings) {
|
protected static List<GUIActionConfiguration> readActions(@NotNull List<String> strings) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class UserManager {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public UserNameTag getNameTag(Player player) {
|
public UserNameTag getNameTag(Player player) {
|
||||||
if (PluginConfig.FUNCTIONS.NAME_PREFIX.ENABLE.getNotNull()) {
|
if (this.isNamePrefixEnabled()) {
|
||||||
if (nameTags.containsKey(player.getUniqueId())) {
|
if (nameTags.containsKey(player.getUniqueId())) {
|
||||||
return nameTags.get(player.getUniqueId());
|
return nameTags.get(player.getUniqueId());
|
||||||
} else {
|
} else {
|
||||||
@@ -53,7 +53,7 @@ public class UserManager {
|
|||||||
|
|
||||||
public void initPlayer(Player player) {
|
public void initPlayer(Player player) {
|
||||||
checkPrefix(player, false);
|
checkPrefix(player, false);
|
||||||
if (PluginConfig.FUNCTIONS.NAME_PREFIX.ENABLE.getNotNull()) {
|
if (this.isNamePrefixEnabled()) {
|
||||||
createNameTag(player);
|
createNameTag(player);
|
||||||
updatePrefixView(player, true);
|
updatePrefixView(player, true);
|
||||||
}
|
}
|
||||||
@@ -73,14 +73,14 @@ public class UserManager {
|
|||||||
* @param loadOthers 是否为玩家更新其他人的前缀(一般用于加入游戏)
|
* @param loadOthers 是否为玩家更新其他人的前缀(一般用于加入游戏)
|
||||||
*/
|
*/
|
||||||
public void updatePrefixView(Player player, boolean loadOthers) {
|
public void updatePrefixView(Player player, boolean loadOthers) {
|
||||||
if (!PluginConfig.FUNCTIONS.NAME_PREFIX.ENABLE.getNotNull()) return; //未启用的情况下,不需要进行任何操作。
|
if (!this.isNamePrefixEnabled()) return; //未启用的情况下,不需要进行任何操作。
|
||||||
UserNameTag tag = getNameTag(player);
|
UserNameTag tag = getNameTag(player);
|
||||||
if (tag == null) return; //未启用的情况下,不需要进行任何操作。
|
if (tag == null) return; //未启用的情况下,不需要进行任何操作。
|
||||||
|
|
||||||
PrefixConfig playerPrefix = getPrefix(player);
|
PrefixConfig playerPrefix = getPrefix(player);
|
||||||
boolean descOrder = PluginConfig.FUNCTIONS.NAME_PREFIX.ORDER_DESC.getNotNull();
|
boolean descOrder = PluginConfig.FUNCTIONS.NAME_PREFIX.ORDER_DESC.getNotNull();
|
||||||
|
|
||||||
tag.setPrefix(playerPrefix.getContent());
|
tag.setPrefix(playerPrefix.getContent(player));
|
||||||
tag.setOrder(descOrder ? 999 - playerPrefix.getWeight() : playerPrefix.getWeight());
|
tag.setOrder(descOrder ? 999 - playerPrefix.getWeight() : playerPrefix.getWeight());
|
||||||
|
|
||||||
Main.debugging("为玩家 " + player.getName() + " 设置了 " + player.getName() + "的前缀为 #" + playerPrefix.getWeight() + " " + playerPrefix.getName());
|
Main.debugging("为玩家 " + player.getName() + " 设置了 " + player.getName() + "的前缀为 #" + playerPrefix.getWeight() + " " + playerPrefix.getName());
|
||||||
@@ -90,7 +90,7 @@ public class UserManager {
|
|||||||
UserNameTag onlinePlayerTag = getNameTag(onlinePlayer);
|
UserNameTag onlinePlayerTag = getNameTag(onlinePlayer);
|
||||||
|
|
||||||
if (onlinePlayerTag != null) {
|
if (onlinePlayerTag != null) {
|
||||||
onlinePlayerTag.setPrefix(player, playerPrefix.getContent());
|
onlinePlayerTag.setPrefix(player, playerPrefix.getContent(onlinePlayer));
|
||||||
onlinePlayerTag.setOrder(player, descOrder ? 999 - playerPrefix.getWeight() : playerPrefix.getWeight());
|
onlinePlayerTag.setOrder(player, descOrder ? 999 - playerPrefix.getWeight() : playerPrefix.getWeight());
|
||||||
Main.debugging("为玩家 " + onlinePlayer.getName() + " 设置了 " + player.getName() + "的前缀为 #" + playerPrefix.getWeight() + " " + playerPrefix.getName());
|
Main.debugging("为玩家 " + onlinePlayer.getName() + " 设置了 " + player.getName() + "的前缀为 #" + playerPrefix.getWeight() + " " + playerPrefix.getName());
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public class UserManager {
|
|||||||
|
|
||||||
if (loadOthers) {
|
if (loadOthers) {
|
||||||
PrefixConfig onlinePlayerPrefix = getPrefix(onlinePlayer);
|
PrefixConfig onlinePlayerPrefix = getPrefix(onlinePlayer);
|
||||||
tag.setPrefix(onlinePlayer, onlinePlayerPrefix.getContent());
|
tag.setPrefix(onlinePlayer, onlinePlayerPrefix.getContent(player));
|
||||||
tag.setOrder(onlinePlayer, descOrder ? 999 - onlinePlayerPrefix.getWeight() : onlinePlayerPrefix.getWeight());
|
tag.setOrder(onlinePlayer, descOrder ? 999 - onlinePlayerPrefix.getWeight() : onlinePlayerPrefix.getWeight());
|
||||||
Main.debugging("为玩家 " + player.getName() + " 设置了 " + onlinePlayer.getName() + "的前缀为 #" + onlinePlayerPrefix.getWeight() + " " + onlinePlayerPrefix.getName());
|
Main.debugging("为玩家 " + player.getName() + " 设置了 " + onlinePlayer.getName() + "的前缀为 #" + onlinePlayerPrefix.getWeight() + " " + onlinePlayerPrefix.getName());
|
||||||
}
|
}
|
||||||
@@ -131,13 +131,13 @@ public class UserManager {
|
|||||||
UserPrefixExpireEvent.call(player, currentPrefix);
|
UserPrefixExpireEvent.call(player, currentPrefix);
|
||||||
|
|
||||||
// 发送消息
|
// 发送消息
|
||||||
PluginMessages.EXPIRED.send(player, newPrefix.getName(), currentPrefix.getName());
|
PluginMessages.EXPIRED.sendTo(player, currentPrefix.getName(), newPrefix.getName());
|
||||||
|
|
||||||
// 播放声音
|
// 播放声音
|
||||||
PluginConfig.SOUNDS.PREFIX_EXPIRED.playTo(player);
|
PluginConfig.SOUNDS.PREFIX_EXPIRED.playTo(player);
|
||||||
} else {
|
} else {
|
||||||
// 当前前缀为空,则代表是旧的前缀不存在了,
|
// 当前前缀为空,则代表是旧的前缀不存在了,
|
||||||
PluginMessages.REMOVED.send(player, newPrefix.getName(), currentPrefixData);
|
PluginMessages.REMOVED.sendTo(player, newPrefix.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
UserPrefixChangeEvent.call(player, currentPrefix, newPrefix, (after) -> {
|
UserPrefixChangeEvent.call(player, currentPrefix, newPrefix, (after) -> {
|
||||||
@@ -209,7 +209,7 @@ public class UserManager {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public PrefixConfig getHighestPrefix(Player player) {
|
public PrefixConfig getHighestPrefix(Player player) {
|
||||||
if (PluginConfig.FUNCTIONS.AUTO_USE.getNotNull()) {
|
if (!PluginConfig.FUNCTIONS.AUTO_USE.getNotNull()) {
|
||||||
// 关闭了自动选择,就直接给默认的前缀,让玩家自己去设置吧~
|
// 关闭了自动选择,就直接给默认的前缀,让玩家自己去设置吧~
|
||||||
return UserPrefixAPI.getDefaultPrefix();
|
return UserPrefixAPI.getDefaultPrefix();
|
||||||
}
|
}
|
||||||
@@ -273,4 +273,7 @@ public class UserManager {
|
|||||||
user.data().clear(NodeType.META.predicate(mn -> mn.getMetaKey().equals(META_KEY)));
|
user.data().clear(NodeType.META.predicate(mn -> mn.getMetaKey().equals(META_KEY)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isNamePrefixEnabled() {
|
||||||
|
return PluginConfig.FUNCTIONS.NAME_PREFIX.ENABLE.getNotNull() && !Main.getInstance().isOnFolia();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,13 @@ import org.bukkit.event.inventory.ClickType;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class PrefixSelectGUI extends AutoPagedGUI {
|
public class PrefixSelectGUI extends AutoPagedGUI {
|
||||||
|
|
||||||
public static HashSet<Player> openingUsers = new HashSet<>();
|
public static HashSet<Player> openingUsers = new HashSet<>();
|
||||||
|
|
||||||
Player player;
|
protected final Player player;
|
||||||
|
|
||||||
public PrefixSelectGUI(Player player) {
|
public PrefixSelectGUI(Player player) {
|
||||||
super(GUIType.SIX_BY_NINE, PluginConfig.GUI.TITLE.get(), 10, 43);
|
super(GUIType.SIX_BY_NINE, PluginConfig.GUI.TITLE.get(), 10, 43);
|
||||||
@@ -49,7 +50,10 @@ public class PrefixSelectGUI extends AutoPagedGUI {
|
|||||||
|
|
||||||
for (PrefixConfig prefix : prefixList) {
|
for (PrefixConfig prefix : prefixList) {
|
||||||
if (prefix.getIdentifier().equals(usingPrefix.getIdentifier())) {
|
if (prefix.getIdentifier().equals(usingPrefix.getIdentifier())) {
|
||||||
addItem(new GUIItem(prefix.getItemWhenUsing(player) != null ? prefix.getItemWhenUsing(player) : prefix.getItemHasPermission(player)));
|
addItem(new GUIItem(Optional
|
||||||
|
.ofNullable(prefix.getItemWhenUsing(player))
|
||||||
|
.orElse(prefix.getItemHasPermission(player))
|
||||||
|
));
|
||||||
} else if (prefix.checkPermission(player)) {
|
} else if (prefix.checkPermission(player)) {
|
||||||
addItem(new GUIItem(prefix.getItemHasPermission(player)) {
|
addItem(new GUIItem(prefix.getItemHasPermission(player)) {
|
||||||
|
|
||||||
@@ -61,7 +65,7 @@ public class PrefixSelectGUI extends AutoPagedGUI {
|
|||||||
|
|
||||||
// 发送消息与提示
|
// 发送消息与提示
|
||||||
PluginConfig.SOUNDS.PREFIX_CHANGE.playTo(player);
|
PluginConfig.SOUNDS.PREFIX_CHANGE.playTo(player);
|
||||||
PluginMessages.SELECTED.send(player, prefix.getName());
|
PluginMessages.SELECTED.sendTo(player, prefix.getName());
|
||||||
|
|
||||||
UserPrefixChangeEvent.call(player, usingPrefix, prefix, config -> {
|
UserPrefixChangeEvent.call(player, usingPrefix, prefix, config -> {
|
||||||
if (config == null) return;
|
if (config == null) return;
|
||||||
@@ -103,7 +107,7 @@ public class PrefixSelectGUI extends AutoPagedGUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void open(Player player) {
|
public static void open(Player player) {
|
||||||
player.closeInventory(); // 防止冲突
|
// player.closeInventory(); // 防止冲突
|
||||||
PluginConfig.SOUNDS.GUI_OPEN.playTo(player);
|
PluginConfig.SOUNDS.GUI_OPEN.playTo(player);
|
||||||
new PrefixSelectGUI(player).openGUI(player);
|
new PrefixSelectGUI(player).openGUI(player);
|
||||||
openingUsers.add(player);
|
openingUsers.add(player);
|
||||||
|
|||||||
+13
-3
@@ -8,8 +8,16 @@ name: "&b&lPro&b"
|
|||||||
|
|
||||||
# Content [Necessary]
|
# Content [Necessary]
|
||||||
# Use in Placeholders
|
# Use in Placeholders
|
||||||
|
# Supports multiple lines for content rotation.
|
||||||
content: "&b&lPro &b"
|
content: "&b&lPro &b"
|
||||||
|
|
||||||
|
# Period [Unnecessary]
|
||||||
|
# Set the rotation period of the prefix content, in milliseconds.
|
||||||
|
# If set to -1, it will not rotate.
|
||||||
|
# If set to 0, it will randomly select a line each time the prefix is fetched
|
||||||
|
# If set to a value greater than 0, it will rotate the content every specified milliseconds.
|
||||||
|
period: -1
|
||||||
|
|
||||||
# Weight [Necessary]
|
# Weight [Necessary]
|
||||||
# used for sorting in the GUI and TabList
|
# used for sorting in the GUI and TabList
|
||||||
# In GUI : the larger is displayed at the back
|
# In GUI : the larger is displayed at the back
|
||||||
@@ -27,11 +35,13 @@ permission: "yc.vip"
|
|||||||
actions:
|
actions:
|
||||||
- "[CONSOLE] say %player_name% selected PRO !"
|
- "[CONSOLE] say %player_name% selected PRO !"
|
||||||
|
|
||||||
|
# Display item configuration
|
||||||
|
# More details please see https://github.com/CryptoMorin/XSeries/wiki/XItemStack
|
||||||
item:
|
item:
|
||||||
# itemHasPermission [Necessary]
|
# itemHasPermission [Necessary]
|
||||||
# This Item will be displayed when player has permission
|
# This Item will be displayed when player has permission
|
||||||
has-perm:
|
has-perm:
|
||||||
type: DIAMOND
|
material: DIAMOND
|
||||||
name: "&b&lVIP Prefix"
|
name: "&b&lVIP Prefix"
|
||||||
lore:
|
lore:
|
||||||
- ""
|
- ""
|
||||||
@@ -41,7 +51,7 @@ item:
|
|||||||
# This Item will be displayed when the prefix is selected.
|
# This Item will be displayed when the prefix is selected.
|
||||||
# If there is no such configuration, it will automatically display "itemHasPermission".
|
# If there is no such configuration, it will automatically display "itemHasPermission".
|
||||||
using:
|
using:
|
||||||
type: DIAMOND
|
material: DIAMOND
|
||||||
name: "&b&lVIP Prefix"
|
name: "&b&lVIP Prefix"
|
||||||
enchants:
|
enchants:
|
||||||
PROTECTION_ENVIRONMENTAL: 1 #Add an enchantment so it looks like it’s selected
|
PROTECTION_ENVIRONMENTAL: 1 #Add an enchantment so it looks like it’s selected
|
||||||
@@ -53,7 +63,7 @@ item:
|
|||||||
# If player doesn't have the permission,this item will be displayed.
|
# If player doesn't have the permission,this item will be displayed.
|
||||||
# If this item is not configured, it will not be displayed in the GUI when the player does not have permission to use it.
|
# If this item is not configured, it will not be displayed in the GUI when the player does not have permission to use it.
|
||||||
no-perm:
|
no-perm:
|
||||||
type: INK_SACK
|
material: INK_SACK
|
||||||
data: 8
|
data: 8
|
||||||
name: "&b&lVIP &c(Buy it!)"
|
name: "&b&lVIP &c(Buy it!)"
|
||||||
lore:
|
lore:
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
|
||||||
|
# Nombre [Necesario]
|
||||||
|
# Uso en mensajes.
|
||||||
|
name: "&b&lPro&b"
|
||||||
|
|
||||||
|
# Contenido [Necesario]
|
||||||
|
# Uso en Placeholders
|
||||||
|
# Soporta múltiples líneas para la rotación de contenido.
|
||||||
|
content: "&b&lPro &b"
|
||||||
|
|
||||||
|
# Periodo [Innecesario]
|
||||||
|
# Establece el periodo de rotación del contenido del prefijo, en milisegundos.
|
||||||
|
# Si se establece en -1, no rotará.
|
||||||
|
# Si se establece en 0, seleccionará aleatoriamente una línea cada vez que se
|
||||||
|
# obtenga el prefijo.
|
||||||
|
# Si se establece en un valor mayor que 0, rotará el contenido cada los mil
|
||||||
|
# segundos especificados.
|
||||||
|
period: -1
|
||||||
|
|
||||||
|
# Weight [Necesario]
|
||||||
|
# utilizado para ordenar en la GUI y TabList
|
||||||
|
# En GUI : el más grande se muestra en la parte posterior
|
||||||
|
# En TabList : el más grande se muestra en la parte superior
|
||||||
|
weight: 1
|
||||||
|
|
||||||
|
# Permisos [Innecesario]
|
||||||
|
# Si no hay permiso para la detección, todo el mundo puede utilizarlo,
|
||||||
|
# lo que significa que no es necesario configurar "itemNoPermission"
|
||||||
|
# (porque es imposible mostrar elementos sin permiso en absoluto)
|
||||||
|
permission: "yc.vip"
|
||||||
|
|
||||||
|
# Acciones al seleccionar [Innecesario]
|
||||||
|
# Por favor, compruebe https://github.com/CarmJos/UserPrefix/tree/master/.documentation/ACTIONS.md
|
||||||
|
actions:
|
||||||
|
- "[CONSOLE] say %player_name% Has seleccionado La etiqueta PRO!"
|
||||||
|
|
||||||
|
item:
|
||||||
|
# itemHasPermission [Necesario]
|
||||||
|
# Este elemento se mostrará cuando el jugador tenga permiso
|
||||||
|
has-perm:
|
||||||
|
material: DIAMOND
|
||||||
|
name: "&b&lVIP Prefix"
|
||||||
|
lore:
|
||||||
|
- ""
|
||||||
|
- "&a➥ Pulsa para utilizar"
|
||||||
|
|
||||||
|
# itemUsing [Innecesario]
|
||||||
|
# Este elemento se mostrará cuando se seleccione el prefijo.
|
||||||
|
# Si no existe tal configuración, se mostrará automáticamente "itemHasPermission".
|
||||||
|
using:
|
||||||
|
material: DIAMOND
|
||||||
|
name: "&b&lPrefix VIP"
|
||||||
|
enchants:
|
||||||
|
PROTECTION_ENVIRONMENTAL: 1 #Añade un encantamiento para que parezca que está seleccionado
|
||||||
|
lore:
|
||||||
|
- ""
|
||||||
|
- "&a✔ Seleccionado"
|
||||||
|
|
||||||
|
# itemNoPermission [Innecesario]
|
||||||
|
# Si el jugador no tiene el permiso,este item sera mostrado.
|
||||||
|
# Si este elemento no está configurado, no se mostrará en la GUI cuando el jugador no tenga permiso para usarlo.
|
||||||
|
no-perm:
|
||||||
|
material: INK_SACK
|
||||||
|
data: 8
|
||||||
|
name: "&b&lVIP &c(¡Cómpralo!)"
|
||||||
|
lore:
|
||||||
|
- ""
|
||||||
|
- "&e✯ Necesitas Comprar el VIP para utilizarlo!"
|
||||||
@@ -8,6 +8,7 @@ authors:
|
|||||||
website: ${project.url}
|
website: ${project.url}
|
||||||
description: ${project.description}
|
description: ${project.description}
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
folia-supported: true
|
||||||
|
|
||||||
depend:
|
depend:
|
||||||
- LuckPerms
|
- LuckPerms
|
||||||
|
|||||||
@@ -5,12 +5,20 @@ identifier: "pro"
|
|||||||
|
|
||||||
# 名字 [必须]
|
# 名字 [必须]
|
||||||
# 切换的时候左下角会弹提示 用的就是这个名字
|
# 切换的时候左下角会弹提示 用的就是这个名字
|
||||||
name: "&b&lPro&b"
|
name: "&b&lPro &b会员"
|
||||||
|
|
||||||
# 内容 [必须]
|
# 内容 [必须]
|
||||||
# 显示在名字前面的内容
|
# 显示在名字前面的内容
|
||||||
|
# 支持多行内容以实现前缀内容的轮换
|
||||||
content: "&b&lPro &b"
|
content: "&b&lPro &b"
|
||||||
|
|
||||||
|
# 轮换周期 [非必须]
|
||||||
|
# 设置前缀内容的轮换周期,单位为毫秒。
|
||||||
|
# 若数值为-1,则表示不轮换。
|
||||||
|
# 若数值为0,则每次获取前缀时都会随机选择一行内容。
|
||||||
|
# 若数值大于0,则表示每隔指定毫秒数轮换一次内容
|
||||||
|
period: -1
|
||||||
|
|
||||||
# 权重 [必须]
|
# 权重 [必须]
|
||||||
# 用于GUI、TabList的排序和自动前缀显示
|
# 用于GUI、TabList的排序和自动前缀显示
|
||||||
# 在GUI中,权重越高的会显示在越后面
|
# 在GUI中,权重越高的会显示在越后面
|
||||||
@@ -29,50 +37,46 @@ permission: "yc.pro"
|
|||||||
actions:
|
actions:
|
||||||
- "[CONSOLE] say %player_name% 选择了 Pro会员前缀 !"
|
- "[CONSOLE] say %player_name% 选择了 Pro会员前缀 !"
|
||||||
|
|
||||||
|
description: # 描述 [非必须]
|
||||||
|
- "&f尊贵的Pro会员专属称号。"
|
||||||
|
- "&f您将获得多种特权与更好的游戏体验。"
|
||||||
|
- "&f您可以输入 &b/vip &f指令查看详细特权!"
|
||||||
|
|
||||||
# 该前缀的GUI物品配置
|
# 该前缀的GUI物品配置
|
||||||
|
# 物品配置方式详见 https://github.com/CryptoMorin/XSeries/wiki/XItemStack
|
||||||
item:
|
item:
|
||||||
|
|
||||||
# 有权限时显示的物品 [必须]
|
# 有权限时显示的物品 [必须]
|
||||||
# 当用户有权限且未选中时,会显示该物品
|
# 当用户有权限且未选中时,会显示该物品
|
||||||
has-perm:
|
has-perm:
|
||||||
type: DIAMOND
|
material: DIAMOND
|
||||||
name: "&b&lPro &b会员前缀"
|
name: "%(name)"
|
||||||
lore:
|
lore:
|
||||||
- "&7Pro会员专属称号"
|
- "&7Pro会员专属称号"
|
||||||
- ""
|
- "#desciption#{1,1}"
|
||||||
- "&f尊贵的Pro会员专属称号。"
|
|
||||||
- "&f您将获得多种特权与更好的游戏体验。"
|
|
||||||
- ""
|
|
||||||
- "&a➥ 点击切换到该前缀"
|
- "&a➥ 点击切换到该前缀"
|
||||||
|
|
||||||
# 正在使用时显示的物品 [非必需]
|
# 正在使用时显示的物品 [非必需]
|
||||||
# 当用户正在使用时会显示这个物品,不配置即自动加载“itemHasPermission”
|
# 当用户正在使用时会显示这个物品,不配置即自动加载“itemHasPermission”
|
||||||
using:
|
using:
|
||||||
type: DIAMOND
|
material: DIAMOND
|
||||||
name: "&b&lPro &b会员前缀"
|
name: "%(name)"
|
||||||
flags:
|
flags:
|
||||||
- HIDE_ENCHANTS # 隐藏附魔显示
|
- HIDE_ENCHANTS # 隐藏附魔显示
|
||||||
enchants:
|
enchants:
|
||||||
PROTECTION_ENVIRONMENTAL: 1 #加一个附魔这样看上去就像是选中了的
|
PROTECTION_ENVIRONMENTAL: 1 #加一个附魔这样看上去就像是选中了的
|
||||||
lore:
|
lore:
|
||||||
- "&7Pro会员专属称号"
|
- "&7Pro会员专属称号"
|
||||||
- ""
|
- "#desciption#{1,1}"
|
||||||
- "&f尊贵的Pro会员专属称号。"
|
|
||||||
- "&f您将获得多种特权与更好的游戏体验。"
|
|
||||||
- ""
|
|
||||||
- "&a✔ 您正在使用该前缀"
|
- "&a✔ 您正在使用该前缀"
|
||||||
|
|
||||||
# 没有权限时显示的物品 [非必需]
|
# 没有权限时显示的物品 [非必需]
|
||||||
# 如果没有权限就会显示这个item。如果不配置该物品,则玩家没有使用权限时不会显示在GUI里面。
|
# 如果没有权限就会显示这个item。如果不配置该物品,则玩家没有使用权限时不会显示在GUI里面。
|
||||||
no-perm:
|
no-perm:
|
||||||
type: INK_SACK
|
material: INK_SACK
|
||||||
data: 8
|
data: 8
|
||||||
name: "&b&lPro+ &b会员前缀 &c(未拥有)"
|
name: "%(name) &c(未拥有)"
|
||||||
lore:
|
lore:
|
||||||
- "&7Pro+会员专属称号"
|
- "&7Pro 会员专属称号"
|
||||||
- ""
|
- "#desciption#{1,1}"
|
||||||
- "&f尊贵的Pro会员专属称号。"
|
- "&e✯ 加入Pro会员以使用该前缀!"
|
||||||
- "&f您将获得多种特权与更好的游戏体验。"
|
|
||||||
- "&f您可以输入 &b/vip &f指令查看详细特权!"
|
|
||||||
- ""
|
|
||||||
- "&e✯ 加入Pro+会员以使用该前缀!"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user