mirror of
https://github.com/CarmJos/UserPrefix.git
synced 2024-09-19 20:15:47 +00:00
chore(item): 更换物品的配置逻辑,支持跨版本的物品读取、保存。
BREAKING-CHANGE: 旧的配置文件需要进行变更。
This commit is contained in:
parent
7d62f68662
commit
12489fe1a8
@ -87,7 +87,6 @@ public class PrefixConfig {
|
|||||||
|
|
||||||
@Contract("_,!null->!null")
|
@Contract("_,!null->!null")
|
||||||
protected @Nullable ItemStack getItem(@Nullable Player player, @Nullable ItemStack item) {
|
protected @Nullable ItemStack getItem(@Nullable Player player, @Nullable ItemStack item) {
|
||||||
if (item == null) return null;
|
|
||||||
return PreparedItem.of(item).get(player);
|
return PreparedItem.of(item).get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ 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 {
|
||||||
|
|
||||||
@ -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)) {
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ item:
|
|||||||
# itemHasPermission [Necesario]
|
# itemHasPermission [Necesario]
|
||||||
# Este elemento se mostrará cuando el jugador tenga permiso
|
# Este elemento se mostrará cuando el jugador tenga permiso
|
||||||
has-perm:
|
has-perm:
|
||||||
type: DIAMOND
|
material: DIAMOND
|
||||||
name: "&b&lVIP Prefix"
|
name: "&b&lVIP Prefix"
|
||||||
lore:
|
lore:
|
||||||
- ""
|
- ""
|
||||||
@ -38,7 +38,7 @@ item:
|
|||||||
# Este elemento se mostrará cuando se seleccione el prefijo.
|
# Este elemento se mostrará cuando se seleccione el prefijo.
|
||||||
# Si no existe tal configuración, se mostrará automáticamente "itemHasPermission".
|
# Si no existe tal configuración, se mostrará automáticamente "itemHasPermission".
|
||||||
using:
|
using:
|
||||||
type: DIAMOND
|
material: DIAMOND
|
||||||
name: "&b&lVIP Prefix"
|
name: "&b&lVIP Prefix"
|
||||||
enchants:
|
enchants:
|
||||||
PROTECTION_ENVIRONMENTAL: 1 #Añade un encantamiento para que parezca que está seleccionado
|
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 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.
|
# Si este elemento no está configurado, no se mostrará en la GUI cuando el jugador no tenga permiso para usarlo.
|
||||||
no-perm:
|
no-perm:
|
||||||
type: INK_SACK
|
material: INK_SACK
|
||||||
data: 8
|
data: 8
|
||||||
name: "&b&lVIP &c(¡Cómpralo!)"
|
name: "&b&lVIP &c(¡Cómpralo!)"
|
||||||
lore:
|
lore:
|
||||||
|
@ -31,7 +31,7 @@ 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 +41,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 +53,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:
|
||||||
|
@ -35,7 +35,7 @@ item:
|
|||||||
# 有权限时显示的物品 [必须]
|
# 有权限时显示的物品 [必须]
|
||||||
# 当用户有权限且未选中时,会显示该物品
|
# 当用户有权限且未选中时,会显示该物品
|
||||||
has-perm:
|
has-perm:
|
||||||
type: DIAMOND
|
material: DIAMOND
|
||||||
name: "&b&lPro &b会员前缀"
|
name: "&b&lPro &b会员前缀"
|
||||||
lore:
|
lore:
|
||||||
- "&7Pro会员专属称号"
|
- "&7Pro会员专属称号"
|
||||||
@ -48,7 +48,7 @@ item:
|
|||||||
# 正在使用时显示的物品 [非必需]
|
# 正在使用时显示的物品 [非必需]
|
||||||
# 当用户正在使用时会显示这个物品,不配置即自动加载“itemHasPermission”
|
# 当用户正在使用时会显示这个物品,不配置即自动加载“itemHasPermission”
|
||||||
using:
|
using:
|
||||||
type: DIAMOND
|
material: DIAMOND
|
||||||
name: "&b&lPro &b会员前缀"
|
name: "&b&lPro &b会员前缀"
|
||||||
flags:
|
flags:
|
||||||
- HIDE_ENCHANTS # 隐藏附魔显示
|
- HIDE_ENCHANTS # 隐藏附魔显示
|
||||||
@ -65,7 +65,7 @@ item:
|
|||||||
# 没有权限时显示的物品 [非必需]
|
# 没有权限时显示的物品 [非必需]
|
||||||
# 如果没有权限就会显示这个item。如果不配置该物品,则玩家没有使用权限时不会显示在GUI里面。
|
# 如果没有权限就会显示这个item。如果不配置该物品,则玩家没有使用权限时不会显示在GUI里面。
|
||||||
no-perm:
|
no-perm:
|
||||||
type: INK_SACK
|
material: INK_SACK
|
||||||
data: 8
|
data: 8
|
||||||
name: "&b&lPro+ &b会员前缀 &c(未拥有)"
|
name: "&b&lPro+ &b会员前缀 &c(未拥有)"
|
||||||
lore:
|
lore:
|
||||||
|
Loading…
Reference in New Issue
Block a user