fix cancel bug giving item despite not taking it

Took 5 minutes
This commit is contained in:
Kiran Hart 2023-02-17 13:56:14 -05:00
parent f97007e428
commit 4bcefadb1a
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
3 changed files with 14 additions and 2 deletions

View File

@ -348,7 +348,7 @@ public final class CommandSell extends AbstractCommand {
AuctionHouse.getInstance().getAuctionPlayerManager().processSell(player);
player.closeInventory();
PlayerUtils.giveItem(player, auctionedItem.getItem());
// PlayerUtils.giveItem(player, auctionedItem.getItem());
auctionPlayer.setItemBeingListed(null);
return;
}

View File

@ -26,6 +26,9 @@ import ca.tweetzy.core.utils.TextUtils;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
public final class GUIListingConfirm extends AbstractPlaceholderGui {
@ -33,6 +36,8 @@ public final class GUIListingConfirm extends AbstractPlaceholderGui {
private final AuctionedItem auctionedItem;
private final Consumer<Boolean> result;
private final Set<UUID> resulted = new HashSet<>();
public GUIListingConfirm(Player player, AuctionedItem auctionedItem, Consumer<Boolean> result) {
super(player);
this.auctionedItem = auctionedItem;
@ -44,16 +49,23 @@ public final class GUIListingConfirm extends AbstractPlaceholderGui {
draw();
}
private void draw() {
setItems(0, 3, getConfirmListingYesItem());
setItem(0, 4, this.auctionedItem.getDisplayStack(AuctionStackType.LISTING_PREVIEW));
setItems(5, 8, getConfirmListingNoItem());
setActionForRange(5, 8, ClickType.LEFT, e -> {
if (resulted.contains(e.player.getUniqueId())) return;
resulted.add(e.player.getUniqueId());
setAllowClose(true);
this.result.accept(false);
});
setActionForRange(0, 3, ClickType.LEFT, e -> {
if (resulted.contains(e.player.getUniqueId())) return;
resulted.add(e.player.getUniqueId());
setAllowClose(true);
this.result.accept(true);
});

View File

@ -37,6 +37,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
@ -149,7 +150,6 @@ public final class AuctionCreator {
//====================================================================================
// Actually attempt the insertion now
AuctionHouse.getInstance().getDataManager().insertAuctionAsync(auctionItem, (error, inserted) -> {
auctionPlayer.setItemBeingListed(null);