From 40b59e4b708f11c8e3d9691ee258fd5966ef63e3 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Wed, 6 Sep 2023 15:18:25 +0100 Subject: [PATCH] Added the possibilty to have force a specific item to appear when a skill is bound to a slot for the skill UI. --- .../net/Indyuce/mmocore/gui/SkillList.java | 30 ++++++++++++------- .../main/resources/default/gui/skill-list.yml | 9 ++++-- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillList.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillList.java index 612be472..7fb8041f 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillList.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillList.java @@ -172,12 +172,17 @@ public class SkillList extends EditableInventory { public class SlotItem extends InventoryItem { private final String none; - private final int emptyCMD; + @Nullable + private final Material filledItem; + private final int filledCMD; public SlotItem(ConfigurationSection config) { super(config); none = MythicLib.plugin.parseColors(config.getString("no-skill")); - emptyCMD = config.getInt("empty-custom-model-data", getModelData()); + + filledItem = config.contains("filled-item") ? Material + .valueOf(config.getString("filled-item").toUpperCase().replace("-", "_").replace(" ", "_")) : null; + filledCMD = config.getInt("filled-custom-model-data", getModelData()); } @Override @@ -187,13 +192,21 @@ public class SkillList extends EditableInventory { return new ItemStack(Material.AIR); final @Nullable ClassSkill boundSkill = inv.getPlayerData().getBoundSkill(n + 1); - final ItemStack item = super.display(inv, n); + ItemStack item; + if (boundSkill == null) + item = super.display(inv, n); + else if (filledItem == null) + item = boundSkill.getSkill().getIcon(); + else { + item = new ItemStack(filledItem); + if (MythicLib.plugin.getVersion().isStrictlyHigher(1, 13)) { + ItemMeta meta = item.getItemMeta(); + meta.setCustomModelData(filledCMD); + item.setItemMeta(meta); + } + } Placeholders holders = getPlaceholders(inv, n); - // Same material as skill - if (boundSkill != null) - item.setType(boundSkill.getSkill().getIcon().getType()); - final ItemMeta meta = item.getItemMeta(); meta.setDisplayName(MMOCore.plugin.placeholderParser.parse(inv.getPlayerData().getPlayer(), skillSlot.getName())); @@ -217,9 +230,6 @@ public class SkillList extends EditableInventory { for (int j = 0; j < lore.size(); j++) lore.set(j, ChatColor.GRAY + holders.apply(inv.getPlayer(), lore.get(j))); meta.setLore(lore); - // Same CMD as skill icon - if (boundSkill != null && boundSkill.getSkill().getIcon().hasItemMeta() && boundSkill.getSkill().getIcon().getItemMeta().hasCustomModelData()) - meta.setCustomModelData(boundSkill.getSkill().getIcon().getItemMeta().getCustomModelData()); item.setItemMeta(meta); return item; diff --git a/MMOCore-Dist/src/main/resources/default/gui/skill-list.yml b/MMOCore-Dist/src/main/resources/default/gui/skill-list.yml index c2d561c3..c0ff1983 100644 --- a/MMOCore-Dist/src/main/resources/default/gui/skill-list.yml +++ b/MMOCore-Dist/src/main/resources/default/gui/skill-list.yml @@ -7,7 +7,7 @@ slots: 54 items: skill: - slots: [ 10,11,12,19,20,21,28,29,30,37,38,39] + slots: [ 10,11,12,19,20,21,28,29,30,37,38,39 ] function: skill name: '&a{skill} &6[{level}]' @@ -34,7 +34,7 @@ items: lore: { } reallocate: - slots: [45] + slots: [ 45 ] function: reallocation item: CAULDRON name: '&aReallocate Skill Points' @@ -53,6 +53,11 @@ items: name: '&aSkill Slot {slot}' no-skill: '&cNone' + + #If this is filled, the item shown in the GUI when a slot is filled will be the item specified here. + #Else it will be the display item of the bound skill. + #filled-item: + #filled-custom-model-data: lore: - '&7Current Skill: &6{skill}' - ''