Exemple #1
0
 /** End of auction */
 public void endAuction() {
   if (ClanHallManager.loaded()) {
     if (_highestBidderId == 0 && _sellerId == 0) {
       startAutoTask();
       return;
     }
     if (_highestBidderId == 0 && _sellerId > 0) {
       /** If seller haven't sell ClanHall, auction removed, THIS MUST BE CONFIRMED */
       int aucId = AuctionService.getInstance().getAuctionIndex(_id);
       AuctionService.getInstance().getAuctions().remove(aucId);
       return;
     }
     if (_sellerId > 0) {
       returnItem(_sellerClanName, PcInventory.ADENA_ID, _highestBidderMaxBid, true);
       returnItem(
           _sellerClanName,
           PcInventory.ADENA_ID,
           ClanHallManager.getInstance().getClanHallById(_itemId).getLease(),
           false);
     }
     deleteAuctionFromDB();
     L2Clan Clan =
         ClanTable.getInstance().getClanByName(_bidders.get(_highestBidderId).getClanName());
     _bidders.remove(_highestBidderId);
     Clan.setAuctionBiddedAt(0, true);
     removeBids();
     ClanHallManager.getInstance().setOwner(_itemId, Clan);
   } else {
     /** Task waiting ClanHallManager is loaded every 3s */
     ThreadPoolManager.getInstance().scheduleGeneral(new AutoEndTask(), 3000);
   }
 }
Exemple #2
0
  /** Confirm an auction */
  public void confirmAuction() {
    AuctionService.getInstance().getAuctions().add(this);
    Connection con = null;
    try {
      PreparedStatement statement;
      con = L2DatabaseFactory.getInstance().getConnection(con);

      statement =
          con.prepareStatement(
              "INSERT INTO auction (id, sellerId, sellerName, sellerClanName, itemType, itemId, itemObjectId, itemName, itemQuantity, startingBid, currentBid, endDate) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");
      statement.setInt(1, getId());
      statement.setInt(2, _sellerId);
      statement.setString(3, _sellerName);
      statement.setString(4, _sellerClanName);
      statement.setString(5, _itemType);
      statement.setInt(6, _itemId);
      statement.setInt(7, _itemObjectId);
      statement.setString(8, _itemName);
      statement.setInt(9, _itemQuantity);
      statement.setInt(10, _startingBid);
      statement.setInt(11, _currentBid);
      statement.setLong(12, _endDate);
      statement.execute();
      statement.close();
      loadBid();
    } catch (Exception e) {
      _log.fatal("Exception: Auction.load(): " + e.getMessage(), e);
    } finally {
      L2DatabaseFactory.close(con);
    }
  }
Exemple #3
0
 /** Remove auctions */
 public void deleteAuctionFromDB() {
   AuctionService.getInstance().getAuctions().remove(this);
   Connection con = null;
   try {
     con = L2DatabaseFactory.getInstance().getConnection(con);
     PreparedStatement statement;
     statement = con.prepareStatement("DELETE FROM auction WHERE itemId=?");
     statement.setInt(1, _itemId);
     statement.execute();
     statement.close();
   } catch (Exception e) {
     _log.fatal("Exception: Auction.deleteFromDB(): " + e.getMessage(), e);
   } finally {
     L2DatabaseFactory.close(con);
   }
 }