ItemAuctionInstance.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.model.itemauction;
  16. import gnu.trove.map.hash.TIntObjectHashMap;
  17. import java.sql.Connection;
  18. import java.sql.PreparedStatement;
  19. import java.sql.ResultSet;
  20. import java.sql.SQLException;
  21. import java.text.SimpleDateFormat;
  22. import java.util.ArrayList;
  23. import java.util.Arrays;
  24. import java.util.Comparator;
  25. import java.util.Date;
  26. import java.util.concurrent.ScheduledFuture;
  27. import java.util.concurrent.TimeUnit;
  28. import java.util.concurrent.atomic.AtomicInteger;
  29. import java.util.logging.Level;
  30. import java.util.logging.Logger;
  31. import org.w3c.dom.NamedNodeMap;
  32. import org.w3c.dom.Node;
  33. import com.l2jserver.Config;
  34. import com.l2jserver.L2DatabaseFactory;
  35. import com.l2jserver.gameserver.ThreadPoolManager;
  36. import com.l2jserver.gameserver.datatables.CharNameTable;
  37. import com.l2jserver.gameserver.instancemanager.ItemAuctionManager;
  38. import com.l2jserver.gameserver.model.L2ItemInstance;
  39. import com.l2jserver.gameserver.model.L2ItemInstance.ItemLocation;
  40. import com.l2jserver.gameserver.model.L2World;
  41. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  42. import com.l2jserver.gameserver.network.SystemMessageId;
  43. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  44. import com.l2jserver.gameserver.templates.StatsSet;
  45. import com.l2jserver.util.Rnd;
  46. public final class ItemAuctionInstance
  47. {
  48. static final Logger _log = Logger.getLogger(ItemAuctionInstance.class.getName());
  49. private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("HH:mm:ss dd.MM.yy");
  50. private static final long START_TIME_SPACE = TimeUnit.MILLISECONDS.convert(1, TimeUnit.MINUTES);
  51. private static final long FINISH_TIME_SPACE = TimeUnit.MILLISECONDS.convert(10, TimeUnit.MINUTES);
  52. private final int _instanceId;
  53. private final AtomicInteger _auctionIds;
  54. private final TIntObjectHashMap<ItemAuction> _auctions;
  55. private final ArrayList<AuctionItem> _items;
  56. private final AuctionDateGenerator _dateGenerator;
  57. private ItemAuction _currentAuction;
  58. private ItemAuction _nextAuction;
  59. private ScheduledFuture<?> _stateTask;
  60. public ItemAuctionInstance(final int instanceId, final AtomicInteger auctionIds, final Node node) throws Exception
  61. {
  62. _instanceId = instanceId;
  63. _auctionIds = auctionIds;
  64. _auctions = new TIntObjectHashMap<ItemAuction>();
  65. _items = new ArrayList<AuctionItem>();
  66. final NamedNodeMap nanode = node.getAttributes();
  67. final StatsSet generatorConfig = new StatsSet();
  68. for (int i = nanode.getLength(); i-- > 0;)
  69. {
  70. final Node n = nanode.item(i);
  71. if (n != null)
  72. generatorConfig.set(n.getNodeName(), n.getNodeValue());
  73. }
  74. _dateGenerator = new AuctionDateGenerator(generatorConfig);
  75. for (Node na = node.getFirstChild(); na != null; na = na.getNextSibling())
  76. {
  77. try
  78. {
  79. if ("item".equalsIgnoreCase(na.getNodeName()))
  80. {
  81. final NamedNodeMap naa = na.getAttributes();
  82. final int auctionItemId = Integer.parseInt(naa.getNamedItem("auctionItemId").getNodeValue());
  83. final int auctionLenght = Integer.parseInt(naa.getNamedItem("auctionLenght").getNodeValue());
  84. final long auctionInitBid = Integer.parseInt(naa.getNamedItem("auctionInitBid").getNodeValue());
  85. final int itemId = Integer.parseInt(naa.getNamedItem("itemId").getNodeValue());
  86. final int itemCount = Integer.parseInt(naa.getNamedItem("itemCount").getNodeValue());
  87. if (auctionLenght < 1)
  88. throw new IllegalArgumentException("auctionLenght < 1 for instanceId: " + _instanceId + ", itemId " + itemId);
  89. final StatsSet itemExtra = new StatsSet();
  90. final AuctionItem item = new AuctionItem(auctionItemId, auctionLenght, auctionInitBid, itemId, itemCount, itemExtra);
  91. if (!item.checkItemExists())
  92. throw new IllegalArgumentException("Item with id " + itemId + " not found");
  93. for (final AuctionItem tmp : _items)
  94. {
  95. if (tmp.getAuctionItemId() == auctionItemId)
  96. throw new IllegalArgumentException("Dublicated auction item id " + auctionItemId);
  97. }
  98. _items.add(item);
  99. for (Node nb = na.getFirstChild(); nb != null; nb = nb.getNextSibling())
  100. {
  101. if ("extra".equalsIgnoreCase(nb.getNodeName()))
  102. {
  103. final NamedNodeMap nab = nb.getAttributes();
  104. for (int i = nab.getLength(); i-- > 0;)
  105. {
  106. final Node n = nab.item(i);
  107. if (n != null)
  108. itemExtra.set(n.getNodeName(), n.getNodeValue());
  109. }
  110. }
  111. }
  112. }
  113. }
  114. catch (final IllegalArgumentException e)
  115. {
  116. _log.log(Level.WARNING, "ItemAuctionInstance: Failed loading auction item", e);
  117. }
  118. }
  119. if (_items.isEmpty())
  120. throw new IllegalArgumentException("No items defined");
  121. Connection con = null;
  122. try
  123. {
  124. con = L2DatabaseFactory.getInstance().getConnection();
  125. PreparedStatement statement = con.prepareStatement("SELECT auctionId FROM item_auction WHERE instanceId=?");
  126. statement.setInt(1, _instanceId);
  127. ResultSet rset = statement.executeQuery();
  128. while (rset.next())
  129. {
  130. final int auctionId = rset.getInt(1);
  131. try
  132. {
  133. final ItemAuction auction = loadAuction(auctionId);
  134. if (auction != null)
  135. {
  136. _auctions.put(auctionId, auction);
  137. }
  138. else
  139. {
  140. ItemAuctionManager.deleteAuction(auctionId);
  141. }
  142. }
  143. catch (final SQLException e)
  144. {
  145. _log.log(Level.WARNING, "ItemAuctionInstance: Failed loading auction: " + auctionId, e);
  146. }
  147. }
  148. }
  149. catch (final SQLException e)
  150. {
  151. _log.log(Level.SEVERE, "L2ItemAuctionInstance: Failed loading auctions.", e);
  152. return;
  153. }
  154. finally
  155. {
  156. L2DatabaseFactory.close(con);
  157. }
  158. _log.log(Level.INFO, "L2ItemAuctionInstance: Loaded " + _items.size() + " item(s) and registered " + _auctions.size() + " auction(s) for instance " + _instanceId + ".");
  159. checkAndSetCurrentAndNextAuction();
  160. }
  161. public final ItemAuction getCurrentAuction()
  162. {
  163. return _currentAuction;
  164. }
  165. public final ItemAuction getNextAuction()
  166. {
  167. return _nextAuction;
  168. }
  169. public final void shutdown()
  170. {
  171. final ScheduledFuture<?> stateTask = _stateTask;
  172. if (stateTask != null)
  173. stateTask.cancel(false);
  174. }
  175. private final AuctionItem getAuctionItem(final int auctionItemId)
  176. {
  177. for (int i = _items.size(); i-- > 0;)
  178. {
  179. final AuctionItem item = _items.get(i);
  180. if (item.getAuctionItemId() == auctionItemId)
  181. return item;
  182. }
  183. return null;
  184. }
  185. final void checkAndSetCurrentAndNextAuction()
  186. {
  187. final ItemAuction[] auctions = _auctions.values(new ItemAuction[_auctions.size()]);
  188. ItemAuction currentAuction = null;
  189. ItemAuction nextAuction = null;
  190. switch (auctions.length)
  191. {
  192. case 0:
  193. {
  194. nextAuction = createAuction(System.currentTimeMillis() + START_TIME_SPACE);
  195. break;
  196. }
  197. case 1:
  198. {
  199. switch (auctions[0].getAuctionState())
  200. {
  201. case CREATED:
  202. {
  203. if (auctions[0].getStartingTime() < (System.currentTimeMillis() + START_TIME_SPACE))
  204. {
  205. currentAuction = auctions[0];
  206. nextAuction = createAuction(System.currentTimeMillis() + START_TIME_SPACE);
  207. }
  208. else
  209. {
  210. nextAuction = auctions[0];
  211. }
  212. break;
  213. }
  214. case STARTED:
  215. {
  216. currentAuction = auctions[0];
  217. nextAuction = createAuction(Math.max(currentAuction.getEndingTime() + FINISH_TIME_SPACE, System.currentTimeMillis() + START_TIME_SPACE));
  218. break;
  219. }
  220. case FINISHED:
  221. {
  222. currentAuction = auctions[0];
  223. nextAuction = createAuction(System.currentTimeMillis() + START_TIME_SPACE);
  224. break;
  225. }
  226. default:
  227. throw new IllegalArgumentException();
  228. }
  229. break;
  230. }
  231. default:
  232. {
  233. Arrays.sort(auctions, new Comparator<ItemAuction>() {
  234. @Override
  235. public final int compare(final ItemAuction o1, final ItemAuction o2)
  236. {
  237. return ((Long) o2.getStartingTime()).compareTo(o1.getStartingTime());
  238. }
  239. });
  240. // just to make sure we won`t skip any auction because of little different times
  241. final long currentTime = System.currentTimeMillis();
  242. for (int i = 0; i < auctions.length; i++)
  243. {
  244. final ItemAuction auction = auctions[i];
  245. if (auction.getAuctionState() == ItemAuctionState.STARTED)
  246. {
  247. currentAuction = auction;
  248. break;
  249. }
  250. else if (auction.getStartingTime() <= currentTime)
  251. {
  252. currentAuction = auction;
  253. break; // only first
  254. }
  255. }
  256. for (int i = 0; i < auctions.length; i++)
  257. {
  258. final ItemAuction auction = auctions[i];
  259. if (auction.getStartingTime() > currentTime && currentAuction != auction)
  260. {
  261. nextAuction = auction;
  262. break;
  263. }
  264. }
  265. if (nextAuction == null)
  266. nextAuction = createAuction(System.currentTimeMillis() + START_TIME_SPACE);
  267. break;
  268. }
  269. }
  270. _auctions.put(nextAuction.getAuctionId(), nextAuction);
  271. _currentAuction = currentAuction;
  272. _nextAuction = nextAuction;
  273. if (currentAuction != null && currentAuction.getAuctionState() != ItemAuctionState.FINISHED)
  274. {
  275. if (currentAuction.getAuctionState() == ItemAuctionState.STARTED)
  276. setStateTask(ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleAuctionTask(currentAuction), Math.max(currentAuction.getEndingTime() - System.currentTimeMillis(), 0L)));
  277. else
  278. setStateTask(ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleAuctionTask(currentAuction), Math.max(currentAuction.getStartingTime() - System.currentTimeMillis(), 0L)));
  279. _log.log(Level.INFO, "L2ItemAuctionInstance: Schedule current auction " + currentAuction.getAuctionId() + " for instance " + _instanceId);
  280. }
  281. else
  282. {
  283. setStateTask(ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleAuctionTask(nextAuction), Math.max(nextAuction.getStartingTime() - System.currentTimeMillis(), 0L)));
  284. _log.log(Level.INFO, "L2ItemAuctionInstance: Schedule next auction " + nextAuction.getAuctionId() + " on " + DATE_FORMAT.format(new Date(nextAuction.getStartingTime())) + " for instance " + _instanceId);
  285. }
  286. }
  287. public final ItemAuction getAuction(final int auctionId)
  288. {
  289. return _auctions.get(auctionId);
  290. }
  291. public final ItemAuction[] getAuctionsByBidder(final int bidderObjId)
  292. {
  293. final ItemAuction[] auctions = getAuctions();
  294. final ArrayList<ItemAuction> stack = new ArrayList<ItemAuction>(auctions.length);
  295. for (final ItemAuction auction : getAuctions())
  296. {
  297. if (auction.getAuctionState() != ItemAuctionState.CREATED)
  298. {
  299. final ItemAuctionBid bid = auction.getBidFor(bidderObjId);
  300. if (bid != null)
  301. stack.add(auction);
  302. }
  303. }
  304. return stack.toArray(new ItemAuction[stack.size()]);
  305. }
  306. public final ItemAuction[] getAuctions()
  307. {
  308. final ItemAuction[] auctions;
  309. synchronized (_auctions)
  310. {
  311. auctions = _auctions.values(new ItemAuction[_auctions.size()]);
  312. }
  313. return auctions;
  314. }
  315. private final class ScheduleAuctionTask implements Runnable
  316. {
  317. private final ItemAuction _auction;
  318. public ScheduleAuctionTask(final ItemAuction auction)
  319. {
  320. _auction = auction;
  321. }
  322. @Override
  323. public final void run()
  324. {
  325. try
  326. {
  327. runImpl();
  328. }
  329. catch (final Exception e)
  330. {
  331. _log.log(Level.SEVERE, "L2ItemAuctionInstance: Failed scheduling auction " + _auction.getAuctionId(), e);
  332. }
  333. }
  334. private final void runImpl() throws Exception
  335. {
  336. final ItemAuctionState state = _auction.getAuctionState();
  337. switch (state)
  338. {
  339. case CREATED:
  340. {
  341. if (!_auction.setAuctionState(state, ItemAuctionState.STARTED))
  342. throw new IllegalStateException("Could not set auction state: " + ItemAuctionState.STARTED.toString() + ", expected: " + state.toString());
  343. _log.log(Level.INFO, "L2ItemAuctionInstance: Auction " + _auction.getAuctionId() + " has started for instance " + _auction.getInstanceId());
  344. checkAndSetCurrentAndNextAuction();
  345. break;
  346. }
  347. case STARTED:
  348. {
  349. switch (_auction.getAuctionEndingExtendState())
  350. {
  351. case EXTEND_BY_5_MIN:
  352. {
  353. if (_auction.getScheduledAuctionEndingExtendState() == ItemAuctionExtendState.INITIAL)
  354. {
  355. _auction.setScheduledAuctionEndingExtendState(ItemAuctionExtendState.EXTEND_BY_5_MIN);
  356. setStateTask(ThreadPoolManager.getInstance().scheduleGeneral(this, Math.max(_auction.getEndingTime() - System.currentTimeMillis(), 0L)));
  357. return;
  358. }
  359. break;
  360. }
  361. case EXTEND_BY_3_MIN:
  362. {
  363. if (_auction.getScheduledAuctionEndingExtendState() != ItemAuctionExtendState.EXTEND_BY_3_MIN)
  364. {
  365. _auction.setScheduledAuctionEndingExtendState(ItemAuctionExtendState.EXTEND_BY_3_MIN);
  366. setStateTask(ThreadPoolManager.getInstance().scheduleGeneral(this, Math.max(_auction.getEndingTime() - System.currentTimeMillis(), 0L)));
  367. return;
  368. }
  369. break;
  370. }
  371. case EXTEND_BY_CONFIG_PHASE_A:
  372. {
  373. if (_auction.getScheduledAuctionEndingExtendState() != ItemAuctionExtendState.EXTEND_BY_CONFIG_PHASE_B)
  374. {
  375. _auction.setScheduledAuctionEndingExtendState(ItemAuctionExtendState.EXTEND_BY_CONFIG_PHASE_B);
  376. setStateTask(ThreadPoolManager.getInstance().scheduleGeneral(this, Math.max(_auction.getEndingTime() - System.currentTimeMillis(), 0L)));
  377. return;
  378. }
  379. break;
  380. }
  381. case EXTEND_BY_CONFIG_PHASE_B:
  382. {
  383. if (_auction.getScheduledAuctionEndingExtendState() != ItemAuctionExtendState.EXTEND_BY_CONFIG_PHASE_A)
  384. {
  385. _auction.setScheduledAuctionEndingExtendState(ItemAuctionExtendState.EXTEND_BY_CONFIG_PHASE_A);
  386. setStateTask(ThreadPoolManager.getInstance().scheduleGeneral(this, Math.max(_auction.getEndingTime() - System.currentTimeMillis(), 0L)));
  387. return;
  388. }
  389. }
  390. }
  391. if (!_auction.setAuctionState(state, ItemAuctionState.FINISHED))
  392. throw new IllegalStateException("Could not set auction state: " + ItemAuctionState.FINISHED.toString() + ", expected: " + state.toString());
  393. onAuctionFinished(_auction);
  394. checkAndSetCurrentAndNextAuction();
  395. break;
  396. }
  397. default:
  398. throw new IllegalStateException("Invalid state: " + state);
  399. }
  400. }
  401. }
  402. final void onAuctionFinished(final ItemAuction auction)
  403. {
  404. auction.broadcastToAllBiddersInternal(SystemMessage.getSystemMessage(SystemMessageId.S1_AUCTION_ENDED).addNumber(auction.getAuctionId()));
  405. final ItemAuctionBid bid = auction.getHighestBid();
  406. if (bid != null)
  407. {
  408. final L2ItemInstance item = auction.createNewItemInstance();
  409. final L2PcInstance player = bid.getPlayer();
  410. if (player != null)
  411. {
  412. player.getWarehouse().addItem("ItemAuction", item, null, null);
  413. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.WON_BID_ITEM_CAN_BE_FOUND_IN_WAREHOUSE));
  414. _log.log(Level.INFO, "L2ItemAuctionInstance: Auction " + auction.getAuctionId() + " has finished. Highest bid by " + player.getName() + " for instance " + _instanceId);
  415. }
  416. else
  417. {
  418. item.setOwnerId(bid.getPlayerObjId());
  419. item.setLocation(ItemLocation.WAREHOUSE);
  420. item.updateDatabase();
  421. L2World.getInstance().removeObject(item);
  422. _log.log(Level.INFO, "L2ItemAuctionInstance: Auction " + auction.getAuctionId() + " has finished. Highest bid by " + CharNameTable.getInstance().getNameById(bid.getPlayerObjId()) + " for instance " + _instanceId);
  423. }
  424. // Clean all canceled bids
  425. auction.clearCanceledBids();
  426. }
  427. else
  428. {
  429. _log.log(Level.INFO, "L2ItemAuctionInstance: Auction " + auction.getAuctionId() + " has finished. There have not been any bid for instance " + _instanceId);
  430. }
  431. }
  432. final void setStateTask(final ScheduledFuture<?> future)
  433. {
  434. final ScheduledFuture<?> stateTask = _stateTask;
  435. if (stateTask != null)
  436. stateTask.cancel(false);
  437. _stateTask = future;
  438. }
  439. private final ItemAuction createAuction(final long after)
  440. {
  441. final AuctionItem auctionItem = _items.get(Rnd.get(_items.size()));
  442. final long startingTime = _dateGenerator.nextDate(after);
  443. final long endingTime = startingTime + TimeUnit.MILLISECONDS.convert(auctionItem.getAuctionLength(), TimeUnit.MINUTES);
  444. final ItemAuction auction = new ItemAuction(_auctionIds.getAndIncrement(), _instanceId, startingTime, endingTime, auctionItem);
  445. auction.storeMe();
  446. return auction;
  447. }
  448. private final ItemAuction loadAuction(final int auctionId) throws SQLException
  449. {
  450. Connection con = null;
  451. try
  452. {
  453. con = L2DatabaseFactory.getInstance().getConnection();
  454. PreparedStatement statement = con.prepareStatement("SELECT auctionItemId,startingTime,endingTime,auctionStateId FROM item_auction WHERE auctionId=?");
  455. statement.setInt(1, auctionId);
  456. ResultSet rset = statement.executeQuery();
  457. if (!rset.next())
  458. {
  459. _log.log(Level.WARNING, "ItemAuctionInstance: Auction data not found for auction: " + auctionId);
  460. return null;
  461. }
  462. final int auctionItemId = rset.getInt(1);
  463. final long startingTime = rset.getLong(2);
  464. final long endingTime = rset.getLong(3);
  465. final byte auctionStateId = rset.getByte(4);
  466. statement.close();
  467. if (startingTime >= endingTime)
  468. {
  469. _log.log(Level.WARNING, "ItemAuctionInstance: Invalid starting/ending paramaters for auction: " + auctionId);
  470. return null;
  471. }
  472. final AuctionItem auctionItem = getAuctionItem(auctionItemId);
  473. if (auctionItem == null)
  474. {
  475. _log.log(Level.WARNING, "ItemAuctionInstance: AuctionItem: " + auctionItemId + ", not found for auction: " + auctionId);
  476. return null;
  477. }
  478. final ItemAuctionState auctionState = ItemAuctionState.stateForStateId(auctionStateId);
  479. if (auctionState == null)
  480. {
  481. _log.log(Level.WARNING, "ItemAuctionInstance: Invalid auctionStateId: " + auctionStateId + ", for auction: " + auctionId);
  482. return null;
  483. }
  484. if (auctionState == ItemAuctionState.FINISHED
  485. && startingTime < System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(Config.ALT_ITEM_AUCTION_EXPIRED_AFTER, TimeUnit.DAYS))
  486. {
  487. _log.log(Level.INFO, "ItemAuctionInstance: Clearing expired auction: " + auctionId);
  488. statement = con.prepareStatement("DELETE FROM item_auction WHERE auctionId=?");
  489. statement.setInt(1, auctionId);
  490. statement.execute();
  491. statement.close();
  492. statement = con.prepareStatement("DELETE FROM item_auction_bid WHERE auctionId=?");
  493. statement.setInt(1, auctionId);
  494. statement.execute();
  495. statement.close();
  496. return null;
  497. }
  498. statement = con.prepareStatement("SELECT playerObjId,playerBid FROM item_auction_bid WHERE auctionId=?");
  499. statement.setInt(1, auctionId);
  500. rset = statement.executeQuery();
  501. final ArrayList<ItemAuctionBid> auctionBids = new ArrayList<ItemAuctionBid>();
  502. while (rset.next())
  503. {
  504. final int playerObjId = rset.getInt(1);
  505. final long playerBid = rset.getLong(2);
  506. final ItemAuctionBid bid = new ItemAuctionBid(playerObjId, playerBid);
  507. auctionBids.add(bid);
  508. }
  509. return new ItemAuction(auctionId, _instanceId, startingTime, endingTime, auctionItem, auctionBids, auctionState);
  510. }
  511. finally
  512. {
  513. L2DatabaseFactory.close(con);
  514. }
  515. }
  516. }