mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-22 05:25:11 +01:00
patch for duplication bug related to purchasing specific quantities of items
Took 4 minutes
This commit is contained in:
parent
baf5fdd84b
commit
e68029d444
@ -414,7 +414,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
connection.setAutoCommit(false);
|
||||
SQLException err = null;
|
||||
|
||||
PreparedStatement statement = connection.prepareStatement("UPDATE " + this.getTablePrefix() + "auctions SET owner = ?, owner_name = ?, highest_bidder = ?, highest_bidder_name = ?, base_price = ?, bid_start_price = ?, bid_increment_price = ?, current_price = ?, expires_at = ?, expired = ? WHERE id = ?");
|
||||
PreparedStatement statement = connection.prepareStatement("UPDATE " + this.getTablePrefix() + "auctions SET owner = ?, owner_name = ?, highest_bidder = ?, highest_bidder_name = ?, base_price = ?, bid_start_price = ?, bid_increment_price = ?, current_price = ?, expires_at = ?, expired = ?, item = ? WHERE id = ?");
|
||||
for (AuctionedItem item : items) {
|
||||
try {
|
||||
statement.setString(1, item.getOwner().toString());
|
||||
@ -427,7 +427,8 @@ public class DataManager extends DataManagerAbstract {
|
||||
statement.setDouble(8, item.getCurrentPrice());
|
||||
statement.setLong(9, item.getExpiresAt());
|
||||
statement.setBoolean(10, item.isExpired());
|
||||
statement.setString(11, item.getId().toString());
|
||||
statement.setString(11, AuctionAPI.encodeItem(item.getItem()));
|
||||
statement.setString(12, item.getId().toString());
|
||||
statement.addBatch();
|
||||
} catch (SQLException e) {
|
||||
err = e;
|
||||
|
@ -99,6 +99,7 @@ public class GUIConfirmPurchase extends Gui {
|
||||
setActionForRange(this.buyingSpecificQuantity ? 14 : 5, this.buyingSpecificQuantity ? 17 : 8, ClickType.LEFT, e -> {
|
||||
e.gui.close();
|
||||
});
|
||||
|
||||
setActionForRange(this.buyingSpecificQuantity ? 9 : 0, this.buyingSpecificQuantity ? 12 : 3, ClickType.LEFT, e -> {
|
||||
// Re-select the item to ensure that it's available
|
||||
try {
|
||||
@ -134,17 +135,19 @@ public class GUIConfirmPurchase extends Gui {
|
||||
}
|
||||
|
||||
if (this.buyingSpecificQuantity) {
|
||||
ItemStack item = auctionItem.getItem();
|
||||
// the original item stack
|
||||
ItemStack item = auctionItem.getItem().clone();
|
||||
ItemStack toGive = auctionItem.getItem().clone();
|
||||
|
||||
if (item.getAmount() - this.purchaseQuantity >= 1) {
|
||||
item.setAmount(item.getAmount() - this.purchaseQuantity);
|
||||
toGive.setAmount(this.purchaseQuantity);
|
||||
|
||||
if (!located.isInfinite()) {
|
||||
located.setItem(item);
|
||||
located.setBasePrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(located.getBasePrice() - buyNowPrice) : located.getBasePrice() - buyNowPrice);
|
||||
}
|
||||
|
||||
item.setAmount(this.purchaseQuantity);
|
||||
transferFunds(e.player, buyNowPrice);
|
||||
} else {
|
||||
transferFunds(e.player, buyNowPrice);
|
||||
@ -152,7 +155,7 @@ public class GUIConfirmPurchase extends Gui {
|
||||
AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(located);
|
||||
}
|
||||
|
||||
PlayerUtils.giveItem(e.player, item);
|
||||
PlayerUtils.giveItem(e.player, toGive);
|
||||
sendMessages(e, located, true, buyNowPrice);
|
||||
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user