From 90706ae97c18d87c11c1b40dea2934fc9986b263 Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 8 Oct 2023 01:22:44 +0200 Subject: [PATCH] Default color for skill tree node names --- .../mmocore/gui/api/item/InventoryItem.java | 1 - .../gui/skilltree/SkillTreeViewer.java | 3 +- .../mmocore/skilltree/SkillTreeNode.java | 6 ++-- .../main/resources/default/gui/skill-tree.yml | 29 +++++++++---------- .../specific-skill-tree-default.yml | 18 ++++++------ 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java index cf13065e..41a49334 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java @@ -112,7 +112,6 @@ public abstract class InventoryItem { inv.setItem(slot, display); } else for (int j = 0; j < slots.size(); j++) inv.setItem(slots.get(j), display(generated, j)); - } public boolean hasDifferentDisplay() { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java index e7532f7f..ee774ee2 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java @@ -263,7 +263,8 @@ public class SkillTreeViewer extends EditableInventory { lore.add(holders.apply(inv.getPlayer(), str)); }); meta.setLore(lore); - meta.setDisplayName(node.getName()); + final String name = meta.getDisplayName(); + meta.setDisplayName(name == null || name.isEmpty() ? node.getName() : name); } //If it is path we remove the display name and the lore. else { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java index 8e670950..42dce8eb 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java @@ -85,8 +85,8 @@ public class SkillTreeNode implements ExperienceObject { for (String key : config.getConfigurationSection("lores").getKeys(false)) try { lores.put(Integer.parseInt(key), config.getStringList("lores." + key)); - } catch (NumberFormatException e) { - throw new RuntimeException("You must only specifiy integers in lores."); + } catch (NumberFormatException exception) { + throw new RuntimeException("You shall only specify integers in the 'lores' config section"); } Validate.isTrue(config.contains("experience-table"), "You must specify an exp table"); @@ -232,7 +232,6 @@ public class SkillTreeNode implements ExperienceObject { return NodeType.getNodeType(hasUpPathOrNode, hasRightPathOrNode, hasDownPathOrNode, hasLeftPathOrNode); } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -261,6 +260,7 @@ public class SkillTreeNode implements ExperienceObject { List parsedLore = new ArrayList<>(); if (!lores.containsKey(playerData.getNodeLevel(this))) return parsedLore; + List lore = lores.get(playerData.getNodeLevel(this)); lore.forEach(string -> parsedLore.add( MythicLib.plugin.parseColors(holders.apply(playerData.getPlayer(), string)))); diff --git a/MMOCore-Dist/src/main/resources/default/gui/skill-tree.yml b/MMOCore-Dist/src/main/resources/default/gui/skill-tree.yml index 37f31414..4ebbfeed 100644 --- a/MMOCore-Dist/src/main/resources/default/gui/skill-tree.yml +++ b/MMOCore-Dist/src/main/resources/default/gui/skill-tree.yml @@ -38,14 +38,11 @@ items: slots: [ 9,18,27 ] lore: - '' - - '&aDescription:' - '{tree-lore}' - '' - - '--------------------' - - '&e◆Max points&e: &6{max-point-spent}' - - '&e◆Points spent&e:&6 {point-spent}' - - '&e◆Current {name} &epoints: &6{skill-tree-points}' - - '&e◆Current Global points: &6{global-points}' + - '&e◆ Points: &6{max-point-spent}&e/&6{point-spent}' + - '&e◆ Current {name} &ePoints: &6{skill-tree-points}' + - '&e◆ Current Global Points: &6{global-points}' next-tree-list-page: function: 'next-tree-list-page' @@ -77,6 +74,7 @@ items: function: 'skill-tree-node' slots: [ 1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,28,29,30,31,32,33,34,35,37,38,39,40,41,42,43,44 ] + name: '&a{name}' #The lore that will be displayed after the lore of the node. #The {node-lore} placeholder will be replaced by the lore specified in the skill tree node config. #All the placeholders you see here can also be used in the node lore. @@ -86,24 +84,23 @@ items: - '&7Current Level: &6{current-level}' - '&7Max Level: &6{max-level}' - '&7Max Children: &6{max-children}' - - '&7Points required: &6{point-consumed}' + - '&7Points Required: &6{point-consumed}' - '&7Size: &6{size}' - - '--------------------' + - '' - '&7⧆ &6Requirements: ' - '&fStrong Parents: ' - '{strong-parents}' - '' - '&fSoft Parents: ' - '{soft-parents}' - - '--------------------' - - '{node-lore}' - - '--------------------' - - '&e◆Max points for {skill-tree}&e: &6{max-point-spent}' - - '&e◆Points spent for {skill-tree}&e:&6 {point-spent}' - - '&e◆Current {skill-tree} &epoints: &6{skill-tree-points}' - - '&e◆Current &6global&e points: &6{global-points}' - path-lore: - '' + - '{node-lore}' + - '' + - '&e◆ Max points for {skill-tree}&e: &6{max-point-spent}' + - '&e◆ Points spent for {skill-tree}&e:&6 {point-spent}' + - '&e◆ Current {skill-tree} &ePoints: &6{skill-tree-points}' + - '&e◆ Current &6global&e points: &6{global-points}' + path-lore: [] #This is the name that will be displayed for each status. status-names: diff --git a/MMOCore-Dist/src/main/resources/default/gui/specific-skill-tree/specific-skill-tree-default.yml b/MMOCore-Dist/src/main/resources/default/gui/specific-skill-tree/specific-skill-tree-default.yml index bd169b6c..8c341f01 100644 --- a/MMOCore-Dist/src/main/resources/default/gui/specific-skill-tree/specific-skill-tree-default.yml +++ b/MMOCore-Dist/src/main/resources/default/gui/specific-skill-tree/specific-skill-tree-default.yml @@ -50,6 +50,7 @@ items: function: 'skill-tree-node' slots: [ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44 ] + name: '&a{name}' #The lore that will be displayed after the lore of the node. #The {node-lore} placeholder will be replaced by the lore specified in the skill tree node config. #All the placeholders you see here can also be used in the node lore. @@ -61,22 +62,21 @@ items: - '&7Max Children: &6{max-children}' - '&7Points required: &6{point-consumed}' - '&7Size: &6{size}' - - '--------------------' + - '' - '&7⧆ &6Requirements: ' - '&fStrong Parents: ' - '{strong-parents}' - '' - '&fSoft Parents: ' - '{soft-parents}' - - '--------------------' - - '{node-lore}' - - '--------------------' - - '&e◆Max points for {skill-tree}&e: &6{max-point-spent}' - - '&e◆Points spent for {skill-tree}&e:&6 {point-spent}' - - '&e◆Current {skill-tree} &epoints: &6{skill-tree-points}' - - '&e◆Current &6global&e points: &6{global-points}' - path-lore: - '' + - '{node-lore}' + - '' + - '&e◆ Max points for {skill-tree}&e: &6{max-point-spent}' + - '&e◆ Points spent for {skill-tree}&e:&6 {point-spent}' + - '&e◆ Current {skill-tree} &epoints: &6{skill-tree-points}' + - '&e◆ Current &6global&e points: &6{global-points}' + path-lore: [] #This is the name that will be displayed for each status. status-names: