package me.pgdev.plugin.MyServer.commands;

import me.pgdev.plugin.MyServer.message.Message;
import me.pgdev.plugin.MyServer.Permission;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;


public class ClearInvCommand implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String tag, String[] args) {
        if(!(sender instanceof Player)) {
            sender.sendMessage(Message.ERROR + "Player Command Only!");
            return true;
        }
        Player player = (Player) sender;
        if(tag.equalsIgnoreCase("ci") || tag.equalsIgnoreCase("clearinventory")) {
            if(player.hasPermission(Permission.CLEARINVENTORY_COMMAND)) {
                player.getInventory().setArmorContents(null);
                player.getInventory().clear();
                player.sendMessage(Message.INFO + "You have cleared you inventory.");
            } else {
                player.sendMessage(Message.PERMISSION + Permission.CLEARINVENTORY_COMMAND);
            }
        }
        return true;
    }
}
