Пример #1
0
  /** Remove bids */
  private void removeBids() {
    Connection con = null;
    try {
      con = L2DatabaseFactory.getInstance().getConnection(con);
      PreparedStatement statement;

      statement = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=?");
      statement.setInt(1, getId());
      statement.execute();

      statement.close();
    } catch (Exception e) {
      _log.fatal("Exception: Auction.deleteFromDB(): " + e.getMessage(), e);
    } finally {
      L2DatabaseFactory.close(con);
    }

    for (Bidder b : _bidders.values()) {
      if (ClanTable.getInstance().getClanByName(b.getClanName()).getHasHideout() == 0)
        returnItem(b.getClanName(), PcInventory.ADENA_ID, b.getBid(), true); // 10 % tax
      else {
        L2Player bidder = L2World.getInstance().getPlayer(b.getName());
        if (bidder != null) bidder.sendMessage("Congratulations! You have won a ClanHall!");
      }
      ClanTable.getInstance().getClanByName(b.getClanName()).setAuctionBiddedAt(0, true);
    }
    _bidders.clear();
  }
Пример #2
0
  /** Update auction in DB */
  private void updateInDB(L2Player bidder, int bid) {
    Connection con = null;
    try {
      con = L2DatabaseFactory.getInstance().getConnection(con);
      PreparedStatement statement;

      if (getBidders().get(bidder.getClanId()) != null) {
        statement =
            con.prepareStatement(
                "UPDATE auction_bid SET bidderId=?, bidderName=?, maxBid=?, time_bid=? WHERE auctionId=? AND bidderId=?");
        statement.setInt(1, bidder.getClanId());
        statement.setString(2, bidder.getClan().getLeaderName());
        statement.setInt(3, bid);
        statement.setLong(4, System.currentTimeMillis());
        statement.setInt(5, getId());
        statement.setInt(6, bidder.getClanId());
        statement.execute();
        statement.close();
      } else {
        statement =
            con.prepareStatement(
                "INSERT INTO auction_bid (id, auctionId, bidderId, bidderName, maxBid, clan_name, time_bid) VALUES (?, ?, ?, ?, ?, ?, ?)");
        statement.setInt(1, IdFactory.getInstance().getNextId());
        statement.setInt(2, getId());
        statement.setInt(3, bidder.getClanId());
        statement.setString(4, bidder.getName());
        statement.setInt(5, bid);
        statement.setString(6, bidder.getClan().getName());
        statement.setLong(7, System.currentTimeMillis());
        statement.execute();
        statement.close();
        L2Player highest = L2World.getInstance().getPlayer(_highestBidderName);
        if (highest != null) highest.sendMessage("You have been out bidded");
      }
      _highestBidderId = bidder.getClanId();
      _highestBidderMaxBid = bid;
      _highestBidderName = bidder.getClan().getLeaderName();
      if (_bidders.get(_highestBidderId) == null) {
        _bidders.put(
            _highestBidderId,
            new Bidder(
                _highestBidderName, bidder.getClan().getName(), bid, System.currentTimeMillis()));
      } else {
        _bidders.get(_highestBidderId).setBid(bid);
        _bidders.get(_highestBidderId).setTimeBid(System.currentTimeMillis());
      }
      bidder.sendPacket(SystemMessageId.BID_IN_CLANHALL_AUCTION);
    } catch (Exception e) {
      _log.fatal("Exception: Auction.updateInDB(L2Player bidder, int bid): ", e);
    } finally {
      L2DatabaseFactory.close(con);
    }
  }