Merged with released L2J-Unity files.
This commit is contained in:
@@ -1,112 +1,112 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package handlers.itemhandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.RecipeData;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.L2RecipeList;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class Recipes implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
if (activeChar.isInCraftMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_ALTER_YOUR_RECIPE_BOOK_WHILE_ENGAGED_IN_MANUFACTURING);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2RecipeList rp = RecipeData.getInstance().getRecipeByItemId(item.getId());
|
||||
if (rp == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasRecipeList(rp.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_RECIPE_IS_ALREADY_REGISTERED);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean canCraft = false;
|
||||
boolean recipeLevel = false;
|
||||
boolean recipeLimit = false;
|
||||
if (rp.isDwarvenRecipe())
|
||||
{
|
||||
canCraft = activeChar.hasDwarvenCraft();
|
||||
recipeLevel = rp.getLevel() > activeChar.getDwarvenCraft();
|
||||
recipeLimit = activeChar.getDwarvenRecipeBook().length >= activeChar.getDwarfRecipeLimit();
|
||||
}
|
||||
else
|
||||
{
|
||||
canCraft = activeChar.hasCommonCraft();
|
||||
recipeLevel = rp.getLevel() > activeChar.getCommonCraft();
|
||||
recipeLimit = activeChar.getCommonRecipeBook().length >= activeChar.getCommonRecipeLimit();
|
||||
}
|
||||
|
||||
if (!canCraft)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_RECIPE_CANNOT_BE_REGISTERED_YOU_DO_NOT_HAVE_THE_ABILITY_TO_CREATE_ITEMS);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (recipeLevel)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_CREATE_ITEM_LEVEL_IS_TOO_LOW_TO_REGISTER_THIS_RECIPE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (recipeLimit)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.UP_TO_S1_RECIPES_CAN_BE_REGISTERED);
|
||||
sm.addInt(rp.isDwarvenRecipe() ? activeChar.getDwarfRecipeLimit() : activeChar.getCommonRecipeLimit());
|
||||
activeChar.sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rp.isDwarvenRecipe())
|
||||
{
|
||||
activeChar.registerDwarvenRecipeList(rp, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.registerCommonRecipeList(rp, true);
|
||||
}
|
||||
|
||||
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_ADDED);
|
||||
sm.addItemName(item);
|
||||
activeChar.sendPacket(sm);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package handlers.itemhandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.RecipeData;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.model.L2RecipeList;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class Recipes implements IItemHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
|
||||
{
|
||||
if (!playable.isPlayer())
|
||||
{
|
||||
playable.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = playable.getActingPlayer();
|
||||
if (activeChar.isInCraftMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_ALTER_YOUR_RECIPE_BOOK_WHILE_ENGAGED_IN_MANUFACTURING);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2RecipeList rp = RecipeData.getInstance().getRecipeByItemId(item.getId());
|
||||
if (rp == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasRecipeList(rp.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_RECIPE_IS_ALREADY_REGISTERED);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean canCraft = false;
|
||||
boolean recipeLevel = false;
|
||||
boolean recipeLimit = false;
|
||||
if (rp.isDwarvenRecipe())
|
||||
{
|
||||
canCraft = activeChar.hasDwarvenCraft();
|
||||
recipeLevel = (rp.getLevel() > activeChar.getDwarvenCraft());
|
||||
recipeLimit = (activeChar.getDwarvenRecipeBook().length >= activeChar.getDwarfRecipeLimit());
|
||||
}
|
||||
else
|
||||
{
|
||||
canCraft = activeChar.hasCommonCraft();
|
||||
recipeLevel = (rp.getLevel() > activeChar.getCommonCraft());
|
||||
recipeLimit = (activeChar.getCommonRecipeBook().length >= activeChar.getCommonRecipeLimit());
|
||||
}
|
||||
|
||||
if (!canCraft)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_RECIPE_CANNOT_BE_REGISTERED_YOU_DO_NOT_HAVE_THE_ABILITY_TO_CREATE_ITEMS);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (recipeLevel)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_CREATE_ITEM_LEVEL_IS_TOO_LOW_TO_REGISTER_THIS_RECIPE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (recipeLimit)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.UP_TO_S1_RECIPES_CAN_BE_REGISTERED);
|
||||
sm.addInt(rp.isDwarvenRecipe() ? activeChar.getDwarfRecipeLimit() : activeChar.getCommonRecipeLimit());
|
||||
activeChar.sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rp.isDwarvenRecipe())
|
||||
{
|
||||
activeChar.registerDwarvenRecipeList(rp, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.registerCommonRecipeList(rp, true);
|
||||
}
|
||||
|
||||
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_ADDED);
|
||||
sm.addItemName(item);
|
||||
activeChar.sendPacket(sm);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user