🪲 Fix regarding infinite items losing their original stack size. Possibly resolves #24, needs confirmation

Took 4 minutes
This commit is contained in:
Kiran Hart 2023-02-26 18:30:54 -05:00
parent 6895ed8a89
commit dc0dd49560
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3

View File

@ -157,14 +157,12 @@ public class GUIConfirmPurchase extends AbstractPlaceholderGui {
ItemStack item = auctionItem.getItem().clone();
ItemStack toGive = auctionItem.getItem().clone();
if (item.getAmount() - this.purchaseQuantity >= 1) {
if (item.getAmount() - this.purchaseQuantity >= 1 && !located.isInfinite()) {
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);
}
located.setItem(item);
located.setBasePrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(located.getBasePrice() - buyNowPrice) : located.getBasePrice() - buyNowPrice);
transferFunds(e.player, buyNowPrice);
} else {
@ -209,12 +207,13 @@ public class GUIConfirmPurchase extends AbstractPlaceholderGui {
.sendPrefixedMessage(player));
}
AuctionHouse.getInstance().getTransactionManager().getPrePurchasePlayers(auctionItem.getId()).forEach(player -> {
AuctionHouse.getInstance().getTransactionManager().removeAllRelatedPlayers(auctionItem.getId());
player.closeInventory();
});
e.gui.close();
} catch (ItemNotFoundException exception) {
AuctionHouse.getInstance().getLogger().info("Tried to purchase item that was bought, or does not exist");
}