Package com.l2jfrozen.gameserver.network.serverpackets

Examples of com.l2jfrozen.gameserver.network.serverpackets.InventoryUpdate


      getOwner().sendPacket(new SystemMessage(SystemMessageId.SLOTS_FULL));
    }
    else
    {
      // Prepare inventory update packet
      InventoryUpdate ownerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
      InventoryUpdate partnerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();

      // Transfer items
      partnerList.TransferItems(getOwner(), partnerIU, ownerIU);
      TransferItems(partnerList.getOwner(), ownerIU, partnerIU);
View Full Code Here


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

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

    if(Config.SELL_BY_ITEM){
      // Transfer Item
      if(price > playerInventory.getInventoryItemCount(Config.SELL_ITEM, -1))
      {
        //no useful lock to seller
        //lock();
        return false;
      }
     
      L2ItemInstance item = playerInventory.getItemByItemId(Config.SELL_ITEM);
     
      if(item==null){
        System.out.println("Buyer Medals are null");
        //no useful lock to seller
        //lock();
        return false;
      }
     
      // Check if requested item is available for manipulation
      L2ItemInstance oldItem = player.checkItemManipulation(item.getObjectId(), price, "sell");
      if(oldItem == null)
      {
        System.out.println("Buyer old medals null");
        //no useful lock to seller
        //lock();
        return false;
      }

      // Proceed with item transfer
      L2ItemInstance newItem = playerInventory.transferItem("PrivateStore", item.getObjectId(), price, ownerInventory, player, _owner);
      if(newItem == null){
        System.out.println("Buyer new medals null");
        return false;
      }
     
      // 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
      SystemMessage msg = SystemMessage.sendString("You obtained "+price+" "+item.getItemName());
      _owner.sendPacket(msg);
      msg = null;
     
      SystemMessage msg2 = SystemMessage.sendString("You spent "+price+" "+item.getItemName());
      player.sendPacket(msg2);
     
      /*L2ItemInstance item = playerInventory.getItemByItemId(Config.SELL_ITEM);
      playerInventory.destroyItem("PrivateStore", item.getObjectId(), price, player, _owner);
      playerIU.addItem(item);
      L2ItemInstance item2 = ownerInventory.getItemByItemId(Config.SELL_ITEM);
      ownerInventory.addItem("PrivateStore", item2.getObjectId(), price, _owner, player);
      ownerIU.addItem(ownerInventory.getItemByItemId(Config.SELL_ITEM));
      */
     
    }else{
      // 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())
      {
View Full Code Here

    PcInventory ownerInventory = _owner.getInventory();
    PcInventory playerInventory = player.getInventory();
   
    // Prepare inventory update packet
    InventoryUpdate ownerIU = new InventoryUpdate();
    InventoryUpdate playerIU = new InventoryUpdate();

    //we must check item are available before begining transaction, TODO: should we remove that check when transfering items as it's done here? (there might be synchro problems if player clicks fast if we remove it)
    // also check if augmented items are traded. If so, cancel it...
    for(ItemRequest item : items)
    {
      // Check if requested item is available for manipulation
      L2ItemInstance oldItem = player.checkItemManipulation(item.getObjectId(), item.getCount(), "sell");
      if(oldItem == null){
        if(Config.DEBUG){
          _log.info("[PrivateStoreSell] player.checkItemManipulation(item.getObjectId(), item.getCount(), 'sell') null, return false");
        }
        return false;
      }
     
      boolean found = false;
      for (TradeItem ti : _items)
      {
        if (ti.getItem().getItemId() == item.getItemId())
        {
         
          if (ti.getPrice() != item.getPrice())
          {
            if (Config.DEBUG)
            {
              _log.info("[PrivateStoreSell] ti.getPrice() != item.getPrice(), return false");
            }
            return false;
          }
         
          if (ti.getEnchant() != item.getEnchant())
          {
           
            player.sendMessage("Incorect enchant level.");
            return false;
           
          }
         
          L2Object obj = L2World.getInstance().findObject(item.getObjectId());
          if ((obj == null) || (!(obj instanceof L2ItemInstance)))
          {
            String msgErr = "[RequestPrivateStoreSell] player " + _owner.getName() + " tried to sell null item in a private store (buy), ban this player!";
            Util.handleIllegalPlayerAction(_owner, msgErr, Config.DEFAULT_PUNISH);
            return false;
          }
         
          L2ItemInstance itemInstance = (L2ItemInstance) obj;
          if (item.getEnchant() != itemInstance.getEnchantLevel())
          {
            String msgErr = "[RequestPrivateStoreSell] player " + _owner.getName() + " tried to change enchant level in a private store (buy), ban this player!";
            Util.handleIllegalPlayerAction(_owner, msgErr, Config.DEFAULT_PUNISH);
            return false;
          }
         
          found = true;
          break;
         
        }
      }
     
      //store is not buying that item...
      if(!found){
        String msg = "Requested Item is not available to sell... You are perfoming illegal operation, it has been segnalated";
        _log.warning("ATTENTION: Player "+player.getName()+" has performed sell illegal operation..");
        player.sendMessage(msg);
        msg = null;
        return false;
      }
     
      if(oldItem.getAugmentation() != null)
      {
        String msg = "Transaction failed. Augmented items may not be exchanged.";
        _owner.sendMessage(msg);
        player.sendMessage(msg);
        msg = null;
        return false;
      }

      oldItem = null;
    }

    // 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){
        if(Config.DEBUG){
          _log.info("[PrivateStoreSell] oldItem == null, return false");
        }
        return false;
      }
     
      // Check if requested item is correct
      if (oldItem.getItemId() != item.getItemId())
      {
        Util.handleIllegalPlayerAction(player, player+" is cheating with sell items", Config.DEFAULT_PUNISH);
        return false;
      }
     
      // Proceed with item transfer
      L2ItemInstance newItem = playerInventory.transferItem("PrivateStore", item.getObjectId(), item.getCount(), ownerInventory, player, _owner);
      if(newItem == null){
        if(Config.DEBUG){
          _log.info("[PrivateStoreSell] newItem == null, return false");
        }
       
        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 = null;

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

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

      newItem = null;
      oldItem = null;
    }

    if(Config.SELL_BY_ITEM){
      // Transfer Item
      if(price > ownerInventory.getInventoryItemCount(Config.SELL_ITEM, -1))
      {
        lock();
        if(Config.DEBUG){
          _log.info("[PrivateStoreSell] price > ownerInventory.getInventoryItemCount(Config.SELL_ITEM, -1), return false");
        }
       
        return false;
      }
     
      L2ItemInstance item = ownerInventory.getItemByItemId(Config.SELL_ITEM);
     
      if(item==null){
        if(Config.DEBUG){
          _log.info("[PrivateStoreSell] item==null, return false");
        }
       
        lock();
        return false;
      }
     
     
      // Check if requested item is available for manipulation
      L2ItemInstance oldItem = _owner.checkItemManipulation(item.getObjectId(), price, "sell");
      if(oldItem == null)
      {
        lock();
        if(Config.DEBUG){
          _log.info("[PrivateStoreSell] _owner.checkItemManipulation(item.getObjectId(), price, 'sell')==null, return false");
        }
       
        return false;
      }

      // Proceed with item transfer
      L2ItemInstance newItem = ownerInventory.transferItem("PrivateStore", item.getObjectId(), price, playerInventory,_owner, player);
      if(newItem == null){
        if(Config.DEBUG){
          _log.info("[PrivateStoreSell] newItem = ownerInventory.transferItem('PrivateStore', item.getObjectId(), price, playerInventory,_owner, player) == null, return false");
        }
       
        return false;
      }
     
      // 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
      SystemMessage msg = SystemMessage.sendString("You obtained "+price+" "+item.getItemName());
      player.sendPacket(msg);
      msg = null;
     
      SystemMessage msg2 = SystemMessage.sendString("You spent "+price+" "+item.getItemName());
      _owner.sendPacket(msg2);
    }else{
     
      // Transfer adena
      if(price > ownerInventory.getAdena()){
        if(Config.DEBUG){
          _log.info("[PrivateStoreSell] price > ownerInventory.getAdena(), return false");
        }
       
        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
View Full Code Here

        // unequip
        if(isEquipped())
        {
          L2ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getEquipSlot());
          InventoryUpdate iu = new InventoryUpdate();

          for(L2ItemInstance element : unequiped)
          {
            player.checkSSMatch(null, element);
            iu.addModifiedItem(element);
          }

          player.sendPacket(iu);

          unequiped = null;
          iu = null;
        }

        if(getLocation() != ItemLocation.WAREHOUSE)
        {
          // destroy
          player.getInventory().destroyItem("L2ItemInstance", this, player, null);

          // send update
          InventoryUpdate iu = new InventoryUpdate();
          iu.addRemovedItem(this);
          player.sendPacket(iu);
          iu = null;

          StatusUpdate su = new StatusUpdate(player.getObjectId());
          su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
          player.sendPacket(su);
          su = null;
        }
        else
        {
          player.getWarehouse().destroyItem("L2ItemInstance", this, player, null);
        }

        // delete from world
        L2World.getInstance().removeObject(this);
      }
      else
      {
        // Reschedule if still equipped
        if(!_consumingMana && isEquipped())
          scheduleConsumeManaTask();
       
        if(getLocation() != ItemLocation.WAREHOUSE)
        {
          InventoryUpdate iu = new InventoryUpdate();
          iu.addModifiedItem(this);
          player.sendPacket(iu);
          iu = null;
        }
      }
View Full Code Here

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

    associatedParty = null;

    InventoryUpdate iu = new InventoryUpdate();

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

    addedOfferings = null;

    partyLeader.sendPacket(iu);
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.network.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.