Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.voxbestww.ability.command;
- import org.bukkit.command.*;
- import org.bukkit.entity.*;
- import org.bukkit.inventory.*;
- import com.voxbestww.ability.*;
- import com.voxbestww.ability.ability.*;
- import com.voxbestww.zoom.utils.bukkit.*;
- public class AbilityCommand implements CommandExecutor
- {
- public boolean onCommand(final CommandSender sender, final Command command, final String s, final String[] args) {
- if (args.length < 1) {
- sender.sendMessage(ChatUtil.RED + "Usage: /ability <player> <ability>");
- return true;
- }
- Player player = Ability.INSTANCE.getPlugin().getServer().getPlayer(args[0]);
- if (player == null && sender instanceof Player) {
- player = (Player) sender;
- }
- if (player == null) {
- sender.sendMessage(ChatUtil.RED + "Player" + args[0] + " not found.");
- return true;
- }
- final AbilityType abilityType = AbilityType.valueOf(args[1].toUpperCase());
- if (abilityType == null) {
- sender.sendMessage(ChatUtil.RED + "Ability \"" + args[1].toUpperCase() + "\" not found.");
- return true;
- }
- if (PlayerUtil.isInventoryFull(player)) {
- player.getWorld().dropItemNaturally(player.getLocation(), abilityType.getItemStack());
- }
- else {
- player.getInventory().addItem(new ItemStack[] { abilityType.getItemStack() });
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement