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 45c557b..f55da23 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 @@ -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); } 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 c2606a4..9e643b0 100644 --- a/src/main/java/cc/carm/plugin/userprefix/ui/PrefixSelectGUI.java +++ b/src/main/java/cc/carm/plugin/userprefix/ui/PrefixSelectGUI.java @@ -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)) { diff --git a/src/main/resources/ejemplo-prefijo.yml b/src/main/resources/ejemplo-prefijo.yml index e36ed2c..5d77ab9 100644 --- a/src/main/resources/ejemplo-prefijo.yml +++ b/src/main/resources/ejemplo-prefijo.yml @@ -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: diff --git a/src/main/resources/en_US/example-prefix.yml b/src/main/resources/en_US/example-prefix.yml index b148183..942f5f8 100644 --- a/src/main/resources/en_US/example-prefix.yml +++ b/src/main/resources/en_US/example-prefix.yml @@ -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 it’s 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: diff --git a/src/main/resources/prefixes/example-prefix.yml b/src/main/resources/prefixes/example-prefix.yml index b36f834..d6e2ce5 100644 --- a/src/main/resources/prefixes/example-prefix.yml +++ b/src/main/resources/prefixes/example-prefix.yml @@ -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: