Package net.sf.l2j.gameserver.serverpackets

Examples of net.sf.l2j.gameserver.serverpackets.InventoryUpdate


        PcInventory ownerInventory = _owner.getInventory();
        PcInventory playerInventory = player.getInventory();

        // Prepare inventory update packets
        InventoryUpdate ownerIU = new InventoryUpdate();
        InventoryUpdate playerIU = new InventoryUpdate();

        // Transfer adena
        if (price > playerInventory.getAdena())
        {
            lock();
            return false;
        }
       
        L2ItemInstance adenaItem = playerInventory.getAdenaInstance();
        playerInventory.reduceAdena("PrivateStore", price, player, _owner);
        playerIU.addItem(adenaItem);
        ownerInventory.addAdena("PrivateStore", price, _owner, player);
        ownerIU.addItem(ownerInventory.getAdenaInstance());

        // Transfer items
        for (ItemRequest item : items)
        {
            //Check if requested item is sill on the list and adjust its count
            adjustItemRequest(item);
            if (item.getCount() == 0) continue;

            // Check if requested item is available for manipulation
            L2ItemInstance oldItem = _owner.checkItemManipulation(item.getObjectId(), item.getCount(), "sell");
            if (oldItem == null)
            {
                lock();
                return false;
            }

            // Proceed with item transfer
            L2ItemInstance newItem = ownerInventory.transferItem("PrivateStore", item.getObjectId(), item.getCount(), playerInventory, _owner, player);
            if (newItem == null) return false;
            removeItem(item.getObjectId(), -1, item.getCount());

            // Add changes to inventory update packets
            if (oldItem.getCount() > 0 && oldItem != newItem) ownerIU.addModifiedItem(oldItem);
            else ownerIU.addRemovedItem(oldItem);
            if (newItem.getCount() > item.getCount()) playerIU.addModifiedItem(newItem);
            else playerIU.addNewItem(newItem);

            // Send messages about the transaction to both players
            if (newItem.isStackable())
            {
                SystemMessage msg = new SystemMessage(SystemMessageId.S1_PURCHASED_S3_S2_S);
View Full Code Here


              return false;
            }
        }

        // Prepare inventory update packet
        InventoryUpdate ownerIU = new InventoryUpdate();
        InventoryUpdate playerIU = new InventoryUpdate();

        // Transfer items
        for (ItemRequest item : items)
        {
            // Check if requested item is sill on the list and adjust its count
            adjustItemRequestByItemId(item);
            if (item.getCount() == 0) continue;

            // Check if requested item is available for manipulation
            L2ItemInstance oldItem = player.checkItemManipulation(item.getObjectId(), item.getCount(), "sell");
            if (oldItem == null) return false;

            // Proceed with item transfer
            L2ItemInstance newItem = playerInventory.transferItem("PrivateStore", item.getObjectId(), item.getCount(), ownerInventory, player, _owner);
            if (newItem == null) return false;
            removeItem(-1, item.getItemId(), item.getCount());

            // Add changes to inventory update packets
            if (oldItem.getCount() > 0 && oldItem != newItem) playerIU.addModifiedItem(oldItem);
            else playerIU.addRemovedItem(oldItem);
            if (newItem.getCount() > item.getCount()) ownerIU.addModifiedItem(newItem);
            else ownerIU.addNewItem(newItem);

            // Send messages about the transaction to both players
            if (newItem.isStackable())
            {
                SystemMessage msg = new SystemMessage(SystemMessageId.PURCHASED_S3_S2_S_FROM_S1);
                msg.addString(player.getName());
                msg.addItemName(newItem.getItemId());
                msg.addNumber(item.getCount());
                _owner.sendPacket(msg);

                msg = new SystemMessage(SystemMessageId.S1_PURCHASED_S3_S2_S);
                msg.addString(_owner.getName());
                msg.addItemName(newItem.getItemId());
                msg.addNumber(item.getCount());
                player.sendPacket(msg);
            }
            else
            {
                SystemMessage msg = new SystemMessage(SystemMessageId.PURCHASED_S2_FROM_S1);
                msg.addString(player.getName());
                msg.addItemName(newItem.getItemId());
                _owner.sendPacket(msg);

                msg = new SystemMessage(SystemMessageId.S1_PURCHASED_S2);
                msg.addString(_owner.getName());
                msg.addItemName(newItem.getItemId());
                player.sendPacket(msg);
            }
        }

        // Transfer adena
        if (price > ownerInventory.getAdena()) return false;
        L2ItemInstance adenaItem = ownerInventory.getAdenaInstance();
        ownerInventory.reduceAdena("PrivateStore", price, _owner, player);
        ownerIU.addItem(adenaItem);
        playerInventory.addAdena("PrivateStore", price, player, _owner);
        playerIU.addItem(playerInventory.getAdenaInstance());

        // Send inventory update packet
        _owner.sendPacket(ownerIU);
        player.sendPacket(playerIU);
        return true;
View Full Code Here

    L2ItemInstance[] unequiped =
      activeChar.getInventory().unEquipItemInBodySlotAndRecord(_slot);

    // show the update in the inventory
    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.abortAttack();
View Full Code Here

                }

                L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(item.getEquipSlot());
                if (item.isEquipped())
                {
                    InventoryUpdate iu = new InventoryUpdate();
                    for (int i = 0; i < unequiped.length; i++)
                    {
                        iu.addModifiedItem(unequiped[i]);
                    }
                    activeChar.sendPacket(iu);
               
                    activeChar.broadcastUserInfo();
                }
               
                int count = item.getCrystalCount() - (item.getItem().getCrystalCount() +1) / 2;
                if (count < 1) count = 1;
   
                L2ItemInstance destroyItem = activeChar.getInventory().destroyItem("Enchant", item, activeChar, null);
                if (destroyItem == null) return;
               
                L2ItemInstance crystals = activeChar.getInventory().addItem("Enchant", crystalId, count, activeChar, destroyItem);
           
                sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
                sm.addItemName(crystals.getItemId());
                sm.addNumber(count);
                activeChar.sendPacket(sm);
   
                if (!Config.FORCE_INVENTORY_UPDATE)
                {
                    InventoryUpdate iu = new InventoryUpdate();
                    if (destroyItem.getCount() == 0) iu.addRemovedItem(destroyItem);
                    else iu.addModifiedItem(destroyItem);
                    iu.addItem(crystals);
                   
                    activeChar.sendPacket(iu);
                }
                else activeChar.sendPacket(new ItemList(activeChar, true));
           
View Full Code Here

            sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
            return;
        }

        // Proceed to the transfer
    InventoryUpdate playerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
    for (int i = 0; i < _count; i++)
    {
      int objectId = _items[i * 2 + 0];
      int count = _items[i * 2 + 1];

      // check for an invalid item
      if (objectId == 0 && count == 0) continue;

      L2ItemInstance oldItem = player.getInventory().getItemByObjectId(objectId);
            if (oldItem == null)
            {
                _log.warning("Error depositing a warehouse object for char "+player.getName()+" (olditem == null)");
                continue;
            }

            int itemId = oldItem.getItemId();

            if ((itemId >= 6611 && itemId <= 6621) || itemId == 6842)
                continue;

      L2ItemInstance newItem = player.getInventory().transferItem("Warehouse", objectId, count, warehouse, player, player.getLastFolkNPC());
            if (newItem == null)
            {
              _log.warning("Error depositing a warehouse object for char "+player.getName()+" (newitem == null)");
              continue;
            }

            if (playerIU != null)
            {
              if (oldItem.getCount() > 0 && oldItem != newItem) playerIU.addModifiedItem(oldItem);
              else playerIU.addRemovedItem(oldItem);
            }
    }

        // Send updated item list to the player
    if (playerIU != null) player.sendPacket(playerIU);
View Full Code Here

      // Remove augementation boni on unequip
            if (item.isAugmented())
              item.getAugmentation().removeBoni(activeChar);

      L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart());
      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();

      ItemList il = new ItemList(activeChar, true);
View Full Code Here

            return;

        L2PcInstance partyLeader = associatedParty.getPartyMembers().get(0);
        L2ItemInstance addedOfferings = partyLeader.getInventory().addItem("Sign", SevenSignsFestival.FESTIVAL_OFFERING_ID, _bonusMultiplier, partyLeader, this);

        InventoryUpdate iu = new InventoryUpdate();

        if (addedOfferings.getCount() != _bonusMultiplier)
            iu.addModifiedItem(addedOfferings);
        else
            iu.addNewItem(addedOfferings);

        partyLeader.sendPacket(iu);

        super.doItemDrop(lastAttacker); // Normal drop
    }
View Full Code Here

    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);
    }
    else sendPacket(new ItemList(activeChar, true));
View Full Code Here

    // consume the life stone
    if (!player.destroyItem("RequestRefine", refinerItem, null, false))
      return false;

    // Prepare inventory update
    InventoryUpdate iu = new InventoryUpdate();

    if (gemstoneItem.getCount()-modifyGemstoneCount == 0)
    {
      player.destroyItem("RequestRefine", gemstoneItem, null, false);
      iu.addRemovedItem(gemstoneItem);
    }
    else
    {
      player.destroyItem("RequestRefine", _gemstoneItemObjId, modifyGemstoneCount, null, false);
      iu.addModifiedItem(gemstoneItem);
    }

    // generate augmentation
    targetItem.setAugmentation(AugmentationData.getInstance().generateRandomAugmentation(targetItem, lifeStoneLevel, lifeStoneGrade));

    // finish and send the inventory update packet
    iu.addModifiedItem(targetItem);
    iu.addRemovedItem(refinerItem);
    player.sendPacket(iu);

    return true;
  }
View Full Code Here

      player.sendPacket(new ItemList(player,false));
    }
    else //Has enough bait, consume 1 and update inventory. Start fishing follows.
    {
      lure2 = player.getInventory().destroyItem("Consume", player.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LHAND), 1, player, null);
      InventoryUpdate iu = new InventoryUpdate();
      iu.addModifiedItem(lure2);
      player.sendPacket(iu);
    }

    // If everything else checks out, actually cast the hook and start fishing... :P
    player.startFishing(x, y, z);
View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.serverpackets.InventoryUpdate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.