Skill Tree Debug

This commit is contained in:
Ka0rX 2022-08-18 17:38:35 +02:00
parent e51ae7cf9e
commit 1e23f4147c
4 changed files with 13 additions and 20 deletions

View File

@ -175,12 +175,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
public void setupNodeState() { public void setupNodeState() {
for (SkillTree skillTree : MMOCore.plugin.skillTreeManager.getAll()) for (SkillTree skillTree : MMOCore.plugin.skillTreeManager.getAll())
if (skillTree instanceof LinkedSkillTree) { skillTree.setupNodeState(this);
LinkedSkillTree linkedSkillTree = (LinkedSkillTree) skillTree;
linkedSkillTree.setupNodeState(this);
} else {
skillTree.setupNodeState(this);
}
} }
public void setSkillTreePoints(String treeId, int points) { public void setSkillTreePoints(String treeId, int points) {
@ -226,7 +222,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
public <T extends SkillTree> void incrementNodeLevel(SkillTreeNode node) { public <T extends SkillTree> void incrementNodeLevel(SkillTreeNode node) {
setNodeLevel(node, getNodeLevel(node) + 1); setNodeLevel(node, getNodeLevel(node) + 1);
//Claims the nodes experience table. //Claims the nodes experience table.
node.getExperienceTable().claim(this,getNodeLevel(node),node); node.getExperienceTable().claim(this, getNodeLevel(node), node);
if (nodeStates.get(node) == NodeState.UNLOCKABLE) if (nodeStates.get(node) == NodeState.UNLOCKABLE)
setNodeState(node, NodeState.UNLOCKED); setNodeState(node, NodeState.UNLOCKED);
@ -364,8 +360,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
@NotNull @NotNull
public SkillTree getOpenedSkillTree() { public SkillTree getOpenedSkillTree() {
if (cachedSkillTree == null) { if (cachedSkillTree == null) {
Optional<SkillTree> optionnal=MMOCore.plugin.skillTreeManager.getAll().stream().findFirst(); Optional<SkillTree> optionnal = MMOCore.plugin.skillTreeManager.getAll().stream().findFirst();
return optionnal.isPresent()?optionnal.get():null; return optionnal.isPresent() ? optionnal.get() : null;
} }
return cachedSkillTree; return cachedSkillTree;
} }
@ -674,7 +670,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return; return;
} }
MMOCore.plugin.configManager.getSimpleMessage("warping-comencing", "left", "" + ((MMOCore.plugin.configManager.waypointWarpTime+20 - t) / 20)).send(getPlayer()); MMOCore.plugin.configManager.getSimpleMessage("warping-comencing", "left", "" + ((MMOCore.plugin.configManager.waypointWarpTime + 20 - t) / 20)).send(getPlayer());
if (t++ >= MMOCore.plugin.configManager.waypointWarpTime) { if (t++ >= MMOCore.plugin.configManager.waypointWarpTime) {
getPlayer().teleport(target.getLocation()); getPlayer().teleport(target.getLocation());
getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1, false, false)); getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1, false, false));
@ -683,11 +679,11 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return; return;
} }
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_CHARGE).playTo(getPlayer(), 1, (float) (t / Math.PI * 1.5/MMOCore.plugin.configManager.waypointWarpTime + .5)); MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_CHARGE).playTo(getPlayer(), 1, (float) (t / Math.PI * 1.5 / MMOCore.plugin.configManager.waypointWarpTime + .5));
double r = Math.sin((double) t / MMOCore.plugin.configManager.waypointWarpTime * Math.PI); double r = Math.sin((double) t / MMOCore.plugin.configManager.waypointWarpTime * Math.PI);
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4) for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
getPlayer().getLocation().getWorld().spawnParticle(Particle.REDSTONE, getPlayer().getLocation().getWorld().spawnParticle(Particle.REDSTONE,
getPlayer().getLocation().add(Math.cos((double) 5*t /MMOCore.plugin.configManager.waypointWarpTime + j) * r, (double) 2*t / MMOCore.plugin.configManager.waypointWarpTime, Math.sin((double) 5*t / MMOCore.plugin.configManager.waypointWarpTime + j) * r), 1, getPlayer().getLocation().add(Math.cos((double) 5 * t / MMOCore.plugin.configManager.waypointWarpTime + j) * r, (double) 2 * t / MMOCore.plugin.configManager.waypointWarpTime, Math.sin((double) 5 * t / MMOCore.plugin.configManager.waypointWarpTime + j) * r), 1,
new Particle.DustOptions(Color.PURPLE, 1.25f)); new Particle.DustOptions(Color.PURPLE, 1.25f));
} }
}.runTaskTimer(MMOCore.plugin, 0, 1); }.runTaskTimer(MMOCore.plugin, 0, 1);

View File

@ -11,6 +11,7 @@ import net.Indyuce.mmocore.manager.data.DataProvider;
import net.Indyuce.mmocore.manager.data.PlayerDataManager; import net.Indyuce.mmocore.manager.data.PlayerDataManager;
import net.Indyuce.mmocore.tree.SkillTreeNode; import net.Indyuce.mmocore.tree.SkillTreeNode;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -78,9 +79,6 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
} }
data.setupNodeState(); data.setupNodeState();
for (SkillTreeNode node : MMOCore.plugin.skillTreeManager.getAllNodes()) {
MMOCore.log(node.getFullId()+" " +data.getNodeState(node)+"");
}
if (config.contains("times-claimed")) if (config.contains("times-claimed"))
for (String key : config.getConfigurationSection("times-claimed").getKeys(true)) for (String key : config.getConfigurationSection("times-claimed").getKeys(true))

View File

@ -44,13 +44,14 @@ public class CustomSkillTree extends SkillTree {
} }
} }
} }
setupRoots();
} }
private void setupRoots() { private void setupRoots() {
//We find the roots of the tree which don't have any parents //We find the roots of the tree which don't have any parents
for (SkillTreeNode node : nodes.values()) { for (SkillTreeNode node : nodes.values()) {
if (node.getSoftParents().size()+node.getStrongParents().size() == 0) { if (node.getSoftParents().size()+node.getStrongParents().size() == 0) {
//We mark the node as a root also //We mark the node as a root also
roots.add(node); roots.add(node);

View File

@ -102,7 +102,7 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
} }
} }
} catch (Exception e) { } catch (Exception e) {
Bukkit.getLogger().log(Level.WARNING, "Couldn't load icons for the skill tree " + id); MMOCore.log( "Couldn't load icons for the skill tree " + id);
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -182,9 +182,8 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
* Recursively go through the skill trees to update the the node states * Recursively go through the skill trees to update the the node states
*/ */
public void setupNodeState(PlayerData playerData) { public void setupNodeState(PlayerData playerData) {
Bukkit.broadcastMessage(getId()+(this instanceof CustomSkillTree)+" "+roots.size());
for (SkillTreeNode root : roots) for (SkillTreeNode root : roots)
root.getTree().setupNodeStateFrom(root, playerData); setupNodeStateFrom(root, playerData);
} }
@ -296,7 +295,6 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
return nodes.containsKey(name); return nodes.containsKey(name);
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;