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() {
for (SkillTree skillTree : MMOCore.plugin.skillTreeManager.getAll())
if (skillTree instanceof LinkedSkillTree) {
LinkedSkillTree linkedSkillTree = (LinkedSkillTree) skillTree;
linkedSkillTree.setupNodeState(this);
} else {
skillTree.setupNodeState(this);
}
skillTree.setupNodeState(this);
}
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) {
setNodeLevel(node, getNodeLevel(node) + 1);
//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)
setNodeState(node, NodeState.UNLOCKED);
@ -364,8 +360,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
@NotNull
public SkillTree getOpenedSkillTree() {
if (cachedSkillTree == null) {
Optional<SkillTree> optionnal=MMOCore.plugin.skillTreeManager.getAll().stream().findFirst();
return optionnal.isPresent()?optionnal.get():null;
Optional<SkillTree> optionnal = MMOCore.plugin.skillTreeManager.getAll().stream().findFirst();
return optionnal.isPresent() ? optionnal.get() : null;
}
return cachedSkillTree;
}
@ -674,7 +670,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
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) {
getPlayer().teleport(target.getLocation());
getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1, false, false));
@ -683,11 +679,11 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
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);
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
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));
}
}.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.tree.SkillTreeNode;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
@ -78,9 +79,6 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
}
data.setupNodeState();
for (SkillTreeNode node : MMOCore.plugin.skillTreeManager.getAllNodes()) {
MMOCore.log(node.getFullId()+" " +data.getNodeState(node)+"");
}
if (config.contains("times-claimed"))
for (String key : config.getConfigurationSection("times-claimed").getKeys(true))

View File

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

View File

@ -102,7 +102,7 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
}
}
} 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();
}
}
@ -182,9 +182,8 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
* Recursively go through the skill trees to update the the node states
*/
public void setupNodeState(PlayerData playerData) {
Bukkit.broadcastMessage(getId()+(this instanceof CustomSkillTree)+" "+roots.size());
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);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;