if (removedItem.getCount() == 0) iu.addRemovedItem(removedItem);
else iu.addModifiedItem(removedItem);
_player.sendPacket(iu);
}
else _player.sendPacket(new ItemList(_player, true));
_player.broadcastUserInfo();
} else
{
// Remove from Db
_log.info(_name + " being removed offline." );
java.sql.Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
// Delete the item
PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?");
statement.setInt(1, _playerId);
statement.setInt(2, _itemId);
if (statement.executeUpdate() != 1)
{
_log.warning("Error while deleting itemId "+ _itemId +" from userId "+ _playerId);
}
statement.close();
/* Yesod: Skill is not stored into database any more.
// Delete the skill
statement = con.prepareStatement("DELETE FROM character_skills WHERE char_obj_id=? AND skill_id=?");
statement.setInt(1, _playerId);
statement.setInt(2, _skillId);
if (statement.executeUpdate() != 1)
{
_log.warning("Error while deleting skillId "+ _skillId +" from userId "+_playerId);
}
*/
// Restore the karma
statement = con.prepareStatement("UPDATE characters SET karma=?, pkkills=? WHERE obj_id=?");
statement.setInt(1, _playerKarma);
statement.setInt(2, _playerPkKills);
statement.setInt(3, _playerId);
if (statement.executeUpdate() != 1)
{
_log.warning("Error while updating karma & pkkills for userId "+_playerId);
}
statement.close();
}
catch (Exception e)
{
_log.warning("Could not delete : " + e);
}
finally
{
try { con.close(); } catch (Exception e) {}
}
}
} else
{
// either this cursed weapon is in the inventory of someone who has another cursed weapon equipped,
// OR this cursed weapon is on the ground.
if ((_player != null) && (_player.getInventory().getItemByItemId(_itemId) != null))
{
// Destroy
L2ItemInstance removedItem = _player.getInventory().destroyItemByItemId("", _itemId, 1, _player, null);
if (!Config.FORCE_INVENTORY_UPDATE)
{
InventoryUpdate iu = new InventoryUpdate();
if (removedItem.getCount() == 0) iu.addRemovedItem(removedItem);
else iu.addModifiedItem(removedItem);
_player.sendPacket(iu);
}
else _player.sendPacket(new ItemList(_player, true));
_player.broadcastUserInfo();
}
// is dropped on the ground
else if (_item != null)