From 4de49070a019f4b1b8c0e0316c0c75ad6b5283e7 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Sun, 16 Apr 2023 18:29:39 +0100 Subject: [PATCH] Fixed issue #792 by adding the possibility to put a "custom-model-data" for skill trees. --- .../main/java/net/Indyuce/mmocore/gui/SkillTreeViewer.java | 3 +++ .../java/net/Indyuce/mmocore/skilltree/tree/SkillTree.java | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillTreeViewer.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillTreeViewer.java index 34d05689..2c3d0208 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillTreeViewer.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillTreeViewer.java @@ -1,5 +1,6 @@ package net.Indyuce.mmocore.gui; +import io.lumine.mythic.lib.MythicLib; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.skilltree.NodeStatus; @@ -120,6 +121,8 @@ public class SkillTreeViewer extends EditableInventory { lore.add(holders.apply(inv.getPlayer(), string)); }); meta.setLore(lore); + if (MythicLib.plugin.getVersion().isStrictlyHigher(1, 13)) + meta.setCustomModelData(skillTree.getCustomModelData()); PersistentDataContainer container = meta.getPersistentDataContainer(); container.set(new NamespacedKey(MMOCore.plugin, "skill-tree-id"), PersistentDataType.STRING, skillTree.getId()); item.setItemMeta(meta); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/tree/SkillTree.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/tree/SkillTree.java index be9c3980..afc2db25 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/tree/SkillTree.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/tree/SkillTree.java @@ -39,6 +39,8 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje private final String id, name; private final List lore = new ArrayList<>(); private final Material item; + private final int customModelData; + //2 different maps to get the nodes //Represents all the coordinates that will be displayed as a path (between 2 nodes of the tree) @@ -59,6 +61,7 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje this.name = MythicLib.plugin.parseColors(Objects.requireNonNull(config.getString("name"), "Could not find skill tree name")); Objects.requireNonNull(config.getStringList("lore"), "Could not find skill tree lore").forEach(str -> lore.add(MythicLib.plugin.parseColors(str))); this.item = Material.valueOf(UtilityMethods.enumName(Objects.requireNonNull(config.getString("item")))); + this.customModelData = config.getInt("custom-model-data", 0); Validate.isTrue(config.isConfigurationSection("nodes"), "Could not find any nodes in the tree"); this.maxPointSpent = config.getInt("max-point-spent", Integer.MAX_VALUE); for (String key : config.getConfigurationSection("nodes").getKeys(false)) { @@ -148,6 +151,10 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje return maxPointSpent; } + public int getCustomModelData() { + return customModelData; + } + public static SkillTree loadSkillTree(ConfigurationSection config) { SkillTree skillTree = null;