Ejemplo n.º 1
0
  @Override
  protected void runImpl() {
    final L2PcInstance player = getClient().getActiveChar();
    if (player == null) return;

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

    final L2PcInstance partner = trade.getPartner();
    if (partner == null
        || L2World.getInstance().getPlayer(partner.getObjectId()) == null
        || partner.getActiveTradeList() == null) {
      // Trade partner not found, cancel trade
      if (partner != null)
        _log.warning(
            "Character:" + player.getName() + " requested invalid trade object: " + _objectId);
      SystemMessage msg = new SystemMessage(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
      player.sendPacket(msg);
      player.cancelActiveTrade();
      return;
    }

    if (trade.isConfirmed() || partner.getActiveTradeList().isConfirmed()) {
      player.sendPacket(
          new SystemMessage(SystemMessageId.CANNOT_ADJUST_ITEMS_AFTER_TRADE_CONFIRMED));
      return;
    }

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

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

    final TradeList.TradeItem item = trade.addItem(_objectId, _count);
    if (item != null) {
      player.sendPacket(new TradeOwnAdd(item));
      trade.getPartner().sendPacket(new TradeOtherAdd(item));
    }
  }
Ejemplo n.º 2
0
    public boolean addToTradeList(TradeList list) {
      if ((MAX_ADENA / _count) < _price) {
        return false;
      }

      list.addItemByItemId(
          _itemId,
          _count,
          _price,
          _enchantLevel,
          _attackAttribute,
          _attackAttributeValue,
          _defenseAttributes,
          _appearanceId);
      return true;
    }
Ejemplo n.º 3
0
  @Override
  protected void runImpl() {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null) {
      return;
    }

    if (_items == null) {
      player.setPrivateStoreType(PrivateStoreType.NONE);
      player.broadcastUserInfo();
      return;
    }

    if (!player.getAccessLevel().allowTransaction()) {
      player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
      return;
    }

    if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player) || player.isInDuel()) {
      player.sendPacket(
          SystemMessageId
              .WHILE_YOU_ARE_ENGAGED_IN_COMBAT_YOU_CANNOT_OPERATE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (player.isInsideZone(ZoneId.NO_STORE)) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(SystemMessageId.YOU_CANNOT_OPEN_A_PRIVATE_STORE_HERE);
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (!player.canOpenPrivateStore()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    TradeList tradeList = player.getBuyList();
    tradeList.clear();

    // Check maximum number of allowed slots for pvt shops
    if (_items.length > player.getPrivateBuyStoreLimit()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
      return;
    }

    long totalCost = 0;
    for (Item i : _items) {
      if (!i.addToTradeList(tradeList)) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set price more than "
                + MAX_ADENA
                + " adena in Private Store - Buy.",
            Config.DEFAULT_PUNISH);
        return;
      }

      totalCost += i.getCost();
      if (totalCost > MAX_ADENA) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set total price more than "
                + MAX_ADENA
                + " adena in Private Store - Buy.",
            Config.DEFAULT_PUNISH);
        return;
      }
    }

    // Check for available funds
    if (totalCost > player.getAdena()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(
          SystemMessageId
              .THE_PURCHASE_PRICE_IS_HIGHER_THAN_THE_AMOUNT_OF_MONEY_THAT_YOU_HAVE_AND_SO_YOU_CANNOT_OPEN_A_PERSONAL_STORE);
      return;
    }

    player.sitDown();
    player.setPrivateStoreType(PrivateStoreType.BUY);
    player.broadcastUserInfo();
    player.broadcastPacket(new PrivateStoreMsgBuy(player));
  }