{
activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE));
return;
}
L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId);
// if we cant find requested item, its actualy a cheat!
if (itemToRemove == null)
return;
// Cannot discard item that the skill is consumming
if (activeChar.isCastingNow())
{
if (activeChar.getCurrentSkill() != null && activeChar.getCurrentSkill().getSkill().getItemConsumeId() == itemToRemove.getItemId())
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
return;
}
}
int itemId = itemToRemove.getItemId();
if (itemToRemove.isWear() || !itemToRemove.isDestroyable() || CursedWeaponsManager.getInstance().isCursed(itemId))
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
return;
}
if(!itemToRemove.isStackable() && count > 1)
{
Util.handleIllegalPlayerAction(activeChar,"[RequestDestroyItem] count > 1 but item is not stackable! oid: "+_objectId+" owner: "+activeChar.getName(),Config.DEFAULT_PUNISH);
return;
}
if (_count > itemToRemove.getCount())
count = itemToRemove.getCount();
if (itemToRemove.isEquipped())
{
L2ItemInstance[] unequiped =
activeChar.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getEquipSlot());
InventoryUpdate iu = new InventoryUpdate();
for (int i = 0; i < unequiped.length; i++)
{
activeChar.checkSSMatch(null, unequiped[i]);
iu.addModifiedItem(unequiped[i]);
}
activeChar.sendPacket(iu);
activeChar.broadcastUserInfo();
}
if (L2PetDataTable.isPetItem(itemId))
{
java.sql.Connection con = null;
try
{
if (activeChar.getPet() != null && activeChar.getPet().getControlItemId() == _objectId)
{
activeChar.getPet().unSummon(activeChar);
}
// if it's a pet control item, delete the pet
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?");
statement.setInt(1, _objectId);
statement.execute();
statement.close();
}
catch (Exception e)
{
_log.log(Level.WARNING, "could not delete pet objectid: ", e);
}
finally
{
try { con.close(); } catch (Exception e) {}
}
}
L2ItemInstance removedItem = activeChar.getInventory().destroyItem("Destroy", _objectId, count, activeChar, null);
if(removedItem == null)
return;
if (!Config.FORCE_INVENTORY_UPDATE)
{
InventoryUpdate iu = new InventoryUpdate();
if (removedItem.getCount() == 0) iu.addRemovedItem(removedItem);
else iu.addModifiedItem(removedItem);
//client.getConnection().sendPacket(iu);
activeChar.sendPacket(iu);
}