package gq.unurled.raxen.commands.player; import gq.unurled.raxen.Raxen; import gq.unurled.raxen.components.player.attributes.Attributes; import net.kyori.adventure.text.Component; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; import static gq.unurled.raxen.utils.Utils.*; public class SkillsCommand implements TabExecutor { private Raxen main; public SkillsCommand(Raxen main) { this.main = main; } @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String msg, @NotNull String[] args) { if(!(sender instanceof Player)) { error("The console can't execute this Command!"); return true; } Player player = (Player) sender; Attributes attributes = new Attributes(main); switch (args.length) { case 0: //open gui player.sendMessage(Component.text(color("&cGUI not implemented yet..")).append(Component.text(color("&cTry /skill help.")))); break; case 1: case 2: player.sendMessage(Component.text(color("&fUse the command like: ")) .append(Component.text(color("&f/skill &3{health|defense|speed|strength} {add|set|remove} {amount}")))); break; case 3: switch (args[0]) { case "health": if(args[1].equalsIgnoreCase("add")) { attributes.setHealth(player, attributes.getHealth(player) + Integer.parseInt(args[2])); msgPlayer(player,"You were added " + args[2] + " health more!"); } if(args[1].equalsIgnoreCase("set")) { attributes.setHealth(player, Integer.parseInt(args[2])); msgPlayer(player,"You are set " + args[2] + " health!"); } if(args[1].equalsIgnoreCase("remove")) { attributes.setHealth(player ,attributes.getHealth(player) - Integer.parseInt(args[2])); msgPlayer(player,"You were removeded " + args[2] + " health less!"); } break; case "defense": if(args[1].equalsIgnoreCase("add")) { attributes.setDefense(player, attributes.getDefense(player) + Integer.parseInt(args[2])); msgPlayer(player,"You were added " + args[2] + " defense more!"); } if(args[1].equalsIgnoreCase("set")) { attributes.setDefense(player, Integer.parseInt(args[2])); msgPlayer(player,"You are set " + args[2] + " defense!"); } if(args[1].equalsIgnoreCase("remove")) { attributes.setDefense(player, attributes.getDefense(player) - Integer.parseInt(args[2])); msgPlayer(player,"You were removed " + args[2] + " defense less!"); } break; case "speed": if(args[1].equalsIgnoreCase("add")) { attributes.setSpeed(player, attributes.getSpeed(player) + Integer.parseInt(args[2])); msgPlayer(player,"You were added " + args[2] + " speed more!"); } if(args[1].equalsIgnoreCase("set")) { attributes.setSpeed(player, Integer.parseInt(args[2])); msgPlayer(player,"You are set " + args[2] + " speed!"); } if(args[1].equalsIgnoreCase("remove")) { attributes.setSpeed(player, attributes.getSpeed(player) - Integer.parseInt(args[2])); msgPlayer(player,"You were removed " + args[2] + " speed less!"); } break; case "stregnth": if(args[1].equalsIgnoreCase("add")) { attributes.setStrength(player, attributes.getStrength(player) + Integer.parseInt(args[2])); msgPlayer(player,"You were added " + args[2] + " strength more!"); } if(args[1].equalsIgnoreCase("set")) { attributes.setStrength(player, Integer.parseInt(args[2])); msgPlayer(player,"You are set " + args[2] + " strength!"); } if(args[1].equalsIgnoreCase("remove")) { attributes.setStrength(player, attributes.getStrength(player) - Integer.parseInt(args[2])); msgPlayer(player,"You were removed " + args[2] + " strength less!"); } break; } gq.unurled.raxen.utils.Skills.updateSkills(main, player); } return false; } @Override public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) { return null; } }