mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-02-08 18:02:10 +01:00
❌ remove nonull from auctionplayer param for AuctionCreator#create
Took 4 minutes
This commit is contained in:
parent
1970f5c3e9
commit
9076085fdc
@ -48,13 +48,19 @@ import static ca.tweetzy.auctionhouse.api.ListingResult.*;
|
||||
@UtilityClass
|
||||
public final class AuctionCreator {
|
||||
|
||||
public void create(@NonNull final AuctionPlayer auctionPlayer, @NonNull final AuctionedItem auctionItem, @NonNull final BiConsumer<AuctionedItem, ListingResult> result) {
|
||||
public void create(final AuctionPlayer auctionPlayer, @NonNull final AuctionedItem auctionItem, @NonNull final BiConsumer<AuctionedItem, ListingResult> result) {
|
||||
final AtomicReference<ListingResult> status = new AtomicReference<>(SUCCESS);
|
||||
if (!auctionItem.isServerItem() && auctionPlayer == null) {
|
||||
throw new RuntimeException("Cannot create listing if AuctionPlayer is null, did you mean to create a server listing?");
|
||||
}
|
||||
|
||||
final AuctionHouse instance = AuctionHouse.getInstance();
|
||||
final Player seller = auctionPlayer.getPlayer();
|
||||
final Player seller = auctionPlayer == null ? null : auctionPlayer.getPlayer();
|
||||
|
||||
// Check if player is even valid?!?
|
||||
|
||||
// only check if not a server item
|
||||
if (!auctionItem.isServerItem()) {
|
||||
if (seller == null) {
|
||||
result.accept(auctionItem, PLAYER_INSTANCE_NOT_FOUND);
|
||||
return;
|
||||
@ -78,6 +84,7 @@ public final class AuctionCreator {
|
||||
result.accept(auctionItem, CANNOT_SELL_REPAIRED_ITEM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!AuctionAPI.getInstance().meetsMinItemPrice(BundleUtil.isBundledItem(auctionItem.getItem()), auctionItem.isBidItem(), auctionItem.getItem(), auctionItem.getBasePrice(), auctionItem.getBidStartingPrice())) {
|
||||
instance.getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(AuctionHouse.getInstance().getMinItemPriceManager().getMinPrice(auctionItem.getItem()).getPrice())).sendPrefixedMessage(seller);
|
||||
@ -100,7 +107,7 @@ public final class AuctionCreator {
|
||||
final double listingFee = Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean() ? AuctionAPI.getInstance().calculateListingFee(originalBasePrice) : 0;
|
||||
|
||||
// check tax
|
||||
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean()) {
|
||||
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean() && !auctionItem.isServerItem()) {
|
||||
if (!EconomyManager.hasBalance(seller, listingFee)) {
|
||||
instance.getLocale().getMessage("auction.tax.cannotpaylistingfee").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(listingFee)).sendPrefixedMessage(seller);
|
||||
result.accept(auctionItem, CANNOT_PAY_LISTING_FEE);
|
||||
@ -162,6 +169,7 @@ public final class AuctionCreator {
|
||||
|
||||
// Actually attempt the insertion now
|
||||
AuctionHouse.getInstance().getDataManager().insertAuctionAsync(auctionItem, (error, inserted) -> {
|
||||
if (auctionPlayer != null)
|
||||
auctionPlayer.setItemBeingListed(null);
|
||||
|
||||
if (error != null) {
|
||||
@ -181,7 +189,7 @@ public final class AuctionCreator {
|
||||
}
|
||||
|
||||
// If the item could not be added for whatever reason and the tax listing fee is enabled, refund them
|
||||
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean()) {
|
||||
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean() && !auctionItem.isServerItem()) {
|
||||
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
|
||||
AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(
|
||||
seller.getUniqueId(),
|
||||
|
Loading…
Reference in New Issue
Block a user