Debug skill Tree & Debug PAPI

This commit is contained in:
Ka0rX 2022-08-27 15:17:52 +02:00
parent fe12e07f37
commit 90ee0c37bb
6 changed files with 52 additions and 38 deletions

View File

@ -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<SkillTreeInventory>(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<String> 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;
}

View File

@ -97,7 +97,8 @@ public class ClassSkill implements CooldownObject {
private String applyPlaceholders(Map<String, String> 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;
}

View File

@ -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"));

View File

@ -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);
}
}

View File

@ -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);
}
}
}

View File

@ -16,7 +16,7 @@
<description>Offer your players a brand new RPG experience!!</description>
<properties>
<revision>1.10.1-SNAPSHOT</revision>
<revision>1.10.2-SNAPSHOT</revision>
<downloadSources>false</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>