fixed very bad bug where players can purchase items w.o having the correct funds

This commit is contained in:
Kiran Hart 2021-04-30 12:48:55 -04:00
parent e09718483b
commit 288cc4498e
3 changed files with 14 additions and 8 deletions

View File

@ -6,7 +6,7 @@
<groupId>ca.tweetzy</groupId> <groupId>ca.tweetzy</groupId>
<artifactId>auctionhouse</artifactId> <artifactId>auctionhouse</artifactId>
<version>2.6.0</version> <version>2.6.2</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -165,6 +165,11 @@ public class GUIAuctionHouse extends Gui {
return; return;
} }
if (!AuctionHouse.getInstance().getEconomy().has(e.player, auctionItem.getBasePrice())) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
return;
}
cleanup(); cleanup();
e.manager.showGUI(e.player, new GUIConfirmPurchase(this.auctionPlayer, auctionItem, false)); e.manager.showGUI(e.player, new GUIConfirmPurchase(this.auctionPlayer, auctionItem, false));
} else { } else {

View File

@ -75,6 +75,14 @@ public class GUIConfirmPurchase extends Gui {
AuctionItem located = AuctionHouse.getInstance().getAuctionItemManager().getItem(this.auctionItem.getKey()); AuctionItem located = AuctionHouse.getInstance().getAuctionItemManager().getItem(this.auctionItem.getKey());
preItemChecks(e, located); preItemChecks(e, located);
// Check economy
if (!AuctionHouse.getInstance().getEconomy().has(e.player, this.buyingSpecificQuantity ? this.purchaseQuantity * this.pricePerItem : located.getBasePrice())) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
SoundManager.getInstance().playSound(e.player, Settings.SOUNDS_NOT_ENOUGH_MONEY.getString(), 1.0F, 1.0F);
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
return;
}
Bukkit.getServer().getScheduler().runTaskAsynchronously(AuctionHouse.getInstance(), () -> { Bukkit.getServer().getScheduler().runTaskAsynchronously(AuctionHouse.getInstance(), () -> {
AuctionEndEvent auctionEndEvent = new AuctionEndEvent(Bukkit.getOfflinePlayer(this.auctionItem.getOwner()), e.player, this.auctionItem, AuctionSaleType.WITHOUT_BIDDING_SYSTEM); AuctionEndEvent auctionEndEvent = new AuctionEndEvent(Bukkit.getOfflinePlayer(this.auctionItem.getOwner()), e.player, this.auctionItem, AuctionSaleType.WITHOUT_BIDDING_SYSTEM);
Bukkit.getServer().getPluginManager().callEvent(auctionEndEvent); Bukkit.getServer().getPluginManager().callEvent(auctionEndEvent);
@ -159,13 +167,6 @@ public class GUIConfirmPurchase extends Gui {
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
return; return;
} }
if (!AuctionHouse.getInstance().getEconomy().has(e.player, located.getBasePrice())) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
SoundManager.getInstance().playSound(e.player, Settings.SOUNDS_NOT_ENOUGH_MONEY.getString(), 1.0F, 1.0F);
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
return;
}
} }
private ItemStack getPurchaseInfoItem(int qty) { private ItemStack getPurchaseInfoItem(int qty) {