1
mirror of https://github.com/CarmJos/UserPrefix.git synced 2026-06-05 09:01:39 +08:00

Compare commits

...

42 Commits

Author SHA1 Message Date
renovate[bot] 3b2eaf2519 chore(deps): update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.5.6 (#145)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-28 04:57:06 +00:00
carm 75ee308174 chore(deps): update XSeries dependency version to 13.8.0 2026-05-13 03:49:24 +08:00
renovate[bot] bed1651027 chore(deps): update actions/upload-artifact action to v7 2026-03-10 08:05:54 +08:00
renovate[bot] 7dde64e699 chore(deps): update dependency org.apache.maven.plugins:maven-shade-plugin to v3.6.2 (#142)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-05 17:38:09 +00:00
renovate[bot] 9b88142676 fix(deps): update dependency org.bstats:bstats-bukkit to v3.2.1 (#140)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-25 00:36:09 +00:00
renovate[bot] e0cfd87ac6 fix(deps): update dependency org.bstats:bstats-bukkit to v3.2.0 (#139)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-23 21:21:11 +00:00
renovate[bot] fd764fa348 chore(deps): update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.5.5 (#138)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-21 16:38:46 +00:00
renovate[bot] 480cebd16a fix(deps): update dependency org.jetbrains:annotations to v26.1.0 (#137)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-18 22:30:57 +00:00
renovate[bot] 6cd25cf94a fix(deps): update dependency me.clip:placeholderapi to v2.12.2 (#136)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-09 01:37:34 +00:00
renovate[bot] 72071492b3 fix(deps): update dependency me.clip:placeholderapi to v2.12.1 (#135)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-03 18:09:02 +00:00
renovate[bot] b334c3476e fix(deps): update dependency me.clip:placeholderapi to v2.12.0 (#134)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-02 22:27:49 +00:00
renovate[bot] c94ed28b98 chore(deps): update dependency org.apache.maven.plugins:maven-compiler-plugin to v3.15.0 (#133)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-02 02:02:54 +00:00
carm 72aa4e3a82 ci(deploy): Add deployment to Modrinth 2025-12-25 14:53:04 +08:00
carm acc92d5fb4 ci(deploy): Add deployment to Modrinth 2025-12-25 14:50:52 +08:00
renovate[bot] bc002f9a07 chore(deps): update actions/upload-artifact action to v6 2025-12-25 14:36:04 +08:00
carm f11749d4da ci(deploy): Add deployment to Modrinth 2025-12-25 14:35:42 +08:00
renovate[bot] a52b703a75 chore(deps): update dependency com.github.cryptomorin:xseries to v13.6.0 (#130)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-13 20:37:53 +00:00
renovate[bot] 86775cdbcd chore(deps): update actions/checkout action to v6 2025-12-01 09:32:27 +08:00
renovate[bot] 8951b7ac90 chore(deps): update dependency org.apache.maven.plugins:maven-source-plugin to v3.4.0 (#128)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-29 05:34:56 +00:00
renovate[bot] 89b520b8d3 chore(deps): update dependency org.apache.maven.plugins:maven-jar-plugin to v3.5.0 (#126)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-15 12:53:53 +00:00
renovate[bot] b57ff5b2c5 chore(deps): update actions/upload-artifact action to v5 2025-11-11 03:30:53 +08:00
Creeam b4469f93d0 Fix Folia detection 2025-11-11 03:30:42 +08:00
renovate[bot] d91dd6c7bd fix(deps): update dependency org.spigotmc:spigot-api to v1.19-r0.1-20220725.090125-47 (#123)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-08 18:26:41 +00:00
renovate[bot] ebd9f9fbfc fix(deps): update dependency me.clip:placeholderapi to v2.11.7 (#121)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-03 19:39:27 +00:00
renovate[bot] f5d256b5c4 chore(deps): update github/codeql-action action to v4 2025-10-23 10:37:05 +08:00
renovate[bot] e43ce22551 chore(deps): update dependency com.github.cryptomorin:xseries to v13.5.1 (#119)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-08 21:08:58 +00:00
renovate[bot] f821ab88ed chore(deps): update dependency com.github.cryptomorin:xseries to v13.5.0 (#117)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-07 16:01:58 +00:00
renovate[bot] b03bb4a476 chore(deps): update dependency org.apache.maven.plugins:maven-compiler-plugin to v3.14.1 (#116)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-22 09:26:03 +00:00
renovate[bot] 86326a168b chore(deps): update dependency org.apache.maven.plugins:maven-javadoc-plugin to v3.12.0 (#115)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-21 08:34:12 +00:00
renovate[bot] 672641259e chore(deps): update dependency com.github.cryptomorin:xseries to v13.4.0 2025-09-14 17:02:04 +08:00
renovate[bot] 5fc46eed8f chore(deps): update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.5.4 2025-09-14 16:56:42 +08:00
renovate[bot] 50ded3fa11 chore(deps): update dependency org.apache.maven.plugins:maven-shade-plugin to v3.6.1 (#112)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-14 03:07:59 +00:00
carm 951fe67117 fix(color): 修复前缀颜色显示的问题。 2025-09-04 01:27:52 +08:00
carm 442374da0a fix: 修复前缀内容显示错误的问题。 2025-09-04 01:21:13 +08:00
renovate[bot] 77a277ba58 fix(deps): update dependency org.jetbrains:annotations to v26.0.2-1 (#109)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-02 00:33:43 +00:00
renovate[bot] 1ead1a0692 chore(deps): update actions/checkout action to v5 2025-08-21 23:44:41 +08:00
renovate[bot] f519fa43df chore(deps): update actions/setup-java action to v5 2025-08-21 23:44:34 +08:00
renovate[bot] da63cf8b1c chore(deps): update dependency org.apache.maven.plugins:maven-javadoc-plugin to v3.11.3 (#105)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-16 16:26:54 +00:00
carm 9527e9fcbb fix: 修复颜色丢失的问题。 2025-08-06 19:05:26 +08:00
carm 5befd40706 feat: 新增prefix内容轮换。 2025-08-03 08:04:09 +08:00
carm e1bedba01b feat: 新增prefix内容轮换。 2025-08-03 08:03:50 +08:00
carm 5809659155 feat: 新增prefix内容轮换。 2025-08-03 07:58:53 +08:00
14 changed files with 167 additions and 37 deletions
+4 -4
View File
@@ -38,11 +38,11 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 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@v3 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@v3 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@v3 uses: github/codeql-action/analyze@v4
+26 -3
View File
@@ -16,9 +16,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: "Set up JDK" - name: "Set up JDK"
uses: actions/setup-java@v4 uses: actions/setup-java@v5
with: with:
java-version: '11' java-version: '11'
distribution: 'adopt' distribution: 'adopt'
@@ -87,4 +87,27 @@ jobs:
- name: "Push javadocs" - name: "Push javadocs"
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)
+3 -3
View File
@@ -14,9 +14,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: "Set up JDK" - name: "Set up JDK"
uses: actions/setup-java@v4 uses: actions/setup-java@v5
with: with:
java-version: '11' java-version: '11'
distribution: 'adopt' distribution: 'adopt'
@@ -37,7 +37,7 @@ jobs:
cp -vrf asset/*.jar artifacts cp -vrf asset/*.jar artifacts
- name: "Upload artifact" - name: "Upload artifact"
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v7
with: with:
name: Artifact name: Artifact
path: artifacts path: artifacts
-2
View File
@@ -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
![example](.documentation/images/using-example.png) ![example](.documentation/images/using-example.png)
+2 -2
View File
@@ -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,6 +39,7 @@ 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 版本起]`
+12 -12
View File
@@ -19,7 +19,7 @@
<groupId>cc.carm.plugin</groupId> <groupId>cc.carm.plugin</groupId>
<artifactId>userprefix</artifactId> <artifactId>userprefix</artifactId>
<version>3.2.7</version> <version>3.3.1</version>
<name>UserPrefix</name> <name>UserPrefix</name>
<description>轻便、高效、实时的用户前缀系统。</description> <description>轻便、高效、实时的用户前缀系统。</description>
@@ -173,7 +173,7 @@
<dependency> <dependency>
<groupId>com.github.cryptomorin</groupId> <groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId> <artifactId>XSeries</artifactId>
<version>13.3.3</version> <version>13.8.0</version>
<scope>compile</scope> <scope>compile</scope>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
@@ -188,14 +188,14 @@
<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.11.6</version> <version>2.12.2</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@@ -209,14 +209,14 @@
<dependency> <dependency>
<groupId>org.bstats</groupId> <groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId> <artifactId>bstats-bukkit</artifactId>
<version>3.1.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>26.0.2</version> <version>26.1.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@@ -256,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.14.0</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>
@@ -267,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.4.2</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.3.1</version> <version>3.4.0</version>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
@@ -285,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.6.0</version> <version>3.6.2</version>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
@@ -331,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.11.2</version> <version>3.12.0</version>
<configuration> <configuration>
<classifier>javadoc</classifier> <classifier>javadoc</classifier>
<links> <links>
@@ -358,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>3.5.3</version> <version>3.5.6</version>
<configuration> <configuration>
<useSystemClassLoader>false</useSystemClassLoader> <useSystemClassLoader>false</useSystemClassLoader>
</configuration> </configuration>
@@ -41,7 +41,7 @@ public class Main extends EasyPlugin {
instance = this; instance = this;
try { try {
Class.forName("io.papermc.paper.threadedregions.RegionizedServerInitEvent"); Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
this.onFolia = true; this.onFolia = true;
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
this.onFolia = false; this.onFolia = false;
@@ -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) {
@@ -21,7 +23,7 @@ public class ListCommand extends SubCommand<AdminCommand> {
for (PrefixConfig value : UserPrefixAPI.getPrefixManager().getPrefixes().values()) { for (PrefixConfig value : UserPrefixAPI.getPrefixManager().getPrefixes().values()) {
PluginMessages.LIST.VALUE.sendTo(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), sender.getName() value.getContent(sender), sender.getName()
); );
} }
@@ -1,6 +1,7 @@
package cc.carm.plugin.userprefix.conf; package cc.carm.plugin.userprefix.conf;
import cc.carm.lib.configuration.Configuration; import cc.carm.lib.configuration.Configuration;
import cc.carm.lib.configuration.adapter.ValueType;
import cc.carm.lib.configuration.annotation.ConfigPath; import cc.carm.lib.configuration.annotation.ConfigPath;
import cc.carm.lib.configuration.annotation.HeaderComments; import cc.carm.lib.configuration.annotation.HeaderComments;
import cc.carm.lib.configuration.value.standard.ConfiguredList; import cc.carm.lib.configuration.value.standard.ConfiguredList;
@@ -12,6 +13,10 @@ import cc.carm.plugin.userprefix.folia.MajorUtil;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class PluginConfig implements Configuration { public class PluginConfig implements Configuration {
@HeaderComments({"开发者查错模式"}) @HeaderComments({"开发者查错模式"})
@@ -148,7 +153,32 @@ public class PluginConfig implements Configuration {
public static final ConfiguredValue<Integer> WEIGHT = ConfiguredValue.of(Integer.class, 0); public static final ConfiguredValue<Integer> WEIGHT = ConfiguredValue.of(Integer.class, 0);
@HeaderComments({"默认前缀的内容,即用于显示的实际前缀"}) @HeaderComments({"默认前缀的内容,即用于显示的实际前缀"})
public static final ConfiguredValue<String> CONTENT = ConfiguredValue.of(String.class, "&r"); 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({"选择默认前缀时执行的操作"}) @HeaderComments({"选择默认前缀时执行的操作"})
public static final ConfiguredList<String> ACTIONS = ConfiguredList.builderOf(String.class).fromString() public static final ConfiguredList<String> ACTIONS = ConfiguredList.builderOf(String.class).fromString()
@@ -162,7 +192,7 @@ public class PluginConfig implements Configuration {
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("","{&f&o }#description#{1,1}", "&a➥ 点击切换到该前缀") .defaultLore("", "{&f&o }#description#{1,1}", "&a➥ 点击切换到该前缀")
.build(); .build();
@HeaderComments({"当选择了默认前缀时显示的物品"}) @HeaderComments({"当选择了默认前缀时显示的物品"})
@@ -171,7 +201,7 @@ public class PluginConfig implements Configuration {
.defaultEnchant(MajorUtil.getEnchantProtection(), 1) // 附魔改过名 .defaultEnchant(MajorUtil.getEnchantProtection(), 1) // 附魔改过名
.defaultFlags(ItemFlag.HIDE_ENCHANTS) .defaultFlags(ItemFlag.HIDE_ENCHANTS)
.defaultName("&f默认玩家前缀") .defaultName("&f默认玩家前缀")
.defaultLore("","{&f&o }#description#{1,1}", "&a✔ 您正在使用该前缀") .defaultLore("", "{&f&o }#description#{1,1}", "&a✔ 您正在使用该前缀")
.build(); .build();
} }
@@ -2,6 +2,7 @@ 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.gui.configuration.GUIActionType;
import cc.carm.lib.easyplugin.utils.ColorParser;
import cc.carm.lib.easyplugin.utils.MessageUtils; import cc.carm.lib.easyplugin.utils.MessageUtils;
import cc.carm.lib.mineconfiguration.bukkit.value.item.PreparedItem; import cc.carm.lib.mineconfiguration.bukkit.value.item.PreparedItem;
import cc.carm.plugin.userprefix.Main; import cc.carm.plugin.userprefix.Main;
@@ -14,16 +15,22 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; 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 @NotNull List<String> description;
protected final long period; // 内容变更周期,单位为毫秒
protected final int weight; protected final int weight;
protected final @Nullable String permission; protected final @Nullable String permission;
@@ -54,10 +61,26 @@ public class PrefixConfig {
@NotNull ItemStack itemHasPermission, @NotNull ItemStack itemHasPermission,
@Nullable ItemStack itemWhenUsing, @Nullable ItemStack itemWhenUsing,
@Nullable ItemStack itemNoPermission) { @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.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;
@@ -73,17 +96,31 @@ public class PrefixConfig {
@NotNull @NotNull
public String getName() { public String getName() {
return name; return ColorParser.parse(name);
} }
@NotNull @NotNull
public List<String> getDescription() { public List<String> getDescription() {
return description; return ColorParser.parse(description);
} }
@NotNull @NotNull
public String getContent(CommandSender viewer) { public String getContent(CommandSender viewer) {
return MessageUtils.setPlaceholders(viewer, content); 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() {
@@ -114,6 +151,8 @@ public class PrefixConfig {
protected @Nullable ItemStack getItem(@Nullable Player player, @Nullable ItemStack item) { protected @Nullable ItemStack getItem(@Nullable Player player, @Nullable ItemStack item) {
PreparedItem prepared = PreparedItem.of(item); PreparedItem prepared = PreparedItem.of(item);
prepared.parser((p, s) -> ColorParser.parse(MessageUtils.setPlaceholders(p, s)));
if (!getDescription().isEmpty()) { if (!getDescription().isEmpty()) {
prepared.insert("description", getDescription()); prepared.insert("description", getDescription());
prepared.placeholder("description", String.join("\n", getDescription())); prepared.placeholder("description", String.join("\n", getDescription()));
@@ -78,7 +78,8 @@ public class PrefixManager {
"default", "default",
PluginConfig.DEFAULT_PREFIX.NAME.getNotNull(), PluginConfig.DEFAULT_PREFIX.NAME.getNotNull(),
PluginConfig.DEFAULT_PREFIX.DESCRIPTION.getNotNull(), PluginConfig.DEFAULT_PREFIX.DESCRIPTION.getNotNull(),
PluginConfig.DEFAULT_PREFIX.CONTENT.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()),
@@ -134,10 +135,21 @@ public class PrefixManager {
String name = conf.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,
conf.getStringList("description"), conf.getStringList("description"),
conf.getString("content", "&r"), content,
conf.getLong("period", -1L),
conf.getInt("weight", 1), conf.getInt("weight", 1),
conf.getString("permission"), conf.getString("permission"),
readActions(conf.getStringList("actions")), readActions(conf.getStringList("actions")),
@@ -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
@@ -5,8 +5,18 @@ name: "&b&lPro&b"
# Contenido [Necesario] # Contenido [Necesario]
# Uso en Placeholders # Uso en Placeholders
# Soporta múltiples líneas para la rotación de contenido.
content: "&b&lPro &b" 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] # Weight [Necesario]
# utilizado para ordenar en la GUI y TabList # utilizado para ordenar en la GUI y TabList
# En GUI : el más grande se muestra en la parte posterior # En GUI : el más grande se muestra en la parte posterior
@@ -9,8 +9,16 @@ name: "&b&lPro &b会员"
# 内容 [必须] # 内容 [必须]
# 显示在名字前面的内容 # 显示在名字前面的内容
# 支持多行内容以实现前缀内容的轮换
content: "&b&lPro &b" content: "&b&lPro &b"
# 轮换周期 [非必须]
# 设置前缀内容的轮换周期,单位为毫秒。
# 若数值为-1,则表示不轮换。
# 若数值为0,则每次获取前缀时都会随机选择一行内容。
# 若数值大于0,则表示每隔指定毫秒数轮换一次内容
period: -1
# 权重 [必须] # 权重 [必须]
# 用于GUI、TabList的排序和自动前缀显示 # 用于GUI、TabList的排序和自动前缀显示
# 在GUI中,权重越高的会显示在越后面 # 在GUI中,权重越高的会显示在越后面