68 lines
2.8 KiB
Java
68 lines
2.8 KiB
Java
package gq.unurled.raxen.commands.player;
|
|
|
|
import gq.unurled.raxen.Raxen;
|
|
import gq.unurled.raxen.components.entity.player.PlayerUtils;
|
|
import gq.unurled.raxen.components.entity.player.attributes.Attributes;
|
|
import gq.unurled.raxen.manager.entity.PlayerManager;
|
|
import org.bukkit.Bukkit;
|
|
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.colorTextComp;
|
|
import static gq.unurled.raxen.utils.Utils.error;
|
|
|
|
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((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"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(colorTextComp("<red>GUI not implemented yet..").append(colorTextComp("<red>Try /skill help.")));
|
|
break;
|
|
case 1:
|
|
case 2:
|
|
player.sendMessage(colorTextComp("<white>Use the command like: ")
|
|
.append(colorTextComp("<white>/skill <dark_aqua>{health|defense|speed|strength} {add|set|remove} {amount}")));
|
|
break;
|
|
case 3:
|
|
PlayerManager pm = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
|
for (String s : pm.getAttribute().keySet()) {
|
|
if (s.equalsIgnoreCase(args[0]))
|
|
switch (args[1]) {
|
|
case "add":
|
|
pm.getAttribute().get(s).add(player, Integer.parseInt(args[2]));
|
|
case "remove":
|
|
pm.getAttribute().get(s).remove(player, Integer.parseInt(args[2]));
|
|
case "set":
|
|
pm.getAttribute().get(s).set(player, Integer.parseInt(args[2]));
|
|
}
|
|
}
|
|
PlayerUtils.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;
|
|
}
|
|
}
|