1
mirror of https://github.com/CarmJos/UserPrefix.git synced 2024-09-19 12:05:47 +00:00

chore(item): 更换物品的配置逻辑,支持跨版本的物品读取、保存。

BREAKING-CHANGE: 旧的配置文件需要进行变更。
This commit is contained in:
Carm Jos 2023-10-12 20:09:24 +08:00
parent 7d62f68662
commit 12489fe1a8
5 changed files with 14 additions and 11 deletions

View File

@ -87,7 +87,6 @@ public class PrefixConfig {
@Contract("_,!null->!null")
protected @Nullable ItemStack getItem(@Nullable Player player, @Nullable ItemStack item) {
if (item == null) return null;
return PreparedItem.of(item).get(player);
}

View File

@ -14,6 +14,7 @@ import org.bukkit.event.inventory.ClickType;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
public class PrefixSelectGUI extends AutoPagedGUI {
@ -49,7 +50,10 @@ public class PrefixSelectGUI extends AutoPagedGUI {
for (PrefixConfig prefix : prefixList) {
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)) {
addItem(new GUIItem(prefix.getItemHasPermission(player)) {

View File

@ -28,7 +28,7 @@ item:
# itemHasPermission [Necesario]
# Este elemento se mostrará cuando el jugador tenga permiso
has-perm:
type: DIAMOND
material: DIAMOND
name: "&b&lVIP Prefix"
lore:
- ""
@ -38,7 +38,7 @@ item:
# Este elemento se mostrará cuando se seleccione el prefijo.
# Si no existe tal configuración, se mostrará automáticamente "itemHasPermission".
using:
type: DIAMOND
material: DIAMOND
name: "&b&lVIP Prefix"
enchants:
PROTECTION_ENVIRONMENTAL: 1 #Añade un encantamiento para que parezca que está seleccionado
@ -50,7 +50,7 @@ item:
# 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:
type: INK_SACK
material: INK_SACK
data: 8
name: "&b&lVIP &c(¡Cómpralo!)"
lore:

View File

@ -31,7 +31,7 @@ item:
# itemHasPermission [Necessary]
# This Item will be displayed when player has permission
has-perm:
type: DIAMOND
material: DIAMOND
name: "&b&lVIP Prefix"
lore:
- ""
@ -41,7 +41,7 @@ item:
# This Item will be displayed when the prefix is selected.
# If there is no such configuration, it will automatically display "itemHasPermission".
using:
type: DIAMOND
material: DIAMOND
name: "&b&lVIP Prefix"
enchants:
PROTECTION_ENVIRONMENTAL: 1 #Add an enchantment so it looks like its selected
@ -53,7 +53,7 @@ item:
# 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.
no-perm:
type: INK_SACK
material: INK_SACK
data: 8
name: "&b&lVIP &c(Buy it!)"
lore:

View File

@ -35,7 +35,7 @@ item:
# 有权限时显示的物品 [必须]
# 当用户有权限且未选中时,会显示该物品
has-perm:
type: DIAMOND
material: DIAMOND
name: "&b&lPro &b会员前缀"
lore:
- "&7Pro会员专属称号"
@ -48,7 +48,7 @@ item:
# 正在使用时显示的物品 [非必需]
# 当用户正在使用时会显示这个物品不配置即自动加载“itemHasPermission”
using:
type: DIAMOND
material: DIAMOND
name: "&b&lPro &b会员前缀"
flags:
- HIDE_ENCHANTS # 隐藏附魔显示
@ -65,7 +65,7 @@ item:
# 没有权限时显示的物品 [非必需]
# 如果没有权限就会显示这个item。如果不配置该物品则玩家没有使用权限时不会显示在GUI里面。
no-perm:
type: INK_SACK
material: INK_SACK
data: 8
name: "&b&lPro+ &b会员前缀 &c(未拥有)"
lore: