
/*
 *  This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */
package net.sf.l2j.gameserver.handler.voicedcommandhandlers;

import java.util.logging.Logger;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.GameServer;
import net.sf.l2j.gameserver.cache.HtmCache;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;

/**
 *
 * @author Zero Cool
 * AIO Voiced Command.
 *
 */
public class VoicedAIOCmd implements IVoicedCommandHandler
{
    private static final String[] VOICED_COMMANDS = { "aio" };
    private static final Logger _log = Logger.getLogger(GameServer.class.getName());
    public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
    {	
        if (command.equalsIgnoreCase("aio"))
        {
        	if (activeChar.isInJail())
            {
            	activeChar.sendMessage("You can't use this command while being in Jail!");
            	return false;
            }

            else if (activeChar.isInDuel() && !Config.VCAIO_AND_DUEL)
            {
            	activeChar.sendMessage("You can't use this command while dueling!");
            	return false;
            }

            else if (activeChar.isDead() && !Config.VCAIO_AND_DEAD)
            {
            	activeChar.sendMessage("You can't use this command while being dead!");
            	return false;
            }

            else if (activeChar.isInOlympiadMode() && !Config.VCAIO_AND_OLY)
            {
            	activeChar.sendMessage("You can't use this command while being in Olympiad!");
            	return false;
            }

            else if (activeChar.getKarma() > 0 && !Config.VCAIO_AND_KARMA)
            {
            	activeChar.sendMessage("You can't use this command while having Karma!");
            	return false;
            }

            else if (activeChar.getPvpFlag() > 0 && !Config.VCAIO_AND_FLAG)
            {
            	activeChar.sendMessage("You can't use this command while being Flagged!");
            	return false;
            }

            else if (activeChar.inObserverMode() && !Config.VCAIO_AND_OBSERVER)
            {
            	activeChar.sendMessage("You can't use this command while observing an olympiad match!");
           	return false;
            }

            else if (activeChar.isFestivalParticipant() && !Config.VCAIO_AND_FESTIVAL)
            {
            	activeChar.sendMessage("You can't use this command while participating in the Festival!");
                return false;
            }

            else if (activeChar.isFishing() && !Config.VCAIO_AND_FISHING)
            {
            	activeChar.sendMessage("You can't use this command while fishing!");
            	return false;
            }

           else if (activeChar.isInCombat() && !Config.VCAIO_AND_COMBAT)
        	{
        		activeChar.sendMessage("You can't use this command while being in combat!");
        		return false;
        	}

        	else if (activeChar.isParalyzed() && !Config.VCAIO_AND_PARA)
        	{
        		activeChar.sendMessage("You can't use this command while being paralyzed!");
        		return false;
        	}

        	else if (activeChar.isFakeDeath() && !Config.VCAIO_AND_FD)
        	{
        		activeChar.sendMessage("You can't use this command while using the 'Fake Death' skill!");
        		return false;
        	}

        	else if (activeChar.isChatBanned() && !Config.VCAIO_AND_CHATBAN)
        	{
        		activeChar.sendMessage("You can't use this command while being Chat Banned!");
        		return false;
        	}

        	else if (activeChar.isCursedWeaponEquiped() && !Config.VCAIO_AND_CW_EQUIPPED)
        	{
        		activeChar.sendMessage("You can't use this command while holding a Cursed Weapon!");
        		return false;
        	}

        	else if (activeChar.isRooted() && !Config.VCAIO_AND_ROOT)
        	{
        		activeChar.sendMessage("You can't use this command while being rooted to the ground!");
        		return false;
        	}

        	else if (activeChar.isSitting() && !Config.VCAIO_AND_SITTING)
        	{
        		activeChar.sendMessage("You can't use this command while sitting down!");
        		return false;
        	}

        	else if (activeChar.isImobilised() && !Config.VCAIO_AND_IMOBILE)
        	{
        		activeChar.sendMessage("You can't use this command while being imobilised!");
        		return false;
        	}

        	else if (activeChar.isIn7sDungeon() && !Config.VCAIO_AND_7SDUNGEON)
        	{
        		activeChar.sendMessage("You can't use this command while being at the 7 Signs Dungeon!");
        		return false;
        	}
        	else
        	{
        		String htmFile = "data/html/mods/VoicedAIOCmd.htm";
        		String htmContent = HtmCache.getInstance().getHtm(htmFile);
        		if (htmContent != null)
        		{
        			NpcHtmlMessage infoHtml = new NpcHtmlMessage(1);
        			infoHtml.setHtml(htmContent);
        			activeChar.sendPacket(infoHtml);
        		}
        		else
        		{
        			_log.info("Failed to load VCAIO File! Make sure that you fix it soon!");
        		}
        	}
        }
		return false;
    }

    public String[] getVoicedCommandList()
    {
        return VOICED_COMMANDS;
    }
}
