forked from Upstream/mmocore
Fixed issue #792 by adding the possibility to put a "custom-model-data" for skill trees.
This commit is contained in:
parent
56a84015ac
commit
4de49070a0
@ -1,5 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.gui;
|
package net.Indyuce.mmocore.gui;
|
||||||
|
|
||||||
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.skilltree.NodeStatus;
|
import net.Indyuce.mmocore.skilltree.NodeStatus;
|
||||||
@ -120,6 +121,8 @@ public class SkillTreeViewer extends EditableInventory {
|
|||||||
lore.add(holders.apply(inv.getPlayer(), string));
|
lore.add(holders.apply(inv.getPlayer(), string));
|
||||||
});
|
});
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
|
if (MythicLib.plugin.getVersion().isStrictlyHigher(1, 13))
|
||||||
|
meta.setCustomModelData(skillTree.getCustomModelData());
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
container.set(new NamespacedKey(MMOCore.plugin, "skill-tree-id"), PersistentDataType.STRING, skillTree.getId());
|
container.set(new NamespacedKey(MMOCore.plugin, "skill-tree-id"), PersistentDataType.STRING, skillTree.getId());
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
@ -39,6 +39,8 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
|
|||||||
private final String id, name;
|
private final String id, name;
|
||||||
private final List<String> lore = new ArrayList<>();
|
private final List<String> lore = new ArrayList<>();
|
||||||
private final Material item;
|
private final Material item;
|
||||||
|
private final int customModelData;
|
||||||
|
|
||||||
//2 different maps to get the nodes
|
//2 different maps to get the nodes
|
||||||
|
|
||||||
//Represents all the coordinates that will be displayed as a path (between 2 nodes of the tree)
|
//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"));
|
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)));
|
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.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");
|
Validate.isTrue(config.isConfigurationSection("nodes"), "Could not find any nodes in the tree");
|
||||||
this.maxPointSpent = config.getInt("max-point-spent", Integer.MAX_VALUE);
|
this.maxPointSpent = config.getInt("max-point-spent", Integer.MAX_VALUE);
|
||||||
for (String key : config.getConfigurationSection("nodes").getKeys(false)) {
|
for (String key : config.getConfigurationSection("nodes").getKeys(false)) {
|
||||||
@ -148,6 +151,10 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
|
|||||||
return maxPointSpent;
|
return maxPointSpent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCustomModelData() {
|
||||||
|
return customModelData;
|
||||||
|
}
|
||||||
|
|
||||||
public static SkillTree loadSkillTree(ConfigurationSection config) {
|
public static SkillTree loadSkillTree(ConfigurationSection config) {
|
||||||
SkillTree skillTree = null;
|
SkillTree skillTree = null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user