Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. package com.voxbestww.ability.command;
  2.  
  3. import org.bukkit.command.*;
  4. import org.bukkit.entity.*;
  5. import org.bukkit.inventory.*;
  6.  
  7. import com.voxbestww.ability.*;
  8. import com.voxbestww.ability.ability.*;
  9. import com.voxbestww.zoom.utils.bukkit.*;
  10.  
  11. public class AbilityCommand implements CommandExecutor
  12. {
  13. public boolean onCommand(final CommandSender sender, final Command command, final String s, final String[] args) {
  14. if (args.length < 1) {
  15. sender.sendMessage(ChatUtil.RED + "Usage: /ability <player> <ability>");
  16. return true;
  17. }
  18. Player player = Ability.INSTANCE.getPlugin().getServer().getPlayer(args[0]);
  19. if (player == null && sender instanceof Player) {
  20. player = (Player) sender;
  21. }
  22. if (player == null) {
  23. sender.sendMessage(ChatUtil.RED + "Player" + args[0] + " not found.");
  24. return true;
  25. }
  26. final AbilityType abilityType = AbilityType.valueOf(args[1].toUpperCase());
  27. if (abilityType == null) {
  28. sender.sendMessage(ChatUtil.RED + "Ability \"" + args[1].toUpperCase() + "\" not found.");
  29. return true;
  30. }
  31. if (PlayerUtil.isInventoryFull(player)) {
  32. player.getWorld().dropItemNaturally(player.getLocation(), abilityType.getItemStack());
  33. }
  34. else {
  35. player.getInventory().addItem(new ItemStack[] { abilityType.getItemStack() });
  36. }
  37. return true;
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement