Package com.l2jfrozen.gameserver.model

Examples of com.l2jfrozen.gameserver.model.TradeList


      player.sendMessage("Trade are disable here. Try in another place.");
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    TradeList tradeList = player.getBuyList();
    tradeList.clear();
   
    int cost = 0;
    for (int i = 0; i < _count; i++)
    {
      int itemId = _items[i * 4 + 0];
      int count = _items[i * 4 + 1];
      int price = _items[i * 4 + 2];
      int enchant = _items[i * 4 + 3];
     
      tradeList.addItemByItemId(itemId, count, price, enchant);
      cost += count * price;
     
      if (cost > Integer.MAX_VALUE)
      {
        player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED));
View Full Code Here


      player.sendMessage("Trade are disable here. Try in another place.");
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    TradeList tradeList = player.getSellList();
    tradeList.clear();
    tradeList.setPackaged(_packageSale);
   
    long totalCost = player.getAdena();
    for (int i = 0; i < _count; i++)
    {
      int objectId = _items[i * 3 + 0];
      int count = _items[i * 3 + 1];
      int price = _items[i * 3 + 2];
     
      if (price <= 0)
      {
        String msgErr = "[SetPrivateStoreListSell] player " + getClient().getActiveChar().getName() + " tried an overflow exploit (use PHX), ban this player!";
        Util.handleIllegalPlayerAction(getClient().getActiveChar(), msgErr, Config.DEFAULT_PUNISH);
        _count = 0;
        _items = null;
        return;
      }
     
      totalCost += price;
      if (totalCost > Integer.MAX_VALUE)
      {
        player.sendPacket(new PrivateStoreManageListSell(player));
        player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED));
        return;
      }
     
      tradeList.addItem(objectId, count, price);
    }
   
    if (_count <= 0)
    {
      player.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
View Full Code Here

      player.sendMessage("Unsufficient privileges.");
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }
   
    TradeList storeList = storePlayer.getSellList();
   
    if (storeList == null)
      return;
   
    // Check if player didn't choose any items
    if (_items == null || _items.length == 0)
    {
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }
   
    // FIXME: this check should be (and most probabliy is) done in the TradeList mechanics
    long priceTotal = 0;
    for (ItemRequest ir : _items)
    {
      if (ir.getCount() > Integer.MAX_VALUE || ir.getCount() < 0)
      {
        String msgErr = "[RequestPrivateStoreBuy] player " + getClient().getActiveChar().getName() + " tried an overflow exploit, ban this player!";
        Util.handleIllegalPlayerAction(getClient().getActiveChar(), msgErr, Config.DEFAULT_PUNISH);
        return;
      }
     
      TradeItem sellersItem = storeList.getItem(ir.getObjectId());
     
      if (sellersItem == null)
      {
        String msgErr = "[RequestPrivateStoreBuy] player " + getClient().getActiveChar().getName() + " tried to buy an item not sold in a private store (buy), ban this player!";
        Util.handleIllegalPlayerAction(getClient().getActiveChar(), msgErr, Config.DEFAULT_PUNISH);
        return;
      }
     
      if (ir.getPrice() != sellersItem.getPrice())
      {
        String msgErr = "[RequestPrivateStoreBuy] player " + getClient().getActiveChar().getName() + " tried to change the seller's price in a private store (buy), ban this player!";
        Util.handleIllegalPlayerAction(getClient().getActiveChar(), msgErr, Config.DEFAULT_PUNISH);
        return;
      }
     
      L2ItemInstance iEnchant = storePlayer.getInventory().getItemByObjectId(ir.getObjectId());
      int enchant = 0;
      if (iEnchant == null)
      {
        enchant = 0;
      }
      else
      {
        enchant = iEnchant.getEnchantLevel();
      }
      ir.setEnchant(enchant);
     
      priceTotal += ir.getPrice() * ir.getCount();
    }
   
    // FIXME: this check should be (and most probabliy is) done in the TradeList mechanics
    if (priceTotal < 0 || priceTotal > Integer.MAX_VALUE)
    {
      String msgErr = "[RequestPrivateStoreBuy] player " + getClient().getActiveChar().getName() + " tried an overflow exploit, ban this player!";
      Util.handleIllegalPlayerAction(getClient().getActiveChar(), msgErr, Config.DEFAULT_PUNISH);
      return;
    }
   
    if (Config.SELL_BY_ITEM)
    {
      if (player.getItemCount(Config.SELL_ITEM, -1) < priceTotal)
      {
        sendPacket(SystemMessage.sendString("You do not have needed items to buy"));
        sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }
     
    }
    else
    {
      if (player.getAdena() < priceTotal)
      {
        sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
        sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }
    }
   
    if (storePlayer.getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_PACKAGE_SELL)
    {
      if (storeList.getItemCount() > _count)
      {
        String msgErr = "[RequestPrivateStoreBuy] player " + getClient().getActiveChar().getName() + " tried to buy less items then sold by package-sell, ban this player for bot-usage!";
        Util.handleIllegalPlayerAction(getClient().getActiveChar(), msgErr, Config.DEFAULT_PUNISH);
        return;
      }
    }
   
    if (!storeList.PrivateStoreBuy(player, _items, (int) priceTotal))
    {
      sendPacket(ActionFailed.STATIC_PACKET);
      // Punishment e log in audit
      Util.handleIllegalPlayerAction(storePlayer, "PrivateStore buy has failed due to invalid list or request. Player: " + player.getName(), Config.DEFAULT_PUNISH);
      _log.warning("PrivateStore buy has failed due to invalid list or request. Player: " + player.getName() + ", Private store of: " + storePlayer.getName());
      return;
    }
   
    if (storeList.getItemCount() == 0)
    {
      storePlayer.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
      storePlayer.broadcastUserInfo();
    }
   
View Full Code Here

   
    L2PcInstance storePlayer = (L2PcInstance) object;
    if (storePlayer.getPrivateStoreType() != L2PcInstance.STORE_PRIVATE_BUY)
      return;
   
    TradeList storeList = storePlayer.getBuyList();
    if (storeList == null)
      return;
   
    // Check if player didn't choose any items
    if (_items == null || _items.length == 0)
    {
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }
   
    if (storeList.getItemCount() == 0)
    {
      storePlayer.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
      storePlayer.broadcastUserInfo();
      return;
    }
   
    if (!player.getAccessLevel().allowTransaction())
    {
      player.sendMessage("Unsufficient privileges.");
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }
   
    if (Config.SELL_BY_ITEM)
    {
      if (storePlayer.getItemCount(Config.SELL_ITEM, -1) < _price)
      {
        sendPacket(ActionFailed.STATIC_PACKET);
        sendPacket(SystemMessage.sendString("You have not enough items to buy, canceling PrivateBuy"));
        storePlayer.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
        storePlayer.broadcastUserInfo();
        return;
      }
     
    }
    else
    {
      if (storePlayer.getAdena() < _price)
      {
        sendPacket(ActionFailed.STATIC_PACKET);
        storePlayer.sendMessage("You have not enough adena, canceling PrivateBuy.");
        storePlayer.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
        storePlayer.broadcastUserInfo();
        return;
      }
    }
   
    if (!storeList.PrivateStoreSell(player, _items, _price))
    {
      sendPacket(ActionFailed.STATIC_PACKET);
      Util.handleIllegalPlayerAction(getClient().getActiveChar(), "Player " + getClient().getActiveChar().getName() + " provided invalid list or request! ", Config.DEFAULT_PUNISH);
      _log.warning("PrivateStore sell has failed due to invalid list or request. Player: " + player.getName() + ", Private store of: " + storePlayer.getName());
      return;
    }
   
    if (storeList.getItemCount() == 0)
    {
      storePlayer.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
      storePlayer.broadcastUserInfo();
    }
   
View Full Code Here

      player.sendMessage("You trading too fast.");
      return;
    }
   
   
    TradeList trade = player.getActiveTradeList();
    if(trade == null)
    {
      //_log.warning("player.getTradeList == null in " + getType() + " for player " + player.getName());
      return;
    }

    if(trade.getOwner().getActiveEnchantItem() != null || trade.getPartner().getActiveEnchantItem() != null)
      return;

    if(trade.isLocked())
      return;

    //abort cast anyway
    player.abortCast(true);
   
    if(player.isCastingNow() || player.isCastingPotionNow())
    {
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if(_response == 1)
    {
      if(trade.getPartner() == null || L2World.getInstance().findObject(trade.getPartner().getObjectId()) == null)
      {
        // Trade partner not found, cancel trade
        player.cancelActiveTrade();
        SystemMessage msg = new SystemMessage(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
        player.sendPacket(msg);
        msg = null;
        return;
      }

      if(!player.getAccessLevel().allowTransaction())
      {
        player.sendMessage("Unsufficient privileges.");
        player.cancelActiveTrade();
        player.sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }
      trade.confirm();
    }
    else
    {
      player.cancelActiveTrade();
    }
View Full Code Here

  {
    final L2PcInstance player = getClient().getActiveChar();
    if (player == null) // Player null
      return;

    final TradeList trade = player.getActiveTradeList();
    if (trade == null) // Trade null
    {
      _log.warning("Character: " + player.getName() + " requested item:" + _objectId + " add without active tradelist:" + _tradeId);
      return;
    }

    // Check Partner and ocbjectId
    if (trade.getPartner() == null || L2World.getInstance().findObject(trade.getPartner().getObjectId()) == null)
    {
      // Trade partner not found, cancel trade
      if(trade.getPartner() != null)
        _log.warning("Character:" + player.getName() + " requested invalid trade object: " + _objectId);

      player.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME));
      player.cancelActiveTrade();
      return;
    }

    // Check if player has Access level for Transaction
    if (!player.getAccessLevel().allowTransaction())
    {
      player.sendMessage("Transactions are disable for your Access Level.");
      player.cancelActiveTrade();
      return;
    }

    // Check validateItemManipulation
    if (!player.validateItemManipulation(_objectId, "trade"))
    {
      player.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
      return;
    }

    // Java Emulator Security
    if (player.getInventory().getItemByObjectId(_objectId) == null || _count <= 0)
    {
      _log.info("Character:" + player.getName() + " requested invalid trade object");
      return;
    }
   
    final TradeList.TradeItem item = trade.addItem(_objectId, _count);   
    if (item == null)
      return;

    if (item.isAugmented())
      return;
   
    player.sendPacket(new TradeOwnAdd(item));
    player.sendPacket(new TradeUpdate(trade, player));
    trade.getPartner().sendPacket(new TradeOtherAdd(item));
  }
View Full Code Here

                for (L2PcInstance player : pls)
                {
                  if (player.getPrivateStoreType() == 0)
                    continue;
                 
                  TradeList list = null;
                  String content = "";
                 
                  if (player.getPrivateStoreType() == 1) // sell
                  {
                    list = player.getSellList();
                    for (com.l2jfrozen.gameserver.model.TradeList.TradeItem item : list.getItems())
                    {
                      content += item.getItem().getItemId() + ":" + item.getEnchant() + ":" + item.getPrice() + ":";
                    }
                    content = player.getName() + ";" + "sell;" + player.getX() + ";" + player.getY() + ";" + content;
                    _print.println(content);
                    continue;
                  }
                  else if (player.getPrivateStoreType() == 3) // buy
                  {
                    list = player.getBuyList();
                    for (com.l2jfrozen.gameserver.model.TradeList.TradeItem item : list.getItems())
                    {
                      content += item.getItem().getItemId() + ":" + item.getEnchant() + ":" + item.getPrice() + ":";
                    }
                    content = player.getName() + ";" + "buy;" + player.getX() + ";" + player.getY() + ";" + content;
                    _print.println(content);
View Full Code Here

      player.sendMessage("You cannot Logout while in registered in an Event.");
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return false;
    }
   
    TradeList storeListBuy = player.getBuyList();
    if (storeListBuy == null && storeListBuy.getItemCount() == 0)
    {
      player.sendMessage("Your buy list is empty.");
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return false;
    }
   
    TradeList storeListSell = player.getSellList();
    if (storeListSell == null && storeListSell.getItemCount() == 0)
    {
      player.sendMessage("Your sell list is empty.");
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return false;
    }
View Full Code Here

      player.sendMessage("You cannot Logout while in registered in an Event.");
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return false;
    }
   
    TradeList storeListBuy = player.getBuyList();
    if (storeListBuy == null && storeListBuy.getItemCount() == 0)
    {
      player.sendMessage("Your buy list is empty.");
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return false;
    }
   
    TradeList storeListSell = player.getSellList();
    if (storeListSell == null && storeListSell.getItemCount() == 0)
    {
      player.sendMessage("Your sell list is empty.");
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return false;
    }
View Full Code Here

   *
   * @param partner the partner
   */
  public void onTradeStart(L2PcInstance partner)
  {
    _activeTradeList = new TradeList(this);
    _activeTradeList.setPartner(partner);

    SystemMessage msg = new SystemMessage(SystemMessageId.BEGIN_TRADE_WITH_S1);
    msg.addString(partner.getName());
    sendPacket(msg);
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.model.TradeList

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.