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 f3b681dd..2210c868 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 @@ -42,6 +42,15 @@ public class SkillTreeViewer extends EditableInventory { if (function.equals("skill-tree")) { return new SkillTreeItem(config); } + if (function.equals("up")) + return new SimplePlaceholderItem(config); + if (function.equals("left")) + return new SimplePlaceholderItem(config); + if (function.equals("down")) + return new SimplePlaceholderItem(config); + if (function.equals("right")) + return new SimplePlaceholderItem(config); + if (function.equals("reallocation")) return new InventoryItem(config) { @@ -100,14 +109,13 @@ public class SkillTreeViewer extends EditableInventory { ItemMeta meta = item.getItemMeta(); meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); meta.setDisplayName(skillTree.getName()); - Placeholders holders= getPlaceholders(inv,n); + Placeholders holders = getPlaceholders(inv, n); List lore = new ArrayList<>(); getLore().forEach(string -> { if (string.contains("{tree-lore}")) { lore.addAll(skillTree.getLore()); - } - else - lore.add(holders.apply(inv.getPlayer(),string)); + } else + lore.add(holders.apply(inv.getPlayer(), string)); }); meta.setLore(lore); PersistentDataContainer container = meta.getPersistentDataContainer(); @@ -323,6 +331,24 @@ public class SkillTreeViewer extends EditableInventory { treeListPage++; open(); } + if (item.getFunction().equals("up")) { + y--; + open(); + + } + if (item.getFunction().equals("right")) { + x++; + open(); + } + if (item.getFunction().equals("down")) { + y++; + open(); + } + if (item.getFunction().equals("left")) { + x--; + open(); + } + if (item.getFunction().equals("previous-tree-list-page")) { treeListPage--; @@ -373,21 +399,11 @@ public class SkillTreeViewer extends EditableInventory { } if (item.getFunction().equals("skill-tree-node")) { - - if (event.getClickType() == ClickType.RIGHT) { - int offset = event.getSlot(); - int xOffset = offset % 9 - middleSlot % 9; - int yOffset = offset / 9 - middleSlot / 9; - x += xOffset; - y += yOffset - 1; - open(); - event.setCancelled(true); - return; - } else if (event.getClickType() == ClickType.LEFT) { + if (event.getClickType() == ClickType.LEFT) { PersistentDataContainer container = event.getItemStack().getItemMeta().getPersistentDataContainer(); int x = container.get(new NamespacedKey(MMOCore.plugin, "coordinates.x"), PersistentDataType.INTEGER); int y = container.get(new NamespacedKey(MMOCore.plugin, "coordinates.y"), PersistentDataType.INTEGER); - if(!skillTree.isNode(new IntegerCoordinates(x,y))) { + if (!skillTree.isNode(new IntegerCoordinates(x, y))) { event.setCancelled(true); return; } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java index 39868ac4..17721011 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java @@ -97,7 +97,8 @@ public class ClassSkill implements CooldownObject { private String applyPlaceholders(Map placeholders, String str) { while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) { String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}")); - str = str.replace("{" + holder + "}", placeholders.getOrDefault(holder, "PHE")); + if(placeholders.containsKey(holder)) + str = str.replace("{" + holder + "}",placeholders.get(holder)); } return str; } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/tree/SkillTreeNode.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/tree/SkillTreeNode.java index a5ff29c5..98e1db85 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/tree/SkillTreeNode.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/tree/SkillTreeNode.java @@ -69,7 +69,7 @@ public class SkillTreeNode implements Unlockable, ExperienceObject { maxLevel = config.contains("max-level") ? config.getInt("max-level") : 1; maxChildren = config.contains("max-children") ? config.getInt("max-children") : 1; - //If coordinates are precised adn we are not wiht an automaticTree we set them up + //If coordinates are precised adn we are not with an automaticTree we set them up if ((!(tree instanceof AutomaticSkillTree))) { Validate.isTrue(config.contains("coordinates.x") && config.contains("coordinates.y"), "No coordinates specified"); coordinates = new IntegerCoordinates(config.getInt("coordinates.x"), config.getInt("coordinates.y")); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/tree/skilltree/AutomaticSkillTree.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/tree/skilltree/AutomaticSkillTree.java index c327422a..17374ba6 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/tree/skilltree/AutomaticSkillTree.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/tree/skilltree/AutomaticSkillTree.java @@ -28,19 +28,19 @@ public class AutomaticSkillTree extends SkillTree { //We setup the children and parents for each node. for (SkillTreeNode node : nodes.values()) { - ConfigurationSection section = config.getConfigurationSection("nodes." + node.getId() + ".children.soft"); + ConfigurationSection section = config.getConfigurationSection("nodes." + node.getId() + ".parents.soft"); if (section != null) { - for (String child : section.getKeys(false)) { - node.addChild(getNode(child)); - getNode(child).addParent(node, section.getInt(child), ParentType.SOFT); + for (String parent : section.getKeys(false)) { + node.addParent(getNode(parent),section.getInt(parent),ParentType.SOFT); + getNode(parent).addChild(node); } } - section = config.getConfigurationSection("nodes." + node.getId() + ".children.strong"); + section = config.getConfigurationSection("nodes." + node.getId() + ".parents.strong"); if (section != null) { - for (String child : section.getKeys(false)) { - node.addChild(getNode(child)); - getNode(child).addParent(node, section.getInt(child), ParentType.STRONG); + for (String parent : section.getKeys(false)) { + node.addParent(getNode(parent),section.getInt(parent),ParentType.STRONG); + getNode(parent).addChild(node); } } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/tree/skilltree/CustomSkillTree.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/tree/skilltree/CustomSkillTree.java index 98ad0ed4..dcbb4da5 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/tree/skilltree/CustomSkillTree.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/tree/skilltree/CustomSkillTree.java @@ -26,21 +26,18 @@ public class CustomSkillTree extends SkillTree { //We setup the children and parents for each node. for (SkillTreeNode node : nodes.values()) { - ConfigurationSection section = config.getConfigurationSection("nodes."+node.getId() + ".children.soft"); + ConfigurationSection section = config.getConfigurationSection("nodes."+node.getId() + ".parents.soft"); if (section != null) { - for (String child : section.getKeys(false)) { - Validate.isTrue(isNode(child),"The node "+child+ "defined in children.soft of"+node.getId()+"doesn't exist."); - node.addChild(getNode(child)); - getNode(child).addParent(node, section.getInt(child), ParentType.SOFT); + for (String parent : section.getKeys(false)) { + node.addParent(getNode(parent),section.getInt(parent),ParentType.SOFT); + getNode(parent).addChild(node); } } - section = config.getConfigurationSection("nodes."+node.getId() + ".children.strong"); + section = config.getConfigurationSection("nodes."+node.getId() + ".parents.strong"); if (section != null) { - for (String child : section.getKeys(false)) { - Validate.isTrue(isNode(child),"The node "+child+ "defined in children.strong of"+node.getId()+"doesn't exist."); - - node.addChild(getNode(child)); - getNode(child).addParent(node, section.getInt(child), ParentType.STRONG); + for (String parent : section.getKeys(false)) { + node.addParent(getNode(parent),section.getInt(parent),ParentType.STRONG); + getNode(parent).addChild(node); } } } diff --git a/pom.xml b/pom.xml index 867ca9e9..3f4295af 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ Offer your players a brand new RPG experience!! - 1.10.1-SNAPSHOT + 1.10.2-SNAPSHOT false false UTF-8