mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
Added attributes to reset command
This commit is contained in:
parent
c9c9b905fa
commit
7b7b35e4a1
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
||||
import net.Indyuce.mmocore.command.api.CommandEnd;
|
||||
import net.Indyuce.mmocore.command.api.CommandMap;
|
||||
import net.Indyuce.mmocore.command.api.Parameter;
|
||||
@ -19,6 +20,7 @@ public class ResetCommandMap extends CommandEnd {
|
||||
addFloor(new ResetLevelsCommandMap(this));
|
||||
addFloor(new ResetSkillsCommandMap(this));
|
||||
addFloor(new ResetAllCommandMap(this));
|
||||
addFloor(new ResetAttributesCommandMap(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,6 +56,12 @@ public class ResetCommandMap extends CommandEnd {
|
||||
MMOCore.plugin.classManager.getAll().forEach(profess -> data.unloadClassInfo(profess));
|
||||
data.setClassPoints(0);
|
||||
data.setSkillPoints(0);
|
||||
|
||||
data.setAttributePoints(0);
|
||||
data.setAttributeReallocationPoints(0);
|
||||
for(PlayerAttribute att : MMOCore.plugin.attributeManager.getAll())
|
||||
data.setAttribute(att, 0);
|
||||
|
||||
MMOCore.plugin.skillManager.getAll().forEach(skill -> data.lockSkill(skill));
|
||||
while (data.hasSkillBound(0))
|
||||
data.unbindSkill(0);
|
||||
@ -96,6 +104,34 @@ public class ResetCommandMap extends CommandEnd {
|
||||
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);
|
||||
data.setAttributePoints(0);
|
||||
data.setAttributeReallocationPoints(0);
|
||||
for(PlayerAttribute att : MMOCore.plugin.attributeManager.getAll())
|
||||
data.setAttribute(att, 0);
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s attribute data was succesfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
public class ResetAttributesCommandMap extends CommandEnd {
|
||||
public ResetAttributesCommandMap(CommandMap parent) {
|
||||
super(parent, "attributes");
|
||||
|
||||
addParameter(Parameter.PLAYER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
|
Loading…
Reference in New Issue
Block a user