Take in account class based skill tree in the GUI

This commit is contained in:
Ka0rX 2022-10-17 06:25:44 +02:00
parent 706413e8e8
commit 0e1772d6d6

View File

@ -102,10 +102,10 @@ public class SkillTreeViewer extends EditableInventory {
@Override @Override
public ItemStack display(SkillTreeInventory inv, int n) { public ItemStack display(SkillTreeInventory inv, int n) {
int index = inv.getEditable().getByFunction("skill-tree").getSlots().size() * inv.treeListPage + n; int index = inv.getEditable().getByFunction("skill-tree").getSlots().size() * inv.treeListPage + n;
if (!MMOCore.plugin.skillTreeManager.has(index)) { if (inv.skillTrees.size()>=index) {
return new ItemStack(Material.AIR); return new ItemStack(Material.AIR);
} }
SkillTree skillTree = MMOCore.plugin.skillTreeManager.get(index); SkillTree skillTree = inv.skillTrees.get(index);
//We display with the material corresponding to the skillTree //We display with the material corresponding to the skillTree
ItemStack item = super.display(inv, n, skillTree.getItem()); ItemStack item = super.display(inv, n, skillTree.getItem());
@ -130,7 +130,7 @@ public class SkillTreeViewer extends EditableInventory {
@Override @Override
public Placeholders getPlaceholders(SkillTreeInventory inv, int n) { public Placeholders getPlaceholders(SkillTreeInventory inv, int n) {
int index = inv.getEditable().getByFunction("skill-tree").getSlots().size() * inv.treeListPage + n; int index = inv.getEditable().getByFunction("skill-tree").getSlots().size() * inv.treeListPage + n;
SkillTree skillTree = MMOCore.plugin.skillTreeManager.get(index); SkillTree skillTree = inv.skillTrees.get(index);
Placeholders holders = new Placeholders(); Placeholders holders = new Placeholders();
holders.register("name", skillTree.getName()); holders.register("name", skillTree.getName());
holders.register("id", skillTree.getId()); holders.register("id", skillTree.getId());
@ -267,6 +267,7 @@ public class SkillTreeViewer extends EditableInventory {
private final int width, height; private final int width, height;
private int treeListPage; private int treeListPage;
private final int maxTreeListPage; private final int maxTreeListPage;
private final List<SkillTree> skillTrees;
private final SkillTree skillTree; private final SkillTree skillTree;
private final List<Integer> slots; private final List<Integer> slots;
@ -274,7 +275,8 @@ public class SkillTreeViewer extends EditableInventory {
super(playerData, editable); super(playerData, editable);
skillTree = playerData.getOpenedSkillTree(); skillTree = playerData.getOpenedSkillTree();
maxTreeListPage = (MMOCore.plugin.skillTreeManager.getAll().size() - 1) / editable.getByFunction("skill-tree").getSlots().size(); skillTrees=playerData.getProfess().getSkillTrees();
maxTreeListPage = (skillTrees.size() - 1) / editable.getByFunction("skill-tree").getSlots().size();
//We get the width and height of the GUI(corresponding to the slots given) //We get the width and height of the GUI(corresponding to the slots given)
slots = editable.getByFunction("skill-tree-node").getSlots(); slots = editable.getByFunction("skill-tree-node").getSlots();
minSlot = 64; minSlot = 64;