package org.black_ixx.bossshop.command;

import java.util.ArrayList;

import org.black_ixx.bossshop.managers.ItemNameManager;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;


public class CommandName extends ACommandBase{

    private final ArrayList<String> mSubCommand=new ArrayList<>();
    
    public CommandName(CommandExc exector){
        super(exector);
        this.mSubCommand.add("key");
    }

    @Override
    public boolean execute(CommandSender pSender,String[] pArgs){
        if(!pSender.isOp()) return true;
        if(!(pSender instanceof Player))
            return consoleNotAllow(pSender);
        Player tPlayer=(Player)pSender;
        ItemStack inHandItem=tPlayer.getItemInHand();
        if(inHandItem==null||inHandItem.getType()==Material.AIR)
            return send(pSender,this.C("Cmd.YouShouldTakeItemInHand"));
        if(pArgs.length==0)
            return send(pSender,">"+this.mPlugin.getManager(ItemNameManager.class).getDisPlayName(inHandItem));
        else if(pArgs[0].equalsIgnoreCase("key"))
            return send(pSender,">"+this.mPlugin.getManager(ItemNameManager.class).getUnlocalizedName(inHandItem));
        else return true;
    }

    @Override
    public ArrayList<String> getHelp(CommandSender pSender,boolean pAll){
        return new ArrayList<>();
    }
    
    @Override
    public ArrayList<String> getSubCommand(CommandSender pSender,String[] pArgs){
        return this.mSubCommand;
    }

    @Override
    public int getMaxArgumentLength(){
        return 1;
    }

}
