Add slight delay to auction creation

Took 7 minutes
This commit is contained in:
Kiran Hart 2023-02-14 13:30:07 -05:00
parent 0d441601ac
commit e3a41dd64c
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
4 changed files with 60 additions and 14 deletions

View File

@ -338,9 +338,9 @@ public final class CommandSell extends AbstractCommand {
auctionedItem.setInfinite(isInfinite); auctionedItem.setInfinite(isInfinite);
auctionedItem.setAllowPartialBuy(partialBuy); auctionedItem.setAllowPartialBuy(partialBuy);
player.getInventory().setItemInHand(CompMaterial.AIR.parseItem());
if (Settings.ASK_FOR_LISTING_CONFIRMATION.getBoolean()) { if (Settings.ASK_FOR_LISTING_CONFIRMATION.getBoolean()) {
player.getInventory().setItemInHand(CompMaterial.AIR.parseItem());
instance.getGuiManager().showGUI(player, new GUIListingConfirm(player, auctionedItem, result -> { instance.getGuiManager().showGUI(player, new GUIListingConfirm(player, auctionedItem, result -> {
if (!result) { if (!result) {
player.closeInventory(); player.closeInventory();
@ -349,9 +349,36 @@ public final class CommandSell extends AbstractCommand {
return; return;
} }
Bukkit.getScheduler().runTaskLaterAsynchronously(AuctionHouse.getInstance(), () -> {
if (auctionPlayer.getPlayer() == null || !auctionPlayer.getPlayer().isOnline()) {
return;
}
player.getInventory().setItemInHand(CompMaterial.AIR.parseItem());
AuctionCreator.create(auctionPlayer, auctionedItem, (auction, listingResult) -> {
if (listingResult != ListingResult.SUCCESS) {
PlayerUtils.giveItem(player, auction.getItem());
auctionPlayer.setItemBeingListed(null);
return;
}
if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean())
instance.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer));
});
}, Settings.INTERNAL_CREATE_DELAY.getInt());
}));
} else {
Bukkit.getScheduler().runTaskLaterAsynchronously(AuctionHouse.getInstance(), () -> {
if (auctionPlayer.getPlayer() == null || !auctionPlayer.getPlayer().isOnline()) {
return;
}
player.getInventory().setItemInHand(CompMaterial.AIR.parseItem());
AuctionCreator.create(auctionPlayer, auctionedItem, (auction, listingResult) -> { AuctionCreator.create(auctionPlayer, auctionedItem, (auction, listingResult) -> {
if (listingResult != ListingResult.SUCCESS) { if (listingResult != ListingResult.SUCCESS) {
player.closeInventory();
PlayerUtils.giveItem(player, auction.getItem()); PlayerUtils.giveItem(player, auction.getItem());
auctionPlayer.setItemBeingListed(null); auctionPlayer.setItemBeingListed(null);
return; return;
@ -360,18 +387,9 @@ public final class CommandSell extends AbstractCommand {
if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean()) if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean())
instance.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer)); instance.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer));
}); });
}));
} else {
AuctionCreator.create(auctionPlayer, auctionedItem, (auction, listingResult) -> {
if (listingResult != ListingResult.SUCCESS) {
PlayerUtils.giveItem(player, auction.getItem());
auctionPlayer.setItemBeingListed(null);
return;
}
if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean()) }, Settings.INTERNAL_CREATE_DELAY.getInt());
instance.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer));
});
} }
return ReturnType.SUCCESS; return ReturnType.SUCCESS;

View File

@ -0,0 +1,26 @@
/*
* Auction House
* Copyright 2023 Kiran Hart
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package ca.tweetzy.auctionhouse.helpers;
import lombok.experimental.UtilityClass;
@UtilityClass
public final class Validate {
}

View File

@ -101,6 +101,7 @@ public class PlayerListeners implements Listener {
player.getInventory().addItem(instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()).getItemBeingListed()); player.getInventory().addItem(instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()).getItemBeingListed());
instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()).setItemBeingListed(null); instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()).setItemBeingListed(null);
instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()).setPlayer(null);
} }

View File

@ -54,6 +54,7 @@ public class Settings {
* ===============================*/ * ===============================*/
public static final ConfigSetting DEFAULT_BIN_LISTING_TIME = new ConfigSetting(config, "auction setting.listings times.bin item", 86400, "The default listing time for bin items (buy only items) before they expire"); public static final ConfigSetting DEFAULT_BIN_LISTING_TIME = new ConfigSetting(config, "auction setting.listings times.bin item", 86400, "The default listing time for bin items (buy only items) before they expire");
public static final ConfigSetting DEFAULT_AUCTION_LISTING_TIME = new ConfigSetting(config, "auction setting.listings times.auction item", 604800, "The default listing time for auction items before they expire"); public static final ConfigSetting DEFAULT_AUCTION_LISTING_TIME = new ConfigSetting(config, "auction setting.listings times.auction item", 604800, "The default listing time for auction items before they expire");
public static final ConfigSetting INTERNAL_CREATE_DELAY = new ConfigSetting(config, "auction setting.internal create delay", 3, "How many ticks should auction house wait before actually creating the item.");
public static final ConfigSetting MAX_AUCTION_PRICE = new ConfigSetting(config, "auction setting.pricing.max auction price", 1000000000, "The max price for buy only / buy now items"); public static final ConfigSetting MAX_AUCTION_PRICE = new ConfigSetting(config, "auction setting.pricing.max auction price", 1000000000, "The max price for buy only / buy now items");
public static final ConfigSetting MAX_AUCTION_START_PRICE = new ConfigSetting(config, "auction setting.pricing.max auction start price", 1000000000, "The max price starting a bidding auction"); public static final ConfigSetting MAX_AUCTION_START_PRICE = new ConfigSetting(config, "auction setting.pricing.max auction start price", 1000000000, "The max price starting a bidding auction");
public static final ConfigSetting MAX_AUCTION_INCREMENT_PRICE = new ConfigSetting(config, "auction setting.pricing.max auction increment price", 1000000000, "The max amount for incrementing a bid."); public static final ConfigSetting MAX_AUCTION_INCREMENT_PRICE = new ConfigSetting(config, "auction setting.pricing.max auction increment price", 1000000000, "The max amount for incrementing a bid.");