mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-23 00:05:52 +01:00
Removed Cached Skill Tree.
This commit is contained in:
parent
5dc69e25cd
commit
bc0c4f7283
@ -80,7 +80,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
private double mana, stamina, stellium;
|
||||
private Guild guild;
|
||||
private SkillCastingHandler skillCasting;
|
||||
private SkillTree cachedSkillTree;
|
||||
private final PlayerQuests questData;
|
||||
private final PlayerStats playerStats;
|
||||
private final List<UUID> friends = new ArrayList<>();
|
||||
@ -406,18 +405,9 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
return Math.max(1, level);
|
||||
}
|
||||
|
||||
public void setCachedSkillTree(SkillTree cachedSkillTree) {
|
||||
this.cachedSkillTree = cachedSkillTree;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SkillTree getOpenedSkillTree() {
|
||||
if (cachedSkillTree == null) {
|
||||
Optional<SkillTree> optionnal = MMOCore.plugin.skillTreeManager.getAll().stream().findFirst();
|
||||
return optionnal.isPresent() ? optionnal.get() : null;
|
||||
}
|
||||
return cachedSkillTree;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Nullable
|
||||
public AbstractParty getParty() {
|
||||
|
@ -186,7 +186,7 @@ public class SavedClassInformation {
|
||||
}
|
||||
|
||||
public int getAttributeLevel(String id) {
|
||||
return attributes.get(id);
|
||||
return attributes.getOrDefault(id,0);
|
||||
}
|
||||
|
||||
public void registerAttributeLevel(PlayerAttribute attribute, int level) {
|
||||
@ -239,6 +239,8 @@ public class SavedClassInformation {
|
||||
attributes.forEach((id, pts) -> player.getAttributes().setBaseAttribute(id, pts));
|
||||
skillTreePoints.forEach((skillTree, point) -> player.setSkillTreePoints(skillTree, point));
|
||||
nodeLevels.forEach((node, level) -> player.setNodeLevel(node, level));
|
||||
for(SkillTree skillTree: profess.getSkillTrees())
|
||||
skillTree.setupNodeState(player);
|
||||
//Add the values to the times claimed table and claims the corresponding stat triggers.
|
||||
nodeTimesClaimed.forEach((str,val)->player.setClaims(str,val));
|
||||
nodeLevels.keySet().forEach(node -> node.getExperienceTable().claimStatTriggers(player, node));
|
||||
|
@ -60,9 +60,9 @@ public class SkillTreeViewer extends EditableInventory {
|
||||
holders.register("skill-tree-points", inv.getPlayerData().getSkillTreePoint(inv.getSkillTree().getId()));
|
||||
holders.register("global-points", inv.getPlayerData().getSkillTreePoint("global"));
|
||||
holders.register("realloc-points", inv.getPlayerData().getSkillTreeReallocationPoints());
|
||||
int maxPointSpent=inv.getSkillTree().getMaxPointSpent();
|
||||
holders.register("max-point-spent",maxPointSpent==Integer.MAX_VALUE?"∞":maxPointSpent);
|
||||
holders.register("point-spent",inv.getPlayerData().getPointSpent(inv.getSkillTree()));
|
||||
int maxPointSpent = inv.getSkillTree().getMaxPointSpent();
|
||||
holders.register("max-point-spent", maxPointSpent == Integer.MAX_VALUE ? "∞" : maxPointSpent);
|
||||
holders.register("point-spent", inv.getPlayerData().getPointSpent(inv.getSkillTree()));
|
||||
|
||||
return holders;
|
||||
}
|
||||
@ -102,7 +102,7 @@ public class SkillTreeViewer extends EditableInventory {
|
||||
@Override
|
||||
public ItemStack display(SkillTreeInventory inv, int n) {
|
||||
int index = inv.getEditable().getByFunction("skill-tree").getSlots().size() * inv.treeListPage + n;
|
||||
if (inv.skillTrees.size()>=index) {
|
||||
if (inv.skillTrees.size() <= index) {
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
SkillTree skillTree = inv.skillTrees.get(index);
|
||||
@ -134,9 +134,9 @@ public class SkillTreeViewer extends EditableInventory {
|
||||
Placeholders holders = new Placeholders();
|
||||
holders.register("name", skillTree.getName());
|
||||
holders.register("id", skillTree.getId());
|
||||
int maxPointSpent=inv.getSkillTree().getMaxPointSpent();
|
||||
holders.register("max-point-spent",maxPointSpent==Integer.MAX_VALUE?"∞":maxPointSpent);
|
||||
holders.register("point-spent",inv.getPlayerData().getPointSpent(inv.getSkillTree()));
|
||||
int maxPointSpent = inv.getSkillTree().getMaxPointSpent();
|
||||
holders.register("max-point-spent", maxPointSpent == Integer.MAX_VALUE ? "∞" : maxPointSpent);
|
||||
holders.register("point-spent", inv.getPlayerData().getPointSpent(inv.getSkillTree()));
|
||||
holders.register("skill-tree-points", inv.getPlayerData().getSkillTreePoint(inv.getSkillTree().getId()));
|
||||
holders.register("global-points", inv.getPlayerData().getSkillTreePoint("global"));
|
||||
return holders;
|
||||
@ -250,9 +250,9 @@ public class SkillTreeViewer extends EditableInventory {
|
||||
holders.register("max-children", node.getMaxChildren());
|
||||
holders.register("size", node.getSize());
|
||||
}
|
||||
int maxPointSpent=inv.getSkillTree().getMaxPointSpent();
|
||||
holders.register("max-point-spent",maxPointSpent==Integer.MAX_VALUE?"∞":maxPointSpent);
|
||||
holders.register("point-spent",inv.getPlayerData().getPointSpent(inv.getSkillTree()));
|
||||
int maxPointSpent = inv.getSkillTree().getMaxPointSpent();
|
||||
holders.register("max-point-spent", maxPointSpent == Integer.MAX_VALUE ? "∞" : maxPointSpent);
|
||||
holders.register("point-spent", inv.getPlayerData().getPointSpent(inv.getSkillTree()));
|
||||
holders.register("skill-tree-points", inv.getPlayerData().getSkillTreePoint(inv.getSkillTree().getId()));
|
||||
holders.register("global-points", inv.getPlayerData().getSkillTreePoint("global"));
|
||||
return holders;
|
||||
@ -268,14 +268,14 @@ public class SkillTreeViewer extends EditableInventory {
|
||||
private int treeListPage;
|
||||
private final int maxTreeListPage;
|
||||
private final List<SkillTree> skillTrees;
|
||||
private final SkillTree skillTree;
|
||||
private SkillTree skillTree;
|
||||
private final List<Integer> slots;
|
||||
|
||||
public SkillTreeInventory(PlayerData playerData, EditableInventory editable) {
|
||||
super(playerData, editable);
|
||||
|
||||
skillTree = playerData.getOpenedSkillTree();
|
||||
skillTrees=playerData.getProfess().getSkillTrees();
|
||||
skillTrees = playerData.getProfess().getSkillTrees();
|
||||
skillTree = skillTrees.get(0);
|
||||
maxTreeListPage = (skillTrees.size() - 1) / editable.getByFunction("skill-tree").getSlots().size();
|
||||
//We get the width and height of the GUI(corresponding to the slots given)
|
||||
slots = editable.getByFunction("skill-tree-node").getSlots();
|
||||
@ -398,10 +398,9 @@ public class SkillTreeViewer extends EditableInventory {
|
||||
if (item.getFunction().equals("skill-tree")) {
|
||||
String id = event.getItemStack().getItemMeta().getPersistentDataContainer().get(
|
||||
new NamespacedKey(MMOCore.plugin, "skill-tree-id"), PersistentDataType.STRING);
|
||||
playerData.setCachedSkillTree(MMOCore.plugin.skillTreeManager.get(id));
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.CHANGE_SKILL_TREE).playTo(player);
|
||||
|
||||
newInventory(playerData).open();
|
||||
skillTree=MMOCore.plugin.skillTreeManager.get(id);
|
||||
open();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -416,7 +415,7 @@ public class SkillTreeViewer extends EditableInventory {
|
||||
return;
|
||||
}
|
||||
SkillTreeNode node = skillTree.getNode(new IntegerCoordinates(x, y));
|
||||
if(playerData.getPointSpent(skillTree)>= skillTree.getMaxPointSpent()) {
|
||||
if (playerData.getPointSpent(skillTree) >= skillTree.getMaxPointSpent()) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("max-points-reached").send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
event.setCancelled(true);
|
||||
|
Loading…
Reference in New Issue
Block a user