forked from Upstream/mmocore
Bug Fixing for the specific display associated to each node.
This commit is contained in:
parent
5fdfc36fcc
commit
523f910113
@ -8,6 +8,7 @@ import net.Indyuce.mmocore.experience.ExpCurve;
|
|||||||
import net.Indyuce.mmocore.experience.ExperienceObject;
|
import net.Indyuce.mmocore.experience.ExperienceObject;
|
||||||
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
||||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||||
|
import net.Indyuce.mmocore.gui.skilltree.display.Icon;
|
||||||
import net.Indyuce.mmocore.skilltree.tree.SkillTree;
|
import net.Indyuce.mmocore.skilltree.tree.SkillTree;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -23,8 +24,8 @@ public class SkillTreeNode implements ExperienceObject {
|
|||||||
private final SkillTree tree;
|
private final SkillTree tree;
|
||||||
private final String name, id;
|
private final String name, id;
|
||||||
|
|
||||||
private Material item;
|
private final Map<NodeStatus, Icon> icons = new HashMap<>();
|
||||||
private int customModelData;
|
|
||||||
private IntegerCoordinates coordinates;
|
private IntegerCoordinates coordinates;
|
||||||
/**
|
/**
|
||||||
* The number of skill tree points this node requires.
|
* The number of skill tree points this node requires.
|
||||||
@ -61,9 +62,15 @@ public class SkillTreeNode implements ExperienceObject {
|
|||||||
Validate.notNull(config, "Config cannot be null");
|
Validate.notNull(config, "Config cannot be null");
|
||||||
this.id = config.getName();
|
this.id = config.getName();
|
||||||
this.tree = tree;
|
this.tree = tree;
|
||||||
if(config.contains("item"))
|
if (config.isConfigurationSection("display")) {
|
||||||
item = Material.valueOf(config.getString("item"));
|
for (NodeStatus status : NodeStatus.values()) {
|
||||||
customModelData= config.getInt("custom-model-data",0);
|
if (!config.isConfigurationSection("display." + status.name().toLowerCase())) {
|
||||||
|
MMOCore.log("Could not find node display for status " + status.name().toLowerCase() + " for node " + id + " in tree " + tree.getId() + ". Using default display.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
icons.put(status, new Icon(config.getConfigurationSection("display." + status.name().toLowerCase())));
|
||||||
|
}
|
||||||
|
}
|
||||||
name = Objects.requireNonNull(config.getString("name"), "Could not find node name");
|
name = Objects.requireNonNull(config.getString("name"), "Could not find node name");
|
||||||
size = Objects.requireNonNull(config.getInt("size"));
|
size = Objects.requireNonNull(config.getInt("size"));
|
||||||
isRoot = config.getBoolean("is-root", false);
|
isRoot = config.getBoolean("is-root", false);
|
||||||
@ -91,12 +98,12 @@ public class SkillTreeNode implements ExperienceObject {
|
|||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material getItem() {
|
public boolean hasIcon(NodeStatus status) {
|
||||||
return item;
|
return icons.containsKey(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCustomModelData() {
|
public Icon getIcon(NodeStatus status) {
|
||||||
return customModelData;
|
return icons.get(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsRoot() {
|
public void setIsRoot() {
|
||||||
|
Loading…
Reference in New Issue
Block a user