public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if(!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance) playable;
L2RecipeList rp = RecipeTable.getInstance().getRecipeByItemId(item.getItemId());
if(activeChar.hasRecipeList(rp.getId()))
{
SystemMessage sm = new SystemMessage(SystemMessageId.RECIPE_ALREADY_REGISTERED);
activeChar.sendPacket(sm);
sm = null;
}
else
{
if(rp.isDwarvenRecipe())
{
if(activeChar.hasDwarvenCraft())
{
if(rp.getLevel() > activeChar.getDwarvenCraft())
{
//can't add recipe, becouse create item level too low
SystemMessage sm = new SystemMessage(SystemMessageId.CREATE_LVL_TOO_LOW_TO_REGISTER);
activeChar.sendPacket(sm);
sm = null;
}
else if(activeChar.getDwarvenRecipeBook().length >= activeChar.GetDwarfRecipeLimit())
{
//Up to $s1 recipes can be registered.
SystemMessage sm = new SystemMessage(SystemMessageId.UP_TO_S1_RECIPES_CAN_REGISTER);
sm.addNumber(activeChar.GetDwarfRecipeLimit());
activeChar.sendPacket(sm);
sm = null;
}
else
{
activeChar.registerDwarvenRecipeList(rp);
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
SystemMessage sm = new SystemMessage(SystemMessageId.S1_ADDED);
sm.addString(item.getItemName());
activeChar.sendPacket(sm);
sm = null;
}
}
else
{
SystemMessage sm = new SystemMessage(SystemMessageId.CANT_REGISTER_NO_ABILITY_TO_CRAFT);
activeChar.sendPacket(sm);
sm = null;
}
}
else
{
if(activeChar.hasCommonCraft())
{
if(rp.getLevel() > activeChar.getCommonCraft())
{
//can't add recipe, becouse create item level too low
SystemMessage sm = new SystemMessage(SystemMessageId.CREATE_LVL_TOO_LOW_TO_REGISTER);
activeChar.sendPacket(sm);
sm = null;