From 75121ef29002e5681bc540d224f908a9cc8d4bd1 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Wed, 10 May 2023 20:12:56 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=AB=20add=20clear=20bids=20admin=20com?= =?UTF-8?q?mand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 8 minutes --- .../auctionhouse/commands/CommandAdmin.java | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandAdmin.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandAdmin.java index 5fcc9b8..9858c3f 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandAdmin.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandAdmin.java @@ -136,10 +136,22 @@ public class CommandAdmin extends AbstractCommand { if (player == null) return ReturnType.FAILURE; final boolean returnItems = Boolean.parseBoolean(args[2]); - final boolean returnMoney = Boolean.parseBoolean(args[3]); + boolean returnMoney = Boolean.parseBoolean(args[3]); handleUserClear(player, returnMoney, returnItems); + break; + case "clearbids": + if (args.length < 3) return ReturnType.FAILURE; + if (!sender.hasPermission("auctionhouse.cmd.admin.clearbids")) return ReturnType.FAILURE; + + player = PlayerUtils.findPlayer(args[1]); + if (player == null) return ReturnType.FAILURE; + + returnMoney = Boolean.parseBoolean(args[2]); + + handleUserBidClear(player, returnMoney); + break; case "opensell": if (args.length < 2) return ReturnType.FAILURE; @@ -223,6 +235,27 @@ public class CommandAdmin extends AbstractCommand { return "Admin options for auction house."; } + private void handleUserBidClear(final Player player, final boolean returnMoney) { + final List items = AuctionHouse.getInstance().getAuctionItemManager().getHighestBidItems(player); + + for (AuctionedItem auctionedItem : items) { + auctionedItem.setHighestBidder(auctionedItem.getOwner()); + auctionedItem.setHighestBidderName(auctionedItem.getOwnerName()); + + if (returnMoney && Settings.BIDDING_TAKES_MONEY.getBoolean()) + if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean()) + AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment( + player.getUniqueId(), + auctionedItem.getCurrentPrice(), + auctionedItem.getItem(), + player.getName(), + PaymentReason.BID_RETURNED + ), null); + else + EconomyManager.deposit(player, auctionedItem.getCurrentPrice()); + } + } + private void handleUserClear(final Player player, final boolean returnBids, final boolean giveItemsBack) { final AuctionPlayer auctionPlayer = AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(player.getUniqueId()); final List items = auctionPlayer.getAllItems();