/*
 * Copyright (C) 2004-2015 L2J DataPack
 * 
 * This file is part of L2J DataPack.
 * 
 * L2J DataPack 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 3 of the License, or
 * (at your option) any later version.
 * 
 * L2J DataPack 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, see .
 */
package handlers.voicedcommandhandlers;
import java.text.SimpleDateFormat;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.instancemanager.PremiumManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
public class Premium implements IVoicedCommandHandler
{
	private static final String[] VOICED_COMMANDS =
	{
		"premium"
	};
	
	@Override
	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
	{
		if (command.startsWith("premium") && Config.PREMIUM_SYSTEM_ENABLED)
		{
			SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
			long endDate = PremiumManager.getInstance().getPremiumEndDate(activeChar.getAccountName());
			if (endDate == 0)
			{
				NpcHtmlMessage msg = new NpcHtmlMessage(5);
				StringBuilder html = new StringBuilder("
Account Details");
				html.append("");
				html.append("| Account Status: Normal 
 | 
");
				html.append("| Rate XP:  x" + Config.RATE_XP + " | 
");
				html.append("| Rate SP:  x" + Config.RATE_SP + " | 
");
				html.append("| Drop Chance:  x" + Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER + " | 
");
				html.append("| Drop Amount:  x" + Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER + " | 
");
				html.append("| Premium Info & Rules 
 | 
");
				html.append("| Rate XP:  x" + (Config.RATE_XP * Config.PREMIUM_RATE_XP) + " | 
");
				html.append("| Rate SP:  x" + (Config.RATE_SP * Config.PREMIUM_RATE_SP) + " | 
");
				html.append("| Drop Chance:  x" + (Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER * Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER * Config.PREMIUM_RATE_DROP_CHANCE) + " | 
");
				html.append("| Drop Amount:  x" + (Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER * Config.PREMIUM_RATE_DROP_AMOUNT) + " | 
");
				html.append("| 1. Premium benefits CAN NOT BE TRANSFERED. | 
");
				html.append("| 2. Premium does not effect party members. | 
");
				html.append("| 3. Premium benefits effect ALL characters in same account. | 
");
				html.append("
");
				html.append("");
				msg.setHtml(html.toString());
				activeChar.sendPacket(msg);
			}
			else
			{
				NpcHtmlMessage msg = new NpcHtmlMessage(5);
				StringBuilder html = new StringBuilder("Premium Account Details");
				html.append("");
				html.append("| Account Status: Premium 
 | 
");
				html.append("| Rate XP: x" + (Config.RATE_XP * Config.PREMIUM_RATE_XP) + " | 
");
				html.append("| Rate SP: x" + (Config.RATE_SP * Config.PREMIUM_RATE_SP) + " | 
");
				html.append("| Drop Chance: x" + (Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER * Config.PREMIUM_RATE_DROP_CHANCE) + " | 
");
				html.append("| Drop Amount: x" + (Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER * Config.PREMIUM_RATE_DROP_AMOUNT) + " | 
");
				html.append("| Expires: " + String.valueOf(format.format(endDate)) + " | 
");
				html.append("| Current Date: " + String.valueOf(format.format(System.currentTimeMillis())) + " 
 
 | 
");
				html.append("| Premium Info & Rules 
 | 
");
				html.append("| 1. Premium accounts CAN NOT BE TRANSFERED. | 
");
				html.append("| 2. Premium does not effect party members. | 
");
				html.append("| 3. Premium account effects ALL characters in same account. 
 
 
 | 
");
				html.append("| Thank you for supporting our server. | 
");
				html.append("
");
				html.append("");
				msg.setHtml(html.toString());
				activeChar.sendPacket(msg);
			}
		}
		else
		{
			return false;
		}
		return true;
	}
	
	@Override
	public String[] getVoicedCommandList()
	{
		return VOICED_COMMANDS;
	}
}