Package lineage2.gameserver.model.items

Examples of lineage2.gameserver.model.items.ItemInstance


    {
      parthner1.sendPacket(SystemMsg.YOU_MAY_NO_LONGER_ADJUST_ITEMS_IN_THE_TRADE_BECAUSE_THE_TRADE_HAS_BEEN_CONFIRMED);
      parthner1.sendActionFailed();
      return;
    }
    ItemInstance item = parthner1.getInventory().getItemByObjectId(_objectId);
    if ((item == null) || !item.canBeTraded(parthner1))
    {
      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


  {
    auction.broadcastToAllBidders(new SystemMessage(SystemMessage.S1_S_AUCTION_HAS_ENDED).addNumber(auction.getAuctionId()));
    ItemAuctionBid bid = auction.getHighestBid();
    if (bid != null)
    {
      ItemInstance item = auction.createNewItemInstance();
      Player player = bid.getPlayer();
      if (player != null)
      {
        player.getWarehouse().addItem(item);
        player.sendPacket(Msg.YOU_HAVE_BID_THE_HIGHEST_PRICE_AND_HAVE_WON_THE_ITEM_THE_ITEM_CAN_BE_FOUND_IN_YOUR_PERSONAL);
        _log.info("ItemAuction: Auction " + auction.getAuctionId() + " has finished. Highest bid by (name) " + player.getName() + " for instance " + _instanceId);
      }
      else
      {
        item.setOwnerId(bid.getCharId());
        item.setLocation(ItemLocation.WAREHOUSE);
        item.setJdbcState(JdbcEntityState.UPDATED);
        item.update();
        _log.info("ItemAuction: Auction " + auction.getAuctionId() + " has finished. Highest bid by (id) " + bid.getCharId() + " for instance " + _instanceId);
      }
    }
    else
    {
View Full Code Here

        mail.setSystemMsg2(rset.getInt(13));
        DbUtils.close(statement, rset);
        statement = con.prepareStatement(RESTORE_MAIL_ATTACHMENTS);
        statement.setInt(1, messageId);
        rset = statement.executeQuery();
        ItemInstance item;
        int objectId;
        while (rset.next())
        {
          objectId = rset.getInt(1);
          item = ItemsDAO.getInstance().load(objectId);
View Full Code Here

      {
        continue;
      }
      for (RewardItem item : items)
      {
        ItemInstance sweep = ItemFunctions.createItem(item.itemId);
        sweep.setCount(item.count);
        if (player.isInParty() && player.getParty().isDistributeSpoilLoot())
        {
          player.getParty().distributeItem(player, sweep, null);
          continue;
        }
        if (!player.getInventory().validateCapacity(sweep) || !player.getInventory().validateWeight(sweep))
        {
          sweep.dropToTheGround(player, targetMonster);
          continue;
        }
        player.getInventory().addItem(sweep);
        SystemMessage smsg;
        if (item.count == 1)
View Full Code Here

    {
      slots = 0;
      weight = 0;
      for (TradeItem ti : tradeList1)
      {
        ItemInstance item = parthner1.getInventory().getItemByObjectId(ti.getObjectId());
        if ((item == null) || (item.getCount() < ti.getCount()) || !item.canBeTraded(parthner1))
        {
          return;
        }
        weight = SafeMath.addAndCheck(weight, SafeMath.mulAndCheck(ti.getCount(), ti.getItem().getWeight()));
        if (!ti.getItem().isStackable() || (parthner2.getInventory().getItemByItemId(ti.getItemId()) == null))
        {
          slots++;
        }
      }
      if (!parthner2.getInventory().validateWeight(weight))
      {
        parthner2.sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
        return;
      }
      if (!parthner2.getInventory().validateCapacity(slots))
      {
        parthner2.sendPacket(Msg.YOUR_INVENTORY_IS_FULL);
        return;
      }
      slots = 0;
      weight = 0;
      for (TradeItem ti : tradeList2)
      {
        ItemInstance item = parthner2.getInventory().getItemByObjectId(ti.getObjectId());
        if ((item == null) || (item.getCount() < ti.getCount()) || !item.canBeTraded(parthner2))
        {
          return;
        }
        weight = SafeMath.addAndCheck(weight, SafeMath.mulAndCheck(ti.getCount(), ti.getItem().getWeight()));
        if (!ti.getItem().isStackable() || (parthner1.getInventory().getItemByItemId(ti.getItemId()) == null))
        {
          slots++;
        }
      }
      if (!parthner1.getInventory().validateWeight(weight))
      {
        parthner1.sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
        return;
      }
      if (!parthner1.getInventory().validateCapacity(slots))
      {
        parthner1.sendPacket(Msg.YOUR_INVENTORY_IS_FULL);
        return;
      }
      for (TradeItem ti : tradeList1)
      {
        ItemInstance item = parthner1.getInventory().removeItemByObjectId(ti.getObjectId(), ti.getCount());
        Log.LogItem(parthner1, Log.TradeSell, item);
        Log.LogItem(parthner2, Log.TradeBuy, item);
        parthner2.getInventory().addItem(item);
      }
      for (TradeItem ti : tradeList2)
      {
        ItemInstance item = parthner2.getInventory().removeItemByObjectId(ti.getObjectId(), ti.getCount());
        Log.LogItem(parthner2, Log.TradeSell, item);
        Log.LogItem(parthner1, Log.TradeBuy, item);
        parthner1.getInventory().addItem(item);
      }
      parthner1.sendPacket(Msg.YOUR_TRADE_IS_SUCCESSFUL);
View Full Code Here

        RewardItem item = monster.takeHarvest();
        if (item == null)
        {
          continue;
        }
        ItemInstance harvest;
        if (!player.getInventory().validateCapacity(item.itemId, item.count) || !player.getInventory().validateWeight(item.itemId, item.count))
        {
          harvest = ItemFunctions.createItem(item.itemId);
          harvest.setCount(item.count);
          harvest.dropToTheGround(player, monster);
          continue;
        }
        player.getInventory().addItem(item.itemId, item.count);
        player.sendPacket(new SystemMessage(SystemMessage.S1_HARVESTED_S3_S2_S).addName(player).addNumber(item.count).addItemName(item.itemId));
        if (player.isInParty())
View Full Code Here

    {
      for (GameObject obj : World.getAroundObjects(actor, 300, 200))
      {
        if (obj.isItem())
        {
          ItemInstance item = (ItemInstance) obj;
          if (item.getItemId() == Crystal_Fragment)
          {
            if (Rnd.chance(50))
            {
              Functions.npcSay(actor, says[Rnd.get(says.length)]);
            }
            itemToConsume = item;
            lastPoint = actor.getLoc();
            actor.setRunning();
            addTaskMove(item.getLoc(), false);
            return true;
          }
        }
      }
    }
View Full Code Here

   * @param player Player
   * @param itemObjId int
   */
  public void showCommissionInfo(Player player, int itemObjId)
  {
    ItemInstance item = player.getInventory().getItemByObjectId(itemObjId);
    if ((item != null) && item.canBeSold(player))
    {
      player.sendPacket(new ExResponseCommissionInfo(item));
    }
    else
    {
View Full Code Here

   * @param sale_days int
   */
  public void registerItem(Player player, int objectId, String item_name, long price, long count, int sale_days)
  {
    PcInventory inventory = player.getInventory();
    ItemInstance item = inventory.getItemByObjectId(objectId);
    if ((item == null) || (item.getCount() < count) || !item.canBeSold(player))
    {
      return;
    }
    int days = (sale_days * 2) + 1;
    if ((days <= 0) || (days > 7))
    {
      return;
    }
    inventory.writeLock();
    container.writeLock();
    try
    {
      long total = SafeMath.mulAndCheck(price, count);
      long fee = Math.round(SafeMath.mulAndCheck(total, days) * REGISTRATION_FEE);
      fee = Math.max(fee, MIN_FEE);
      if ((fee > player.getAdena()) || !player.reduceAdena(fee, false))
      {
        player.sendPacket(new SystemMessage2(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_ADENA_TO_REGISTER_THE_ITEM));
        return;
      }
      ItemInstance cItem = inventory.removeItemByObjectId(objectId, count);
      container.addItem(cItem);
      String item_type = cItem.getTemplate().getExItemType().name();
      CommissionShopDAO.getInstance().saveNewItem(cItem.getObjectId(), player.getObjectId(), item_name, price, item_type, sale_days, System.currentTimeMillis() + (days * 86400000), player.getName());
      Log.LogItem(player, Log.CommissionItemRegister, cItem);
    }
    catch (ArithmeticException ae)
    {
      _log.info("CommissionShopManager.registerItem: " + ae, ae);
View Full Code Here

      mail.setReceiverName(itemInfo.getSellerName());
      mail.setTopic("CommissionBuyTitle");
      mail.setBody(itemInfo.getItem().getName());
      mail.setSystemMsg1(3490);
      mail.setSystemMsg2(3491);
      ItemInstance item = ItemFunctions.createItem(ItemTemplate.ITEM_ID_ADENA);
      item.setLocation(ItemInstance.ItemLocation.MAIL);
      item.setCount(price - fee);
      if (item.getCount() > 0)
      {
        item.save();
        mail.addAttachment(item);
      }
      mail.setType(Mail.SenderType.SYSTEM);
      mail.setUnread(true);
      mail.setReturnable(false);
View Full Code Here

TOP

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

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.