Package lineage2.gameserver.model.items

Examples of lineage2.gameserver.model.items.TradeItem


    if (!TradeHelper.checksIfCanOpenStore(seller, _package ? Player.STORE_PRIVATE_SELL_PACKAGE : Player.STORE_PRIVATE_SELL))
    {
      seller.sendActionFailed();
      return;
    }
    TradeItem temp;
    List<TradeItem> sellList = new CopyOnWriteArrayList<>();
    seller.getInventory().writeLock();
    try
    {
      for (int i = 0; i < _count; i++)
      {
        int objectId = _items[i];
        long count = _itemQ[i];
        long price = _itemP[i];
        ItemInstance item = seller.getInventory().getItemByObjectId(objectId);
        if ((item == null) || (item.getCount() < count) || !item.canBeTraded(seller) || (item.getItemId() == ItemTemplate.ITEM_ID_ADENA))
        {
          continue;
        }
        temp = new TradeItem(item);
        temp.setCount(count);
        temp.setOwnersPrice(price);
        sellList.add(temp);
      }
    }
    finally
    {
View Full Code Here


      parthner1.sendPacket(SystemMsg.THIS_ITEM_CANNOT_BE_TRADED_OR_SOLD);
      return;
    }
    long count = Math.min(_amount, item.getCount());
    List<TradeItem> tradeList = parthner1.getTradeList();
    TradeItem tradeItem = null;
    try
    {
      for (TradeItem ti : parthner1.getTradeList())
      {
        if (ti.getObjectId() == _objectId)
        {
          count = SafeMath.addAndCheck(count, ti.getCount());
          count = Math.min(count, item.getCount());
          ti.setCount(count);
          tradeItem = ti;
          break;
        }
      }
    }
    catch (ArithmeticException ae)
    {
      parthner1.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);
      return;
    }
    if (tradeItem == null)
    {
      tradeItem = new TradeItem(item);
      tradeItem.setCount(count);
      tradeList.add(tradeItem);
    }
    parthner1.sendPacket(new TradeOwnAdd(tradeItem, tradeItem.getCount()), new TradeUpdate(tradeItem, item.getCount() - tradeItem.getCount()));
    parthner2.sendPacket(new TradeOtherAdd(tradeItem, tradeItem.getCount()));
  }
View Full Code Here

    List<TradeItem> registrableItems = new ArrayList<>(items.length);
    for (ItemInstance item : items)
    {
      if (item.canBeSold(player))
      {
        registrableItems.add(new TradeItem(item));
      }
    }
    player.sendPacket(new ExResponseCommissionItemList(registrableItems));
  }
View Full Code Here

    _buyList0 = buyer.getBuyList();
    _buyList = new ArrayList<TradeItem>();

    ItemInstance[] items = buyer.getInventory().getItems();
    ArrayUtils.eqSort(items, ItemClassComparator.getInstance());
    TradeItem bi;
    for (ItemInstance item : items)
      if (item.canBeTraded(buyer) && item.getItemId() != ItemTemplate.ITEM_ID_ADENA)
      {
        _buyList.add(bi = new TradeItem(item));
        bi.setObjectId(0);
      }
  }
View Full Code Here

        ItemInstance item = seller.getInventory().getItemByObjectId(objectId);
        if ((item == null) || (item.getCount() < count) || !item.canBeTraded(seller))
        {
          break loop;
        }
        TradeItem si = null;
        for (TradeItem bi : buyList)
        {
          if (bi.getItemId() == item.getItemId())
          {
            if (bi.getOwnersPrice() == price)
            {
              if (count > bi.getCount())
              {
                break loop;
              }
              totalCost = SafeMath.addAndCheck(totalCost, SafeMath.mulAndCheck(count, price));
              weight = SafeMath.addAndCheck(weight, SafeMath.mulAndCheck(count, item.getTemplate().getWeight()));
              if (!item.isStackable() || (buyer.getInventory().getItemByItemId(item.getItemId()) == null))
              {
                slots++;
              }
              si = new TradeItem();
              si.setObjectId(objectId);
              si.setItemId(item.getItemId());
              si.setCount(count);
              si.setOwnersPrice(price);
              sellList.add(si);
              break;
            }
          }
        }
      }
    }
    catch (ArithmeticException ae)
    {
      sellList.clear();
      sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
      return;
    }
    finally
    {
      try
      {
        if (sellList.size() != _count)
        {
          seller.sendPacket(Msg.THE_ATTEMPT_TO_SELL_HAS_FAILED);
          seller.sendActionFailed();
          return;
        }
        if (!buyer.getInventory().validateWeight(weight))
        {
          buyer.sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
          seller.sendPacket(Msg.THE_ATTEMPT_TO_SELL_HAS_FAILED);
          seller.sendActionFailed();
          return;
        }
        if (!buyer.getInventory().validateCapacity(slots))
        {
          buyer.sendPacket(Msg.YOUR_INVENTORY_IS_FULL);
          seller.sendPacket(Msg.THE_ATTEMPT_TO_SELL_HAS_FAILED);
          seller.sendActionFailed();
          return;
        }
        if (!buyer.reduceAdena(totalCost))
        {
          buyer.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
          seller.sendPacket(Msg.THE_ATTEMPT_TO_SELL_HAS_FAILED);
          seller.sendActionFailed();
          return;
        }
        ItemInstance item;
        for (TradeItem si : sellList)
        {
          item = seller.getInventory().removeItemByObjectId(si.getObjectId(), si.getCount());
          for (TradeItem bi : buyList)
          {
            if (bi.getItemId() == si.getItemId())
            {
              if (bi.getOwnersPrice() == si.getOwnersPrice())
              {
                bi.setCount(bi.getCount() - si.getCount());
                if (bi.getCount() < 1L)
                {
                  buyList.remove(bi);
                }
                break;
View Full Code Here

              totalCost = SafeMath.addAndCheck(totalCost, SafeMath.mulAndCheck(count, price));
              continue loop;
            }
          }
        }
        TradeItem bi = new TradeItem();
        bi.setItemId(itemId);
        bi.setCount(count);
        bi.setOwnersPrice(price);
        totalCost = SafeMath.addAndCheck(totalCost, SafeMath.mulAndCheck(count, price));
        buyList.add(bi);
      }
    }
    catch (ArithmeticException ae)
View Full Code Here

        {
          activeChar.sendActionFailed();
          return;
        }
        totalPrice = SafeMath.addAndCheck(totalPrice, SafeMath.mulAndCheck(count, price));
        TradeItem ti = new TradeItem();
        ti.setItemId(itemId);
        ti.setCount(count);
        ti.setOwnersPrice(price);
        weight = SafeMath.addAndCheck(weight, SafeMath.mulAndCheck(count, ti.getItem().getWeight()));
        if (!ti.getItem().isStackable() || (activeChar.getInventory().getItemByItemId(itemId) == null))
        {
          slots++;
        }
        buyList.add(ti);
      }
      tax = (long) (totalPrice * taxRate);
      totalPrice = SafeMath.addAndCheck(totalPrice, tax);
      if (!activeChar.getInventory().validateWeight(weight))
      {
        sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
        return;
      }
      if (!activeChar.getInventory().validateCapacity(slots))
      {
        sendPacket(Msg.YOUR_INVENTORY_IS_FULL);
        return;
      }
      if (!activeChar.reduceAdena(totalPrice))
      {
        activeChar.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
        return;
      }
      for (TradeItem ti : buyList)
      {
        activeChar.getInventory().addItem(ti.getItemId(), ti.getCount());
      }
      list.updateItems(buyList);
      if (castle != null)
      {
        if ((tax > 0) && (castle.getOwnerId() > 0) && (activeChar.getReflection() == ReflectionManager.DEFAULT))
View Full Code Here

          {
            NpcTradeList tradeList = new NpcTradeList(0);
            List<SeedProduction> seeds = castle.getSeedProduction(CastleManorManager.PERIOD_CURRENT);
            for (SeedProduction s : seeds)
            {
              TradeItem item = new TradeItem();
              item.setItemId(s.getId());
              item.setOwnersPrice(s.getPrice());
              item.setCount(s.getCanProduce());
              if ((item.getCount() > 0) && (item.getOwnersPrice() > 0))
              {
                tradeList.addItem(item);
              }
            }
            BuyListSeed bl = new BuyListSeed(tradeList, castleId, player.getAdena());
View Full Code Here

        }
        if (count > itemToSell.getCount())
        {
          count = itemToSell.getCount();
        }
        TradeItem i = new TradeItem(itemToSell);
        i.setCount(count);
        i.setOwnersPrice(price);
        _sellList.add(i);
      }
      var = getVar("sellstorename");
      if (var != null)
      {
        setSellStoreName(var);
      }
    }
    var = getVar("packageselllist");
    if (var != null)
    {
      _packageSellList = new CopyOnWriteArrayList<TradeItem>();
      String[] items = var.split(":");
      for (String item : items)
      {
        if (item.equals(""))
        {
          continue;
        }
        String[] values = item.split(";");
        if (values.length < 3)
        {
          continue;
        }
        int oId = Integer.parseInt(values[0]);
        long count = Long.parseLong(values[1]);
        long price = Long.parseLong(values[2]);
        ItemInstance itemToSell = getInventory().getItemByObjectId(oId);
        if ((count < 1) || (itemToSell == null))
        {
          continue;
        }
        if (count > itemToSell.getCount())
        {
          count = itemToSell.getCount();
        }
        TradeItem i = new TradeItem(itemToSell);
        i.setCount(count);
        i.setOwnersPrice(price);
        _packageSellList.add(i);
      }
      var = getVar("sellstorename");
      if (var != null)
      {
        setSellStoreName(var);
      }
    }
    var = getVar("buylist");
    if (var != null)
    {
      _buyList = new CopyOnWriteArrayList<TradeItem>();
      String[] items = var.split(":");
      for (String item : items)
      {
        if (item.equals(""))
        {
          continue;
        }
        String[] values = item.split(";");
        if (values.length < 3)
        {
          continue;
        }
        TradeItem i = new TradeItem();
        i.setItemId(Integer.parseInt(values[0]));
        i.setCount(Long.parseLong(values[1]));
        i.setOwnersPrice(Long.parseLong(values[2]));
        _buyList.add(i);
      }
      var = getVar("buystorename");
      if (var != null)
      {
View Full Code Here

      Player player = cha.getPlayer();
     
      QuestState qs = player.getQuestState(_10301_ShadowOfTerrorBlackishRedFog.class);
      if(qs != null && qs.getCond() == 3 && player.getVar("instance10301") == null)
      {
        Quest q = QuestManager.getQuest(10301);
        player.processQuestEvent(q.getName(), "enterInstance", null);
        //player.setVar("instance10301", "true", -1);
        return;
      }
      if (!player.getVarB("@25_20_telzone_to_magmeld"))
      {
View Full Code Here

TOP

Related Classes of lineage2.gameserver.model.items.TradeItem

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.