forked from Upstream/mmocore
Debug and enhancements for the reset method.
This commit is contained in:
parent
06985321d6
commit
9e821c79db
@ -233,6 +233,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
return new HashMap(skillTreePoints);
|
return new HashMap(skillTreePoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void clearSkillTreePoints() {
|
public void clearSkillTreePoints() {
|
||||||
skillTreePoints.clear();
|
skillTreePoints.clear();
|
||||||
}
|
}
|
||||||
@ -371,21 +373,11 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetNodeTimesClaimed() {
|
public void resetTimesClaimed() {
|
||||||
Map<String, Integer> newTableItemClaims = new HashMap<>();
|
|
||||||
tableItemClaims.forEach((str, val) -> {
|
|
||||||
if (!str.startsWith(SkillTreeNode.getPrefix()))
|
|
||||||
newTableItemClaims.put(str, val);
|
|
||||||
});
|
|
||||||
tableItemClaims.clear();
|
tableItemClaims.clear();
|
||||||
tableItemClaims.putAll(newTableItemClaims);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addNodeLevel(SkillTreeNode node) {
|
|
||||||
nodeLevels.put(node, nodeLevels.get(node) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
|
||||||
@ -804,7 +796,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
* If it's null, no hologram will be displayed
|
* If it's null, no hologram will be displayed
|
||||||
* @param splitExp Should the exp be split among party members
|
* @param splitExp Should the exp be split among party members
|
||||||
*/
|
*/
|
||||||
public void giveExperience(double value, EXPSource source, @Nullable Location hologramLocation, boolean splitExp) {
|
public void giveExperience(double value, EXPSource source, @Nullable Location hologramLocation,
|
||||||
|
boolean splitExp) {
|
||||||
if (value <= 0)
|
if (value <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import net.Indyuce.mmocore.MMOCore;
|
|||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.experience.Profession;
|
import net.Indyuce.mmocore.experience.Profession;
|
||||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
|
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
|
||||||
|
import net.Indyuce.mmocore.tree.skilltree.SkillTree;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -22,6 +23,7 @@ public class ResetCommandTreeNode extends CommandTreeNode {
|
|||||||
addChild(new ResetAllCommandTreeNode(this));
|
addChild(new ResetAllCommandTreeNode(this));
|
||||||
addChild(new ResetAttributesCommandTreeNode(this));
|
addChild(new ResetAttributesCommandTreeNode(this));
|
||||||
addChild(new ResetWaypointsCommandTreeNode(this));
|
addChild(new ResetWaypointsCommandTreeNode(this));
|
||||||
|
addChild(new ResetSkillTreesCommandTreeNode(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,8 +59,17 @@ public class ResetCommandTreeNode extends CommandTreeNode {
|
|||||||
MMOCore.plugin.classManager.getAll().forEach(data::unloadClassInfo);
|
MMOCore.plugin.classManager.getAll().forEach(data::unloadClassInfo);
|
||||||
data.getAttributes().getInstances().forEach(ins -> ins.setBase(0));
|
data.getAttributes().getInstances().forEach(ins -> ins.setBase(0));
|
||||||
data.mapSkillLevels().forEach((skill, level) -> data.resetSkillLevel(skill));
|
data.mapSkillLevels().forEach((skill, level) -> data.resetSkillLevel(skill));
|
||||||
|
data.setSkillTreePoints("global", 0);
|
||||||
|
for (SkillTree skillTree : data.getProfess().getSkillTrees()) {
|
||||||
|
data.resetSkillTree(skillTree);
|
||||||
|
data.setSkillTreePoints(skillTree.getId(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
data.resetTimesClaimed();
|
||||||
while (data.hasSkillBound(0))
|
while (data.hasSkillBound(0))
|
||||||
data.unbindSkill(0);
|
data.unbindSkill(0);
|
||||||
|
while (data.hasPassiveSkillBound(0))
|
||||||
|
data.unbindPassiveSkill(0);
|
||||||
data.getQuestData().resetFinishedQuests();
|
data.getQuestData().resetFinishedQuests();
|
||||||
data.getQuestData().start(null);
|
data.getQuestData().start(null);
|
||||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||||
@ -144,6 +155,34 @@ public class ResetCommandTreeNode extends CommandTreeNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class ResetSkillTreesCommandTreeNode extends CommandTreeNode {
|
||||||
|
public ResetSkillTreesCommandTreeNode(CommandTreeNode parent) {
|
||||||
|
super(parent, "skill-trees");
|
||||||
|
|
||||||
|
addParameter(Parameter.PLAYER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandResult execute(CommandSender sender, String[] args) {
|
||||||
|
if (args.length < 4)
|
||||||
|
return CommandResult.THROW_USAGE;
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(args[3]);
|
||||||
|
if (player == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||||
|
return CommandResult.FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerData data = PlayerData.get(player);
|
||||||
|
for (SkillTree skillTree : data.getProfess().getSkillTrees())
|
||||||
|
data.resetSkillTree(skillTree);
|
||||||
|
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||||
|
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s skill-tree data was succesfully reset.");
|
||||||
|
return CommandResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ResetAttributesCommandTreeNode extends CommandTreeNode {
|
public class ResetAttributesCommandTreeNode extends CommandTreeNode {
|
||||||
public ResetAttributesCommandTreeNode(CommandTreeNode parent) {
|
public ResetAttributesCommandTreeNode(CommandTreeNode parent) {
|
||||||
super(parent, "attributes");
|
super(parent, "attributes");
|
||||||
@ -213,7 +252,9 @@ public class ResetCommandTreeNode extends CommandTreeNode {
|
|||||||
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
|
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
|
||||||
data.getCollectionSkills().setExperience(profession, 0);
|
data.getCollectionSkills().setExperience(profession, 0);
|
||||||
data.getCollectionSkills().setLevel(profession, 0);
|
data.getCollectionSkills().setLevel(profession, 0);
|
||||||
|
profession.getExperienceTable().reset(data, profession);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s levels were succesfully reset.");
|
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s levels were succesfully reset.");
|
||||||
|
|
||||||
|
@ -184,6 +184,8 @@ public abstract class PlayerDataManager {
|
|||||||
player.setSkillPoints(skillPoints);
|
player.setSkillPoints(skillPoints);
|
||||||
player.setAttributePoints(attributePoints);
|
player.setAttributePoints(attributePoints);
|
||||||
player.setAttributeReallocationPoints(attrReallocPoints);
|
player.setAttributeReallocationPoints(attrReallocPoints);
|
||||||
|
player.setSkillTreeReallocationPoints(skillTreeReallocPoints);
|
||||||
|
player.setSkillReallocationPoints(skillReallocPoints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user