mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +01:00
Skill Tree.
This commit is contained in:
parent
5a75156411
commit
fbba7ff034
@ -283,7 +283,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
if (skillTree.isNode(coordinates)) {
|
||||
SkillTreeNode node = skillTree.getNode(coordinates);
|
||||
if (nodeStates.get(node) == null) {
|
||||
skillTree.getNodes().forEach(nodee -> Bukkit.broadcastMessage(nodee.getId() + " " + nodeStates.get(nodee)));
|
||||
skillTree.getNodes().forEach(nodee -> Bukkit.broadcastMessage(nodee.getFullId() + " " + nodeStates.get(nodee)));
|
||||
}
|
||||
DisplayInfo displayInfo = new DisplayInfo(nodeStates.get(node), node.getSize());
|
||||
return skillTree.getIcon(displayInfo);
|
||||
|
@ -49,6 +49,24 @@ public class MySQLDataProvider extends MMODataSource implements DataProvider {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
// Add 'skill_tree_realloc_points' if it doesn't exist
|
||||
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'skill_tree_realloc_points'", result -> {
|
||||
try {
|
||||
if (!result.next())
|
||||
executeUpdate("ALTER TABLE mmocore_playerdata ADD COLUMN is_saved TINYINT");
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
// Add 'skill_tree_points' if it doesn't exist
|
||||
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'skill_tree_points'", result -> {
|
||||
try {
|
||||
if (!result.next())
|
||||
executeUpdate("ALTER TABLE mmocore_playerdata ADD COLUMN is_saved TINYINT");
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import net.Indyuce.mmocore.api.player.profess.SavedClassInformation;
|
||||
import net.Indyuce.mmocore.guild.provided.Guild;
|
||||
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.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -72,6 +73,14 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||
}
|
||||
data.setSkillTreePoints("global", config.getInt("skill-tree-points.global", 0));
|
||||
|
||||
for (SkillTreeNode node : MMOCore.plugin.skillTreeManager.getAllNodes()) {
|
||||
data.setNodeLevel(node, config.getInt("skill-tree-level." + node.getFullId(), 0));
|
||||
}
|
||||
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))
|
||||
@ -112,6 +121,8 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||
data.getSkillTreePoints().forEach((key1, value) -> config.set("skill-tree-points." + key1, value));
|
||||
config.set("skill-tree-reallocation-points", data.getSkillTreeReallocationPoints());
|
||||
config.set("skill", null);
|
||||
//Saves the nodes levels
|
||||
MMOCore.plugin.skillTreeManager.getAllNodes().forEach(node -> config.set("skill-tree-level." + node.getFullId(), data.getNodeLevel(node)));
|
||||
data.mapSkillLevels().forEach((key1, value) -> config.set("skill." + key1, value));
|
||||
data.getItemClaims().forEach((key, times) -> config.set("times-claimed." + key, times));
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class AutomaticSkillTree extends SkillTree {
|
||||
}
|
||||
|
||||
}
|
||||
//We find the root of the tree wich is
|
||||
//We find the root of the tree which is
|
||||
for (SkillTreeNode node : nodes.values()) {
|
||||
if (node.getSoftParents().size() == 0 && node.getStrongParents().size() == 0) {
|
||||
Validate.isTrue(roots.size() == 0, "You can't have 2 roots on one automatic skill tree. You have " + (roots.size() != 0 ? roots.get(0).getName() : "") + " and " + node.getName() + ".");
|
||||
|
@ -1,10 +1,14 @@
|
||||
package net.Indyuce.mmocore.tree.skilltree;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.tree.ParentType;
|
||||
import net.Indyuce.mmocore.tree.SkillTreeNode;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CustomSkillTree extends SkillTree{
|
||||
public CustomSkillTree(ConfigurationSection config) {
|
||||
super(config);
|
||||
@ -36,6 +40,17 @@ public class CustomSkillTree extends SkillTree{
|
||||
}
|
||||
}
|
||||
}
|
||||
//We find the roots of the tree which don't have any parents
|
||||
for (SkillTreeNode node : nodes.values()) {
|
||||
if (node.getSoftParents().size() == 0 && node.getStrongParents().size() == 0) {
|
||||
Validate.isTrue(roots.size() == 0, "You can't have 2 roots on one automatic skill tree. You have " + (roots.size() != 0 ? roots.get(0).getName() : "") + " and " + node.getName() + ".");
|
||||
//We mark the node as a root also
|
||||
roots.add(node);
|
||||
node.setIsRoot();
|
||||
}
|
||||
}
|
||||
MMOCore.plugin.getLogger().log(Level.SEVERE,roots.size()+" ROOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOoooT");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
|
||||
|
||||
try {
|
||||
String string = config.getString("type");
|
||||
|
||||
Validate.notNull(string, "You must precise a type for the skill tree.");
|
||||
Validate.isTrue(string.equals("automatic") || string.equals("linked") || string.equals("custom"), "You must precise the type of the skill tree in the yml!" +
|
||||
"\nAllowed values: 'automatic','linked','custom'");
|
||||
if (string.equals("automatic")) {
|
||||
@ -168,7 +168,7 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
|
||||
skillTree.postLoad();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MMOCore.plugin.getLogger().log(Level.SEVERE, "Couldn't load skill tree " + config.getName() + ": " + e.getMessage());
|
||||
MMOCore.log("Couldn't load skill tree " + config.getString("id") + ": " + e.getMessage());
|
||||
}
|
||||
return skillTree;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user