mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-25 05:55:13 +01:00
fixed issue with min item prices being ignored while using the smart price + also blocked -stack / -s behind auctionhouse.cmdflag.stack perm
Took 11 minutes
This commit is contained in:
parent
c289cca30a
commit
2368202f4d
@ -20,6 +20,7 @@ import ca.tweetzy.core.utils.PlayerUtils;
|
||||
import ca.tweetzy.core.utils.TextUtils;
|
||||
import ca.tweetzy.core.utils.items.ItemUtils;
|
||||
import ca.tweetzy.core.utils.nms.NBTEditor;
|
||||
import net.minecraft.world.item.Items;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -28,6 +29,7 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -655,23 +657,9 @@ public class AuctionAPI {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AuctionHouse.getInstance().getMinItemPriceManager().getMinPrices().isEmpty() && !isUsingBundle) {
|
||||
final MinItemPrice foundMinPriceItem = AuctionHouse.getInstance().getMinItemPriceManager().getMinPrice(original);
|
||||
if (foundMinPriceItem != null) {
|
||||
|
||||
boolean valid = true;
|
||||
|
||||
if (isBiddingItem) {
|
||||
if (basePrice < foundMinPriceItem.getPrice() || bidStartPrice < foundMinPriceItem.getPrice()) valid = false;
|
||||
} else {
|
||||
if (basePrice < foundMinPriceItem.getPrice()) valid = false;
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(foundMinPriceItem.getPrice())).sendPrefixedMessage(seller);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!meetsMinItemPrice(isUsingBundle, isBiddingItem, original, basePrice, bidStartPrice)) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(AuctionHouse.getInstance().getMinItemPriceManager().getMinPrice(original).getPrice())).sendPrefixedMessage(seller);
|
||||
return;
|
||||
}
|
||||
|
||||
AuctionedItem auctionedItem = new AuctionedItem();
|
||||
@ -771,6 +759,24 @@ public class AuctionAPI {
|
||||
});
|
||||
}
|
||||
|
||||
public boolean meetsMinItemPrice(boolean isUsingBundle, boolean isBiddingItem, ItemStack original, double basePrice, double bidStartPrice) {
|
||||
boolean valid = true;
|
||||
|
||||
if (!AuctionHouse.getInstance().getMinItemPriceManager().getMinPrices().isEmpty() && !isUsingBundle) {
|
||||
final MinItemPrice foundMinPriceItem = AuctionHouse.getInstance().getMinItemPriceManager().getMinPrice(original);
|
||||
if (foundMinPriceItem != null) {
|
||||
|
||||
if (isBiddingItem) {
|
||||
if (basePrice < foundMinPriceItem.getPrice() || bidStartPrice < foundMinPriceItem.getPrice()) valid = false;
|
||||
} else {
|
||||
if (basePrice < foundMinPriceItem.getPrice()) valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
public void logException(@Nullable Plugin plugin, @NotNull Throwable th) {
|
||||
logException(plugin, th, null);
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public final class CommandSell extends AbstractCommand {
|
||||
if (args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-bundle"))
|
||||
isBundle = true;
|
||||
|
||||
if (args[i].equalsIgnoreCase("-s") || args[i].equalsIgnoreCase("-stack"))
|
||||
if (player.hasPermission("auctionhouse.cmdflag.stack") && args[i].equalsIgnoreCase("-s") || args[i].equalsIgnoreCase("-stack"))
|
||||
isStackPrice = true;
|
||||
|
||||
if ((args[i].equalsIgnoreCase("-i") || args[i].equalsIgnoreCase("-infinite")) && (player.hasPermission("auctionhouse.admin") || player.isOp()))
|
||||
@ -180,12 +180,25 @@ public final class CommandSell extends AbstractCommand {
|
||||
|
||||
// NOT USING THE BIDDING SYSTEM
|
||||
if (!isBiddingItem /* && buyNowPrice != null */) {
|
||||
// min item price todo fix it broke
|
||||
if (!AuctionAPI.getInstance().meetsMinItemPrice(isBundle, isBiddingItem, originalItem, buyNowPrice, isBiddingItem ? startingBid : 0)) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(AuctionHouse.getInstance().getMinItemPriceManager().getMinPrice(originalItem).getPrice())).sendPrefixedMessage(player);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
// Check the if the price meets the min/max criteria
|
||||
if (!checkBasePrice(player, buyNowPrice, false)) return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (isBiddingItem && /* buyNowPrice != null && */ startingBid != null) {
|
||||
// min item price todo fix it broke
|
||||
if (!AuctionAPI.getInstance().meetsMinItemPrice(isBundle, isBiddingItem, originalItem, buyNowPrice, isBiddingItem ? startingBid : 0)) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(AuctionHouse.getInstance().getMinItemPriceManager().getMinPrice(originalItem).getPrice())).sendPrefixedMessage(player);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (!checkBasePrice(player, buyNowPrice, true)) return ReturnType.FAILURE;
|
||||
|
||||
// check the starting bid values
|
||||
if (startingBid < Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.minstartingprice").processPlaceholder("price", Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player);
|
||||
@ -219,6 +232,10 @@ public final class CommandSell extends AbstractCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.SMART_MIN_BUY_PRICE.getBoolean() && itemToSell.getAmount() > 1) {
|
||||
buyNowPrice = isStackPrice ? buyNowPrice : buyNowPrice * itemToSell.getAmount();
|
||||
}
|
||||
|
||||
if (!Settings.ALLOW_ITEM_BUNDLES.getBoolean() && isBundle) {
|
||||
return ReturnType.FAILURE;
|
||||
} else {
|
||||
@ -254,10 +271,6 @@ public final class CommandSell extends AbstractCommand {
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
if (Settings.SMART_MIN_BUY_PRICE.getBoolean() && itemToSell.getAmount() > 1) {
|
||||
buyNowPrice = isStackPrice ? buyNowPrice : buyNowPrice * itemToSell.getAmount();
|
||||
}
|
||||
|
||||
if (Settings.ASK_FOR_LISTING_CONFIRMATION.getBoolean()) {
|
||||
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIConfirmListing(
|
||||
player,
|
||||
|
Loading…
Reference in New Issue
Block a user