package custom.items;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import ru.catssoftware.gameserver.datatables.SkillTable;
import ru.catssoftware.gameserver.model.L2ItemInstance;
import ru.catssoftware.gameserver.model.actor.instance.L2PcInstance;
import ru.catssoftware.gameserver.model.actor.instance.L2PlayableInstance;
import ru.catssoftware.gameserver.network.serverpackets.MagicSkillUse;
import ru.catssoftware.gameserver.handler.ItemHandler;
import ru.catssoftware.gameserver.handler.IItemHandler;
import javolution.util.FastList;
import javolution.util.FastMap;
public class DonateScrolls implements IItemHandler
{
private final static FastMap<Integer, Integer[]> SCROLLS = new FastMap<Integer, Integer[]>().shared("DonateScrolls.SCROLLS");
private static int[] ITEM_IDS = null;
public DonateScrolls()
{
/**шаблон
**SCROLLS.put(итем_ид, new Integer[] { ид_баффа, уровень_баффа, ид_скилла_анимации, продолжительность_анимации(мс.)), кушать_скролл(1 да, 0 нет)) });
**/
SCROLLS.put(9843, new Integer[] { 9959, 1, 2036, 1, 1 });
SCROLLS.put(4356, new Integer[] { 805, 1, 2036, 1, 1 });
SCROLLS.put(4355, new Integer[] { 806, 1, 2036, 1, 1 });
SCROLLS.put(4357, new Integer[] { 807, 1, 2036, 1, 1 });
SCROLLS.put(9996, new Integer[] { 819, 1, 2036, 1, 1 });
SCROLLS.put(9997, new Integer[] { 820, 1, 2036, 1, 1 });
SCROLLS.put(9998, new Integer[] { 821, 1, 2036, 1, 1 });
SCROLLS.put(9999, new Integer[] { 822, 1, 2036, 1, 1 });
SCROLLS.put(4361, new Integer[] { 835, 1, 2031, 1, 0 });
//
Integer[] tmp_ids = (Integer[]) SCROLLS.keySet().toArray(new Integer[SCROLLS.size()]);
ITEM_IDS = toIntArray(tmp_ids);
tmp_ids = null;
ItemHandler.getInstance().registerItemHandler(this);
}
public static void main (String... arguments )
{
new DonateScrolls();
}
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!playable.getPlayer())
return;
L2PcInstance player = (L2PcInstance) playable;
if (player.isAllSkillsDisabled())
{
player.sendActionFailed();
return;
}
if (player.isInOlympiadMode())
{
player.sendPacket(Static.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
player.sendActionFailed();
return;
}
Integer[] data = SCROLLS.get(item.getItemId());
if(data != null)
{
player.stopSkillEffects(data[0]);
SkillTable.getInstance().getInfo(data[0], data[1]).getEffects(player, player);
player.broadcastPacket(new MagicSkillUse(player, player, data[2], 1, data[3], 0));
if (data[4] == 1)
player.destroyItem("Consume", item.getObjectId(), 1, null, false);
}
}
private int[] toIntArray(Integer[] arr)
{
int[] ret = new int[arr.length];
int i = 0;
for (Integer e : arr)
ret[i++] = e.intValue();
return ret;
}
public int[] getItemIds()
{
return ITEM_IDS;
}
}