diff --git a/pom.xml b/pom.xml
index c3b9e0b..b9f5614 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
cc.carm.plugin
userprefix
- 3.2.6
+ 3.2.7-SNAPSHOT
UserPrefix
轻便、高效、实时的用户前缀系统。
diff --git a/src/main/java/cc/carm/plugin/userprefix/conf/PluginConfig.java b/src/main/java/cc/carm/plugin/userprefix/conf/PluginConfig.java
index 7ad3086..c1355aa 100644
--- a/src/main/java/cc/carm/plugin/userprefix/conf/PluginConfig.java
+++ b/src/main/java/cc/carm/plugin/userprefix/conf/PluginConfig.java
@@ -139,6 +139,11 @@ public class PluginConfig implements Configuration {
@HeaderComments("默认前缀的显示名称,用于在消息提示中显示。")
public static final ConfiguredValue NAME = ConfiguredValue.of(String.class, "默认前缀");
+ @HeaderComments({"默认前缀的描述信息。"})
+ public static final ConfiguredList DESCRIPTION = ConfiguredList.builderOf(String.class).fromString()
+ .defaults("&7这是一个默认前缀", "&7您可以在前缀列表中选择其他前缀")
+ .build();
+
@HeaderComments({"默认前缀的权重,默认为0。"})
public static final ConfiguredValue WEIGHT = ConfiguredValue.of(Integer.class, 0);
@@ -157,7 +162,7 @@ public class PluginConfig implements Configuration {
public static final ConfiguredItem NOT_USING = ConfiguredItem.create()
.defaultType(Material.NAME_TAG)
.defaultName("&f默认玩家前缀 &f(点击切换)")
- .defaultLore("", "&a➥ 点击切换到该前缀")
+ .defaultLore("","{&f&o }#description#{1,1}", "&a➥ 点击切换到该前缀")
.build();
@HeaderComments({"当选择了默认前缀时显示的物品"})
@@ -166,7 +171,7 @@ public class PluginConfig implements Configuration {
.defaultEnchant(MajorUtil.getEnchantProtection(), 1) // 附魔改过名
.defaultFlags(ItemFlag.HIDE_ENCHANTS)
.defaultName("&f默认玩家前缀")
- .defaultLore("", "&a✔ 您正在使用该前缀")
+ .defaultLore("","{&f&o }#description#{1,1}", "&a✔ 您正在使用该前缀")
.build();
}
diff --git a/src/main/java/cc/carm/plugin/userprefix/conf/prefix/PrefixConfig.java b/src/main/java/cc/carm/plugin/userprefix/conf/prefix/PrefixConfig.java
index bcffbdd..f36a2c4 100644
--- a/src/main/java/cc/carm/plugin/userprefix/conf/prefix/PrefixConfig.java
+++ b/src/main/java/cc/carm/plugin/userprefix/conf/prefix/PrefixConfig.java
@@ -13,6 +13,7 @@ import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.ArrayList;
import java.util.List;
public class PrefixConfig {
@@ -21,6 +22,7 @@ public class PrefixConfig {
protected final @NotNull String name;
protected final @NotNull String content;
+ protected final @NotNull List description;
protected final int weight;
@@ -38,8 +40,23 @@ public class PrefixConfig {
@NotNull ItemStack itemHasPermission,
@Nullable ItemStack itemWhenUsing,
@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 description,
+ @NotNull String content, int weight, @Nullable String permission,
+ @NotNull List actions,
+ @NotNull ItemStack itemHasPermission,
+ @Nullable ItemStack itemWhenUsing,
+ @Nullable ItemStack itemNoPermission) {
this.identifier = identifier;
this.name = name;
+ this.description = description;
this.content = content;
this.weight = weight;
this.permission = permission;
@@ -59,6 +76,11 @@ public class PrefixConfig {
return name;
}
+ @NotNull
+ public List getDescription() {
+ return description;
+ }
+
@NotNull
public String getContent(CommandSender viewer) {
return MessageUtils.setPlaceholders(viewer, content);
@@ -90,7 +112,23 @@ public class PrefixConfig {
@Contract("_,!null->!null")
protected @Nullable ItemStack getItem(@Nullable Player player, @Nullable ItemStack item) {
- return PreparedItem.of(item).get(player);
+ PreparedItem prepared = PreparedItem.of(item);
+
+ 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);
}
diff --git a/src/main/java/cc/carm/plugin/userprefix/manager/PrefixManager.java b/src/main/java/cc/carm/plugin/userprefix/manager/PrefixManager.java
index 33e13d1..872d9ff 100644
--- a/src/main/java/cc/carm/plugin/userprefix/manager/PrefixManager.java
+++ b/src/main/java/cc/carm/plugin/userprefix/manager/PrefixManager.java
@@ -77,6 +77,7 @@ public class PrefixManager {
this.defaultPrefix = new PrefixConfig(
"default",
PluginConfig.DEFAULT_PREFIX.NAME.getNotNull(),
+ PluginConfig.DEFAULT_PREFIX.DESCRIPTION.getNotNull(),
PluginConfig.DEFAULT_PREFIX.CONTENT.getNotNull(),
PluginConfig.DEFAULT_PREFIX.WEIGHT.getNotNull(),
null,
@@ -135,6 +136,7 @@ public class PrefixManager {
return new PrefixConfig(
identifier, name,
+ conf.getStringList("description"),
conf.getString("content", "&r"),
conf.getInt("weight", 1),
conf.getString("permission"),
diff --git a/src/main/java/cc/carm/plugin/userprefix/ui/PrefixSelectGUI.java b/src/main/java/cc/carm/plugin/userprefix/ui/PrefixSelectGUI.java
index 7924664..7b922d2 100644
--- a/src/main/java/cc/carm/plugin/userprefix/ui/PrefixSelectGUI.java
+++ b/src/main/java/cc/carm/plugin/userprefix/ui/PrefixSelectGUI.java
@@ -20,7 +20,7 @@ public class PrefixSelectGUI extends AutoPagedGUI {
public static HashSet openingUsers = new HashSet<>();
- Player player;
+ protected final Player player;
public PrefixSelectGUI(Player player) {
super(GUIType.SIX_BY_NINE, PluginConfig.GUI.TITLE.get(), 10, 43);
diff --git a/src/main/resources/prefixes/example-prefix.yml b/src/main/resources/prefixes/example-prefix.yml
index 8359dc2..7940548 100644
--- a/src/main/resources/prefixes/example-prefix.yml
+++ b/src/main/resources/prefixes/example-prefix.yml
@@ -5,7 +5,7 @@ identifier: "pro"
# 名字 [必须]
# 切换的时候左下角会弹提示 用的就是这个名字
-name: "&b&lPro&b"
+name: "&b&lPro &b会员"
# 内容 [必须]
# 显示在名字前面的内容
@@ -29,6 +29,11 @@ permission: "yc.pro"
actions:
- "[CONSOLE] say %player_name% 选择了 Pro会员前缀 !"
+description: # 描述 [非必须]
+ - "&f尊贵的Pro会员专属称号。"
+ - "&f您将获得多种特权与更好的游戏体验。"
+ - "&f您可以输入 &b/vip &f指令查看详细特权!"
+
# 该前缀的GUI物品配置
# 物品配置方式详见 https://github.com/CryptoMorin/XSeries/wiki/XItemStack
item:
@@ -37,30 +42,24 @@ item:
# 当用户有权限且未选中时,会显示该物品
has-perm:
material: DIAMOND
- name: "&b&lPro &b会员前缀"
+ name: "%(name)"
lore:
- "&7Pro会员专属称号"
- - ""
- - "&f尊贵的Pro会员专属称号。"
- - "&f您将获得多种特权与更好的游戏体验。"
- - ""
+ - "#desciption#{1,1}"
- "&a➥ 点击切换到该前缀"
# 正在使用时显示的物品 [非必需]
# 当用户正在使用时会显示这个物品,不配置即自动加载“itemHasPermission”
using:
material: DIAMOND
- name: "&b&lPro &b会员前缀"
+ name: "%(name)"
flags:
- HIDE_ENCHANTS # 隐藏附魔显示
enchants:
PROTECTION_ENVIRONMENTAL: 1 #加一个附魔这样看上去就像是选中了的
lore:
- "&7Pro会员专属称号"
- - ""
- - "&f尊贵的Pro会员专属称号。"
- - "&f您将获得多种特权与更好的游戏体验。"
- - ""
+ - "#desciption#{1,1}"
- "&a✔ 您正在使用该前缀"
# 没有权限时显示的物品 [非必需]
@@ -68,12 +67,8 @@ item:
no-perm:
material: INK_SACK
data: 8
- name: "&b&lPro+ &b会员前缀 &c(未拥有)"
+ name: "%(name) &c(未拥有)"
lore:
- - "&7Pro+会员专属称号"
- - ""
- - "&f尊贵的Pro会员专属称号。"
- - "&f您将获得多种特权与更好的游戏体验。"
- - "&f您可以输入 &b/vip &f指令查看详细特权!"
- - ""
- - "&e✯ 加入Pro+会员以使用该前缀!"
+ - "&7Pro 会员专属称号"
+ - "#desciption#{1,1}"
+ - "&e✯ 加入Pro会员以使用该前缀!"