💴💵💶 Multi-Currency Support 💶💵💴

Took 3 hours 16 minutes
This commit is contained in:
Kiran Hart 2024-08-30 16:08:21 -04:00
parent 09d2f1176f
commit 9ae1070486
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
39 changed files with 1061 additions and 435 deletions

View File

@ -3,9 +3,13 @@
![logo](https://i.imgur.com/ENVi7Jn.png)
**The most feature packed, up to date auction plugin on Spigot. 1.8-1.18 support in a single jar.**
### Yes the code is pretty messy, working on cleaning it up. Stuff inside the api folder is the new object structures. Impl package is said interfaces, managers, model, and settings.settingsv3 are also the 'new' format. Pretty much structuring this project like my other updated ones (github/tweetzy)
**The most feature packed, up to date auction plugin on Spigot. 1.8\* -1.21 support in a single jar.**
**Auction House is the ultimate solution when it comes to server auctions. Unlike other auction plugins, auction house provides many features and is GUI based.**
**1.8 - 1.15.0 support is limited, features may or may not work. Use the latest version.**
<!-- Shields -->
[![Discord](https://img.shields.io/discord/821837624272617473?color=7289DA&label=Discord&logo=discord&logoColor=7289DA)](https://discord.tweetzy.ca)
<br>

View File

@ -18,6 +18,7 @@
package ca.tweetzy.auctionhouse;
import ca.tweetzy.auctionhouse.api.AuctionHouseAPI;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.commands.*;
import ca.tweetzy.auctionhouse.database.DataManager;
@ -25,6 +26,7 @@ import ca.tweetzy.auctionhouse.database.migrations.*;
import ca.tweetzy.auctionhouse.database.migrations.v2.*;
import ca.tweetzy.auctionhouse.helpers.UpdateChecker;
import ca.tweetzy.auctionhouse.hooks.PlaceholderAPIHook;
import ca.tweetzy.auctionhouse.impl.AuctionAPI;
import ca.tweetzy.auctionhouse.listeners.*;
import ca.tweetzy.auctionhouse.managers.*;
import ca.tweetzy.auctionhouse.model.manager.BanManager;
@ -97,6 +99,7 @@ public class AuctionHouse extends TweetyPlugin {
private final MinItemPriceManager minItemPriceManager = new MinItemPriceManager();
private final PaymentsManager paymentsManager = new PaymentsManager();
private AuctionHouseAPI API;
// the default vault economy
private Economy economy = null;
@ -129,6 +132,7 @@ public class AuctionHouse extends TweetyPlugin {
return;
}
API = new AuctionAPI();
taskChainFactory = BukkitTaskChainFactory.create(this);
migrationCoreConfig = new TweetzyYamlConfig(this, "migration-config-dont-touch.yml");
@ -187,7 +191,8 @@ public class AuctionHouse extends TweetyPlugin {
new _25_BidHistoryMigration(),
new _26_MultiSerAndCurrencyMigration(),
new _27_FixMigration25to26Migration(),
new _28_PriorityListingMigration()
new _28_PriorityListingMigration(),
new _29_PaymentMultiCurrencyMigration()
);
dataMigrationManager.runMigrations();
@ -201,11 +206,6 @@ public class AuctionHouse extends TweetyPlugin {
this.currencyManager.load();
this.paymentsManager.load();
// warn users if there is a mismatch between new economy and old
if (Settings.ECONOMY_PLUGIN.getString().toLowerCase().contains("ultraeconomy") && !Settings.CURRENCY_DEFAULT_SELECTED.getString().toLowerCase().contains("ultraeconomy")) {
getLogger().warning("You are seeing this message because there is a miss match between your old economy provider settings and the new one. While the plugin will default to Vault, if you are seeing this message it's likely because you were using UltraEconomy and you haven't set it up back under 'default selection' in the config.yml!");
}
// listeners
Bukkit.getServer().getPluginManager().registerEvents(new PlayerListeners(), this);
Bukkit.getServer().getPluginManager().registerEvents(new MeteorClientListeners(), this);
@ -349,6 +349,10 @@ public class AuctionHouse extends TweetyPlugin {
return (AuctionHouse) TweetyPlugin.getInstance();
}
public static AuctionHouseAPI getAPI() {
return getInstance().API;
}
public static DataManager getDataManager() {
return getInstance().dataManager;
}

View File

@ -20,6 +20,7 @@ package ca.tweetzy.auctionhouse.api;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.auction.AuctionPayment;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.auction.MinItemPrice;
import ca.tweetzy.auctionhouse.auction.enums.PaymentReason;
import ca.tweetzy.auctionhouse.settings.Settings;
@ -53,8 +54,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
@ -84,32 +83,6 @@ public class AuctionAPI {
return instance;
}
/**
* @param value a long number to be converted into a easily readable text
* @return a user friendly number to read
*/
public String getFriendlyNumber(double value) {
if (value <= 0) return "0";
int power;
String suffix = " KMBTQPEZY";
String formattedNumber = "";
try {
NumberFormat formatter = new DecimalFormat("#,###.#");
power = (int) StrictMath.log10(value);
value = value / (Math.pow(10, (power / 3) * 3));
formattedNumber = formatter.format(value);
formattedNumber = formattedNumber + suffix.charAt(power / 3);
} catch (StringIndexOutOfBoundsException e) {
return formatNumber(value);
}
return formattedNumber.length() > 4 ? formattedNumber.replaceAll("\\.[0-9]+", "") : formattedNumber;
}
/**
* Used to convert seconds to days, hours, minutes, and seconds
*
@ -383,32 +356,6 @@ public class AuctionAPI {
return matcher.matches();
}
/**
* Used to format numbers with decimals and commas
*
* @param number is the number you want to format
* @return the formatted number string
*/
public String formatNumber(double number) {
String formatted = String.format(Settings.CURRENCY_FORMAT.getString(), number);//%,.2f
if (Settings.USE_SPACE_SEPARATOR_FOR_NUMBER.getBoolean())
formatted = formatted.replace(",", " ");
// do the zero drop here
// this is a bit scuffed, I gotta improve this
if (Settings.STRIP_ZEROS_ON_WHOLE_NUMBERS.getBoolean()) {
if (Double.parseDouble(formatted.replace(",", "")) % 1 == 0) {
formatted = formatted.replaceAll("0+$", "");
if (formatted.endsWith("."))
formatted = formatted.substring(0, formatted.length() - 1);
}
}
String preDecimal = Settings.USE_ALTERNATE_CURRENCY_FORMAT.getBoolean() ? replaceLast(formatted.replace(",", "."), ".", ",") : formatted;
return Settings.USE_FLAT_NUMBER_FORMAT.getBoolean() ? preDecimal.replace(".", "").replace(",", "") : preDecimal;
}
/**
* Used to replace the last portion of a string
*
@ -756,47 +703,69 @@ public class AuctionAPI {
return seconds;
}
public void withdrawBalance(OfflinePlayer player, double amount) {
private void handleWithdraw(OfflinePlayer player, double amount, AuctionedItem auctionedItem) {
if (auctionedItem.hasValidItemCurrency())
AuctionHouse.getCurrencyManager().withdraw(player, auctionedItem.getCurrencyItem(), (int) amount);
else {
final String[] currSplit = auctionedItem.getCurrency().split("/");
AuctionHouse.getCurrencyManager().withdraw(player, currSplit[0], currSplit[1], amount);
}
}
public void withdrawBalance(OfflinePlayer player, double amount, AuctionedItem auctionedItem) {
if (Settings.PAYMENT_HANDLE_USE_CMD.getBoolean()) {
AuctionHouse.newChain().sync(() -> {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), Settings.PAYMENT_HANDLE_WITHDRAW_CMD.getString().replace("%player%", player.getName()).replace("%price%", String.valueOf(amount)));
}).execute();
} else {
if (Settings.FORCE_SYNC_MONEY_ACTIONS.getBoolean())
AuctionHouse.newChain().sync(() -> AuctionHouse.getCurrencyManager().withdraw(player, amount)).execute();
else
AuctionHouse.getCurrencyManager().withdraw(player, amount);
AuctionHouse.newChain().sync(() -> handleWithdraw(player, amount, auctionedItem)).execute();
else {
handleWithdraw(player, amount, auctionedItem);
}
}
}
public void depositBalance(OfflinePlayer player, double amount, ItemStack item, OfflinePlayer paidFrom) {
public void depositBalance(OfflinePlayer player, double amount, ItemStack item, OfflinePlayer paidFrom, AuctionedItem auctionedItem) {
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean()) {
if (Settings.MANUAL_PAYMENTS_ONLY_FOR_OFFLINE_USERS.getBoolean()) {
if (!player.isOnline()) {
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(player.getUniqueId(), amount, item, paidFrom.getName(), PaymentReason.ITEM_SOLD), null);
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(player.getUniqueId(), amount, item, paidFrom.getName(), PaymentReason.ITEM_SOLD, auctionedItem.getCurrency(), auctionedItem.getCurrencyItem()), null);
} else {
initiatePayment(player, amount);
initiatePayment(player, amount, auctionedItem);
}
return;
}
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(player.getUniqueId(), amount, item, paidFrom.getName(), PaymentReason.ITEM_SOLD), null);
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(player.getUniqueId(), amount, item, paidFrom.getName(), PaymentReason.ITEM_SOLD, auctionedItem.getCurrency(), auctionedItem.getCurrencyItem()), null);
return;
}
initiatePayment(player, amount);
initiatePayment(player, amount, auctionedItem);
}
private void initiatePayment(OfflinePlayer player, double amount) {
private void initiatePayment(OfflinePlayer player, double amount, AuctionedItem auctionedItem) {
if (Settings.PAYMENT_HANDLE_USE_CMD.getBoolean()) {
AuctionHouse.newChain().sync(() -> {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), Settings.PAYMENT_HANDLE_DEPOSIT_CMD.getString().replace("%player%", player.getName()).replace("%price%", String.valueOf(amount)));
}).execute();
AuctionHouse.newChain().sync(() -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), Settings.PAYMENT_HANDLE_DEPOSIT_CMD.getString().replace("%player%", player.getName()).replace("%price%", String.valueOf(amount)))).execute();
} else {
if (Settings.FORCE_SYNC_MONEY_ACTIONS.getBoolean())
AuctionHouse.newChain().sync(() -> AuctionHouse.getCurrencyManager().deposit(player, amount)).execute();
AuctionHouse.newChain().sync(() -> handleDeposit(player, amount, auctionedItem)).execute();
else {
handleDeposit(player, amount, auctionedItem);
}
}
}
private void handleDeposit(OfflinePlayer player, double amount, AuctionedItem auctionedItem) {
if (auctionedItem.hasValidItemCurrency())
if (player.isOnline())
AuctionHouse.getCurrencyManager().deposit(player, auctionedItem.getCurrencyItem(), (int) amount);
else
AuctionHouse.getCurrencyManager().deposit(player, amount);
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(player.getUniqueId(), amount, auctionedItem.getItem(), AuctionHouse.getInstance().getLocale().getMessage("general.prefix").getMessage(), PaymentReason.ITEM_SOLD, auctionedItem.getCurrency(), auctionedItem.getCurrencyItem()), null);
else {
final String[] currSplit = auctionedItem.getCurrency().split("/");
AuctionHouse.getCurrencyManager().deposit(player, currSplit[0], currSplit[1], amount);
}
}

View File

@ -18,5 +18,22 @@
package ca.tweetzy.auctionhouse.api;
import org.bukkit.inventory.ItemStack;
public interface AuctionHouseAPI {
/*
----------------------------------------------------------------
CURRENCY / NUMBER / DATE RELATED STUFF
----------------------------------------------------------------
*/
String getNumberAsCurrency(final double number, boolean hideSymbol);
String getNumberAsCurrency(final double number);
String getAbbreviatedNumber(final double number, boolean hideSymbol);
String getAbbreviatedNumber(final double number);
String getFinalizedCurrencyNumber(final double number, final String currency, final ItemStack currencyItem);
}

View File

@ -19,8 +19,8 @@
package ca.tweetzy.auctionhouse.auction;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.enums.PaymentReason;
import ca.tweetzy.flight.comp.enums.CompMaterial;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.entity.Player;
@ -38,17 +38,29 @@ public final class AuctionPayment {
private final String fromName;
private final PaymentReason reason;
private final double amount;
private final long time;
public AuctionPayment(UUID to, double amount, ItemStack item, String fromName, PaymentReason reason) {
this(UUID.randomUUID(), to, item, fromName, reason, amount, System.currentTimeMillis());
private final String currency;
private final ItemStack currencyItem;
public AuctionPayment(UUID to, double amount, ItemStack item, String fromName, PaymentReason reason, String currency, ItemStack currencyItem) {
this(UUID.randomUUID(), to, item, fromName, reason, amount, System.currentTimeMillis(), currency, currencyItem);
}
public void pay(Player player) {
AuctionHouse.getCurrencyManager().deposit(player, this.amount);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.amount)).sendPrefixedMessage(player);
final String[] currSplit = currency.split("/");
if (currencyItem != null && currencyItem.getType() != CompMaterial.AIR.parseMaterial()) {
AuctionHouse.getCurrencyManager().deposit(player, currencyItem, (int) this.amount);
} else {
AuctionHouse.getCurrencyManager().deposit(player, currSplit[0], currSplit[1], this.amount);
}
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getNumberAsCurrency(AuctionHouse.getCurrencyManager().getBalance(player)))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(this.amount, this.currency, this.currencyItem))
.sendPrefixedMessage(player);
}
}

View File

@ -26,6 +26,7 @@ import ca.tweetzy.auctionhouse.helpers.BundleUtil;
import ca.tweetzy.auctionhouse.model.MaterialCategorizer;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.flight.comp.enums.CompMaterial;
import ca.tweetzy.flight.comp.enums.ServerVersion;
import ca.tweetzy.flight.nbtapi.NBT;
import ca.tweetzy.flight.utils.Common;
@ -33,6 +34,7 @@ import ca.tweetzy.flight.utils.QuickItem;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -81,6 +83,9 @@ public class AuctionedItem {
private boolean hasListingPriority;
private long priorityExpiresAt;
private String currency = Settings.CURRENCY_DEFAULT_SELECTED.getString();
private ItemStack currencyItem;
public AuctionedItem() {
}
@ -154,7 +159,7 @@ public class AuctionedItem {
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_HEADER.getStringList()));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_SELLER.getStringList().stream().map(s -> s.replace("%seller%", this.ownerName)).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_CURRENT_PRICE.getStringList().stream().map(s -> s.replace("%currentprice%", Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.currentPrice) : AuctionAPI.getInstance().formatNumber(this.currentPrice))).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_CURRENT_PRICE.getStringList().stream().map(s -> s.replace("%currentprice%", AuctionHouse.getAPI().getFinalizedCurrencyNumber(this.currentPrice, this.currency, this.currencyItem))).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_HIGHEST_BIDDER.getStringList().stream().map(s -> s.replace("%highestbidder%", this.highestBidder.equals(this.owner) ? AuctionHouse.getInstance().getLocale().getMessage("auction.nobids").getMessage() : this.highestBidderName)).collect(Collectors.toList())));
if (this.infinite) {
@ -185,7 +190,7 @@ public class AuctionedItem {
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_HEADER.getStringList()));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_REQUESTER.getStringList().stream().map(s -> s.replace("%requester%", this.ownerName)).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_REQUEST_PRICE.getStringList().stream().map(s -> s.replace("%request_price%", Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.basePrice) : AuctionAPI.getInstance().formatNumber(this.basePrice))).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_REQUEST_PRICE.getStringList().stream().map(s -> s.replace("%request_price%", AuctionHouse.getAPI().getFinalizedCurrencyNumber(this.basePrice, this.currency, this.currencyItem))).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_REQUEST_COUNT.getStringList().stream().map(s -> s.replace("%request_amount%", String.valueOf(requestAmount))).collect(Collectors.toList())));
long[] times = AuctionAPI.getInstance().getRemainingTimeValues((this.expiresAt - System.currentTimeMillis()) / 1000);
@ -226,17 +231,17 @@ public class AuctionedItem {
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_SELLER.getStringList().stream().map(s -> s.replace("%seller%", this.ownerName)).collect(Collectors.toList())));
if (this.basePrice != -1) {
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_BUY_NOW.getStringList().stream().filter(s -> this.isBidItem ? s.length() != 0 : s.length() >= 0).map(s -> s.replace("%buynowprice%", Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.basePrice) : AuctionAPI.getInstance().formatNumber(this.basePrice))).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_BUY_NOW.getStringList().stream().filter(s -> this.isBidItem ? s.length() != 0 : s.length() >= 0).map(s -> s.replace("%buynowprice%", getFormattedBasePrice())).collect(Collectors.toList())));
}
if (this.isBidItem) {
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_CURRENT_PRICE.getStringList().stream().map(s -> s.replace("%currentprice%", Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.currentPrice) : AuctionAPI.getInstance().formatNumber(this.currentPrice))).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_CURRENT_PRICE.getStringList().stream().map(s -> s.replace("%currentprice%", AuctionHouse.getAPI().getFinalizedCurrencyNumber(this.currentPrice, this.currency, this.currencyItem))).collect(Collectors.toList())));
if (!Settings.FORCE_CUSTOM_BID_AMOUNT.getBoolean()) {
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_BID_INCREMENT.getStringList().stream().map(s -> s.replace("%bidincrement%", Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.bidIncrementPrice) : AuctionAPI.getInstance().formatNumber(this.bidIncrementPrice))).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_BID_INCREMENT.getStringList().stream().map(s -> s.replace("%bidincrement%", AuctionHouse.getAPI().getFinalizedCurrencyNumber(this.bidIncrementPrice, this.currency, this.currencyItem))).collect(Collectors.toList())));
}
if (Settings.FORCE_CUSTOM_BID_AMOUNT.getBoolean() && Settings.USE_REALISTIC_BIDDING.getBoolean()) {
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_BID_INCREMENT.getStringList().stream().map(s -> s.replace("%bidincrement%", Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.bidIncrementPrice) : AuctionAPI.getInstance().formatNumber(this.bidIncrementPrice))).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_BID_INCREMENT.getStringList().stream().map(s -> s.replace("%bidincrement%", AuctionHouse.getAPI().getFinalizedCurrencyNumber(this.bidIncrementPrice, this.currency, this.currencyItem))).collect(Collectors.toList())));
}
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_HIGHEST_BIDDER.getStringList().stream().map(s -> s.replace("%highestbidder%", this.highestBidder.equals(this.owner) ? AuctionHouse.getInstance().getLocale().getMessage("auction.nobids").getMessage() : this.highestBidderName)).collect(Collectors.toList())));
@ -306,6 +311,17 @@ public class AuctionedItem {
return itemStack.make();
}
public boolean playerHasSufficientMoney(OfflinePlayer player, double amount) {
if (this.currencyItem != null && this.currencyItem.getType() != CompMaterial.AIR.parseMaterial()) {
return AuctionHouse.getCurrencyManager().has(player, this.currencyItem, (int) amount);
}
final String[] split = this.currency.split("/");
return AuctionHouse.getCurrencyManager().has(player, split[0], split[1], amount);
}
public ItemStack getCleanItem() {
ItemStack cleaned = this.item.clone();
NBT.modify(cleaned, nbt -> {
@ -315,6 +331,26 @@ public class AuctionedItem {
return cleaned;
}
public boolean hasValidItemCurrency() {
return this.currencyItem != null && this.currencyItem.getType() != CompMaterial.AIR.parseMaterial();
}
public String getFormattedCurrentPrice() {
return AuctionHouse.getAPI().getFinalizedCurrencyNumber(this.currentPrice, this.currency, this.currencyItem);
}
public String getFormattedBasePrice() {
return AuctionHouse.getAPI().getFinalizedCurrencyNumber(this.basePrice, this.currency, this.currencyItem);
}
public String getFormattedStartingPrice() {
return AuctionHouse.getAPI().getFinalizedCurrencyNumber(this.bidStartingPrice, this.currency, this.currencyItem);
}
public String getFormattedIncrementPrice() {
return AuctionHouse.getAPI().getFinalizedCurrencyNumber(this.bidIncrementPrice, this.currency, this.currencyItem);
}
public boolean containsValidBid() {
return isBidItem() && !this.highestBidder.equals(this.owner);
}

View File

@ -258,10 +258,12 @@ public class CommandAdmin extends Command {
auctionedItem.getCurrentPrice(),
auctionedItem.getItem(),
player.getName(),
PaymentReason.BID_RETURNED
PaymentReason.BID_RETURNED,
auctionedItem.getCurrency(),
auctionedItem.getCurrencyItem()
), null);
else
AuctionHouse.getCurrencyManager().deposit(player, auctionedItem.getCurrentPrice());
AuctionHouse.getCurrencyManager().deposit(player, auctionedItem.getCurrentPrice(), auctionedItem.getCurrency(), auctionedItem.getCurrencyItem());
}
}
@ -286,13 +288,18 @@ public class CommandAdmin extends Command {
auctionItem.getCurrentPrice(),
auctionItem.getItem(),
player.getName(),
PaymentReason.ADMIN_REMOVED
PaymentReason.ADMIN_REMOVED,
auctionItem.getCurrency(),
auctionItem.getCurrencyItem()
), null);
else
AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice());
AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem());
if (oldBidder.isOnline())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder, auctionItem.getCurrency().split("/")[0], auctionItem.getCurrency().split("/")[1]), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", auctionItem.getFormattedCurrentPrice())
.sendPrefixedMessage(oldBidder.getPlayer());
}
}

View File

@ -83,7 +83,7 @@ public class CommandMinPrice extends Command {
AuctionHouse.getMinItemPriceManager().addItem(inserted);
AuctionHouse.getInstance().getLocale().getMessage("general.added min price")
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(inserted.getItemStack()))
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(inserted.getPrice()))
.processPlaceholder("price", AuctionHouse.getAPI().getNumberAsCurrency(inserted.getPrice(), false))
.sendPrefixedMessage(player);
}
});

View File

@ -224,7 +224,10 @@ public final class CommandSell extends Command {
// NOT USING THE BIDDING SYSTEM
if (!isBiddingItem) {
if (!AuctionAPI.getInstance().meetsMinItemPrice(isBundle, isBiddingItem, originalItem, buyNowPrice, isBiddingItem ? startingBid : 0)) {
AuctionHouse.getInstance().getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(AuctionHouse.getMinItemPriceManager().getMinPrice(originalItem).getPrice())).sendPrefixedMessage(player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.minitemprice")
.processPlaceholder("price", AuctionHouse.getAPI().getNumberAsCurrency(AuctionHouse.getMinItemPriceManager().getMinPrice(originalItem).getPrice()))
.sendPrefixedMessage(player);
return ReturnType.FAIL;
}
@ -234,7 +237,10 @@ public final class CommandSell extends Command {
if (isBiddingItem && startingBid != null) {
if (!AuctionAPI.getInstance().meetsMinItemPrice(isBundle, isBiddingItem, originalItem, buyNowPrice, isBiddingItem ? startingBid : 0)) {
AuctionHouse.getInstance().getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(AuctionHouse.getMinItemPriceManager().getMinPrice(originalItem).getPrice())).sendPrefixedMessage(player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.minitemprice")
.processPlaceholder("price", AuctionHouse.getAPI().getNumberAsCurrency(AuctionHouse.getMinItemPriceManager().getMinPrice(originalItem).getPrice()))
.sendPrefixedMessage(player);
return ReturnType.FAIL;
}

View File

@ -346,7 +346,7 @@ public class DataManager extends DataManagerAbstract {
public void insertAuction(AuctionedItem item, Callback<AuctionedItem> callback) {
this.runAsync(() -> this.databaseConnector.connect(connection -> {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO " + this.getTablePrefix() + "auctions(id, owner, highest_bidder, owner_name, highest_bidder_name, category, base_price, bid_start_price, bid_increment_price, current_price, expired, expires_at, item_material, item_name, item_lore, item_enchants, item, listed_world, infinite, allow_partial_buys, server_auction, is_request, request_count, serialize_version, itemstack, listing_priority, priority_expires_at) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO " + this.getTablePrefix() + "auctions(id, owner, highest_bidder, owner_name, highest_bidder_name, category, base_price, bid_start_price, bid_increment_price, current_price, expired, expires_at, item_material, item_name, item_lore, item_enchants, item, listed_world, infinite, allow_partial_buys, server_auction, is_request, request_count, serialize_version, itemstack, listing_priority, priority_expires_at, currency, currency_item) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
final AuctionAPI api = AuctionAPI.getInstance();
PreparedStatement fetch = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "auctions WHERE id = ?");
@ -363,10 +363,10 @@ public class DataManager extends DataManagerAbstract {
statement.setDouble(10, item.getCurrentPrice());
statement.setBoolean(11, item.isExpired());
statement.setLong(12, item.getExpiresAt());
statement.setString(13, item.getItem().getType().name());
statement.setString(14, api.getItemName(item.getItem()));
statement.setString(15, api.serializeLines(api.getItemLore(item.getItem())));
statement.setString(16, api.serializeLines(api.getItemEnchantments(item.getItem())));
statement.setString(13, item.getItem().getType().name()); // todo remove
statement.setString(14, api.getItemName(item.getItem())); // todo remove
statement.setString(15, api.serializeLines(api.getItemLore(item.getItem()))); // todo remove
statement.setString(16, api.serializeLines(api.getItemEnchantments(item.getItem()))); // todo remove
statement.setString(17, AuctionAPI.encodeItem(item.getItem()));
statement.setString(18, item.getListedWorld());
statement.setBoolean(19, item.isInfinite());
@ -386,6 +386,10 @@ public class DataManager extends DataManagerAbstract {
statement.setBoolean(26, item.isHasListingPriority());
statement.setLong(27, item.getPriorityExpiresAt());
// currency, currency_item, listed_server
statement.setString(28, item.getCurrency());
statement.setString(29, (item.getCurrencyItem() == null || item.getCurrencyItem() == CompMaterial.AIR.parseItem()) ? null : QuickItem.toString(item.getCurrencyItem()));
statement.executeUpdate();
if (callback != null) {
@ -438,6 +442,9 @@ public class DataManager extends DataManagerAbstract {
auctionItem.setHasListingPriority(priorityExpiresAt >= System.currentTimeMillis() && resultSet.getBoolean("listing_priority"));
auctionItem.setPriorityExpiresAt(priorityExpiresAt);
auctionItem.setCurrency(resultSet.getString("currency"));
auctionItem.setCurrencyItem(resultSet.getString("currency_item") == null ? null : QuickItem.getItem(resultSet.getString("currency_item")));
return auctionItem;
}
@ -839,7 +846,7 @@ public class DataManager extends DataManagerAbstract {
public void insertAuctionPayment(AuctionPayment auctionPayment, Callback<AuctionPayment> callback) {
this.runAsync(() -> this.databaseConnector.connect(connection -> {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO " + getTablePrefix() + "payments (uuid, payment_for, amount, time, item, from_name, reason) VALUES (?, ?, ?, ?, ?, ?, ?)")) {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO " + getTablePrefix() + "payments (uuid, payment_for, amount, time, item, from_name, reason, currency, currency_item) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
PreparedStatement fetch = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "payments WHERE uuid = ?");
fetch.setString(1, auctionPayment.getId().toString());
@ -851,6 +858,10 @@ public class DataManager extends DataManagerAbstract {
statement.setString(6, auctionPayment.getFromName());
statement.setString(7, auctionPayment.getReason().name());
statement.setString(8, auctionPayment.getCurrency());
statement.setString(9, (auctionPayment.getCurrencyItem() == null || auctionPayment.getCurrencyItem() == CompMaterial.AIR.parseItem()) ? null : QuickItem.toString(auctionPayment.getCurrencyItem()));
statement.executeUpdate();
// insert into storage
@ -897,7 +908,9 @@ public class DataManager extends DataManagerAbstract {
(resultSet.getString("from_name") == null || resultSet.getString("from_name").trim().isEmpty()) ? null : resultSet.getString("from_name"),
(resultSet.getString("reason") == null || resultSet.getString("reason").trim().isEmpty()) ? PaymentReason.ITEM_SOLD : PaymentReason.valueOf(resultSet.getString("reason")),
resultSet.getDouble("amount"),
resultSet.getLong("time")
resultSet.getLong("time"),
resultSet.getString("currency"),
resultSet.getString("currency_item") == null ? null : QuickItem.getItem(resultSet.getString("currency_item"))
);
}

View File

@ -0,0 +1,22 @@
package ca.tweetzy.auctionhouse.database.migrations;
import ca.tweetzy.flight.database.DataMigration;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
public final class _29_PaymentMultiCurrencyMigration extends DataMigration {
public _29_PaymentMultiCurrencyMigration() {
super(29);
}
@Override
public void migrate(Connection connection, String tablePrefix) throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.execute("ALTER TABLE " + tablePrefix + "payments ADD currency TEXT NOT NULL DEFAULT 'Vault/Vault' ");
statement.execute("ALTER TABLE " + tablePrefix + "payments ADD currency_item TEXT NULL");
}
}
}

View File

@ -19,7 +19,6 @@
package ca.tweetzy.auctionhouse.guis.admin;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.AuctionAdminLog;
import ca.tweetzy.auctionhouse.auction.AuctionPayment;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
@ -88,11 +87,14 @@ public class GUIAdminItem extends AuctionBaseGUI {
final OfflinePlayer oldBidder = Bukkit.getOfflinePlayer(this.auctionItem.getHighestBidder());
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(oldBidder.getUniqueId(), auctionItem.getCurrentPrice(), auctionItem.getItem(), click.player.getName(), PaymentReason.ADMIN_REMOVED), null);
else AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice());
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(oldBidder.getUniqueId(), auctionItem.getCurrentPrice(), auctionItem.getItem(), click.player.getName(), PaymentReason.ADMIN_REMOVED, auctionItem.getCurrency(), auctionItem.getCurrencyItem()), null);
else AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice(), this.auctionItem.getCurrency(), this.auctionItem.getCurrencyItem());
if (oldBidder.isOnline())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getCurrencyManager().getFormattedBalance(oldBidder, this.auctionItem.getCurrency(), this.auctionItem.getCurrencyItem()))
.processPlaceholder("price", this.auctionItem.getFormattedCurrentPrice())
.sendPrefixedMessage(oldBidder.getPlayer());
}
@ -116,15 +118,18 @@ public class GUIAdminItem extends AuctionBaseGUI {
final OfflinePlayer oldBidder = Bukkit.getOfflinePlayer(this.auctionItem.getHighestBidder());
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(oldBidder.getUniqueId(), auctionItem.getCurrentPrice(), auctionItem.getItem(), click.player.getName(), PaymentReason.ADMIN_REMOVED), null);
else AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice());
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(oldBidder.getUniqueId(), auctionItem.getCurrentPrice(), auctionItem.getItem(), click.player.getName(), PaymentReason.ADMIN_REMOVED, auctionItem.getCurrency(), auctionItem.getCurrencyItem()), null);
else AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem());
if (oldBidder.isOnline())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getCurrencyManager().getFormattedBalance(oldBidder, this.auctionItem.getCurrency(), this.auctionItem.getCurrencyItem()))
.processPlaceholder("price", this.auctionItem.getFormattedCurrentPrice())
.sendPrefixedMessage(oldBidder.getPlayer());
}
AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(this.auctionItem);
AuctionHouse.getAuctionItemManager().sendToGarbage(this.auctionItem);
click.gui.close();
});
}
@ -142,22 +147,27 @@ public class GUIAdminItem extends AuctionBaseGUI {
final OfflinePlayer oldBidder = Bukkit.getOfflinePlayer(this.auctionItem.getHighestBidder());
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(
oldBidder.getUniqueId(),
auctionItem.getCurrentPrice(),
auctionItem.getItem(),
click.player.getName(),
PaymentReason.ADMIN_REMOVED
PaymentReason.ADMIN_REMOVED,
auctionItem.getCurrency(),
auctionItem.getCurrencyItem()
), null);
else
AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice());
AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem());
if (oldBidder.isOnline())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getCurrencyManager().getFormattedBalance(oldBidder, this.auctionItem.getCurrency(), this.auctionItem.getCurrencyItem()))
.processPlaceholder("price", this.auctionItem.getFormattedCurrentPrice())
.sendPrefixedMessage(oldBidder.getPlayer());
}
AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(this.auctionItem);
AuctionHouse.getAuctionItemManager().sendToGarbage(this.auctionItem);
click.gui.close();
});
}

View File

@ -41,7 +41,7 @@ import java.util.List;
public final class GUIMinItemPrices extends AuctionPagedGUI<MinItemPrice> {
public GUIMinItemPrices(Player player) {
super(null, player, Settings.GUI_MIN_ITEM_PRICES_TITLE.getString(), 6, AuctionHouse.getInstance().getMinItemPriceManager().getMinPrices());
super(null, player, Settings.GUI_MIN_ITEM_PRICES_TITLE.getString(), 6, AuctionHouse.getMinItemPriceManager().getMinPrices());
draw();
}
@ -58,14 +58,14 @@ public final class GUIMinItemPrices extends AuctionPagedGUI<MinItemPrice> {
return QuickItem
.of(minItemPrice.getItemStack().clone())
.name(AuctionAPI.getInstance().getItemName(minItemPrice.getItemStack()))
.lore(this.player, Replacer.replaceVariables(lore, "price", AuctionAPI.getInstance().formatNumber(minItemPrice.getPrice())))
.lore(this.player, Replacer.replaceVariables(lore, "price", AuctionHouse.getAPI().getNumberAsCurrency(minItemPrice.getPrice(), false)))
.make();
}
@Override
protected void onClick(MinItemPrice minItemPrice, GuiClickEvent event) {
AuctionHouse.getInstance().getDataManager().deleteMinItemPrice(Collections.singletonList(minItemPrice.getUuid()));
AuctionHouse.getInstance().getMinItemPriceManager().removeItem(minItemPrice);
AuctionHouse.getDataManager().deleteMinItemPrice(Collections.singletonList(minItemPrice.getUuid()));
AuctionHouse.getMinItemPriceManager().removeItem(minItemPrice);
event.manager.showGUI(event.player, new GUIMinItemPrices(event.player));
}
}

View File

@ -99,7 +99,7 @@ public class GUIConfirmBid extends AuctionUpdatingPagedGUI<AuctionedItem> {
} else {
if (Settings.BID_MUST_BE_HIGHER_THAN_PREVIOUS.getBoolean()) {
endAndReturn(click);
AuctionHouse.getInstance().getLocale().getMessage("pricing.bidmusthigherthanprevious").processPlaceholder("current_bid", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice())).sendPrefixedMessage(click.player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.bidmusthigherthanprevious").processPlaceholder("current_bid", auctionItem.getFormattedCurrentPrice()).sendPrefixedMessage(click.player);
return;
}
@ -139,23 +139,31 @@ public class GUIConfirmBid extends AuctionUpdatingPagedGUI<AuctionedItem> {
if (!auctionItem.getHighestBidder().equals(auctionItem.getOwner())) {
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(
oldBidder.getUniqueId(),
oldBidAmount,
auctionItem.getItem(),
AuctionHouse.getInstance().getLocale().getMessage("general.prefix").getMessage(),
PaymentReason.BID_RETURNED
PaymentReason.BID_RETURNED,
auctionItem.getCurrency(),
auctionItem.getCurrencyItem()
), null);
else
AuctionHouse.getCurrencyManager().deposit(oldBidder, oldBidAmount);
AuctionHouse.getCurrencyManager().deposit(oldBidder, oldBidAmount, auctionItem.getCurrency(), auctionItem.getCurrencyItem());
if (oldBidder.isOnline())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(oldBidAmount)).sendPrefixedMessage(oldBidder.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder, auctionItem.getCurrency().split("/")[0], auctionItem.getCurrency().split("/")[1]), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(oldBidAmount, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.sendPrefixedMessage(oldBidder.getPlayer());
}
AuctionHouse.getCurrencyManager().withdraw(click.player, newBiddingAmount);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(click.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(newBiddingAmount)).sendPrefixedMessage(click.player);
AuctionHouse.getCurrencyManager().withdraw(click.player, newBiddingAmount, auctionItem.getCurrency(), auctionItem.getCurrencyItem());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(click.player, auctionItem.getCurrency().split("/")[0], auctionItem.getCurrency().split("/")[1]), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(newBiddingAmount, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.sendPrefixedMessage(click.player);
}
@ -174,7 +182,7 @@ public class GUIConfirmBid extends AuctionUpdatingPagedGUI<AuctionedItem> {
Bukkit.getOnlinePlayers().forEach(player -> AuctionHouse.getInstance().getLocale().getMessage("auction.broadcast.bid")
.processPlaceholder("player", click.player.getName())
.processPlaceholder("player_displayname", AuctionAPI.getInstance().getDisplayName(click.player))
.processPlaceholder("amount", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice()))
.processPlaceholder("amount", auctionItem.getFormattedCurrentPrice())
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack))
.sendPrefixedMessage(player));
}
@ -191,7 +199,7 @@ public class GUIConfirmBid extends AuctionUpdatingPagedGUI<AuctionedItem> {
AuctionHouse.getInstance().getLocale().getMessage("auction.placedbid")
.processPlaceholder("player", click.player.getName())
.processPlaceholder("player_displayname", AuctionAPI.getInstance().getDisplayName(click.player))
.processPlaceholder("amount", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice()))
.processPlaceholder("amount", auctionItem.getFormattedCurrentPrice())
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack))
.sendPrefixedMessage(owner.getPlayer());
}

View File

@ -19,7 +19,6 @@
package ca.tweetzy.auctionhouse.guis.confirmation;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.AuctionPayment;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
@ -79,7 +78,7 @@ public class GUIConfirmCancel extends AuctionBaseGUI {
.make(), click -> {
// Re-select the item to ensure that it's available
AuctionedItem located = AuctionHouse.getInstance().getAuctionItemManager().getItem(this.auctionItem.getId());
AuctionedItem located = AuctionHouse.getAuctionItemManager().getItem(this.auctionItem.getId());
if (located == null) {
click.manager.showGUI(click.player, new GUIActiveAuctions(this.auctionPlayer));
return;
@ -91,19 +90,23 @@ public class GUIConfirmCancel extends AuctionBaseGUI {
final OfflinePlayer oldBidder = Bukkit.getOfflinePlayer(located.getHighestBidder());
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(
oldBidder.getUniqueId(),
located.getCurrentPrice(),
auctionItem.getItem(),
AuctionHouse.getInstance().getLocale().getMessage("general.prefix").getMessage(),
PaymentReason.BID_RETURNED
PaymentReason.BID_RETURNED,
auctionItem.getCurrency(),
auctionItem.getCurrencyItem()
), null);
else
AuctionHouse.getCurrencyManager().deposit(oldBidder, located.getCurrentPrice());
AuctionHouse.getCurrencyManager().deposit(oldBidder, located.getCurrentPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem());
if (oldBidder.isOnline())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(located.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder, auctionItem.getCurrency().split("/")[0], auctionItem.getCurrency().split("/")[1]), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", located.getFormattedCurrentPrice())
.sendPrefixedMessage(oldBidder.getPlayer());
}

View File

@ -139,7 +139,7 @@ public class GUIConfirmPurchase extends AuctionBaseGUI {
SPECIAL SHIT FOR REQUESTS
============================================================================
*/
if (isRequest) {
if (isRequest) { //todo add multi currency support to requests
// check if the fulfiller even has the item
final int itemCount = AuctionAPI.getInstance().getItemCountInPlayerInventory(this.player, this.auctionItem.getItem());
final int amountNeeded = this.auctionItem.getRequestAmount() == 0 ? this.auctionItem.getItem().getAmount() : this.auctionItem.getRequestAmount();
@ -182,28 +182,31 @@ public class GUIConfirmPurchase extends AuctionBaseGUI {
toGive.setRequestAmount(amountNeeded);
AuctionHouse.getInstance().getDataManager().insertAuction(toGive, (error, inserted) -> AuctionHouse.getInstance().getAuctionItemManager().addAuctionItem(toGive));
AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(this.auctionItem);
AuctionHouse.getDataManager().insertAuction(toGive, (error, inserted) -> AuctionHouse.getAuctionItemManager().addAuctionItem(toGive));
AuctionHouse.getAuctionItemManager().sendToGarbage(this.auctionItem);
AuctionHouse.getInstance().getTransactionManager().getPrePurchasePlayers(auctionItem.getId()).forEach(player -> {
AuctionHouse.getInstance().getTransactionManager().removeAllRelatedPlayers(auctionItem.getId());
AuctionHouse.getTransactionManager().getPrePurchasePlayers(auctionItem.getId()).forEach(player -> {
AuctionHouse.getTransactionManager().removeAllRelatedPlayers(auctionItem.getId());
player.closeInventory();
});
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(e.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getBasePrice())).sendPrefixedMessage(e.player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(e.player, this.auctionItem.getCurrency().split("/")[0], this.auctionItem.getCurrency().split("/")[1]), this.auctionItem.getCurrency(), this.auctionItem.getCurrencyItem()))
.processPlaceholder("price", this.auctionItem.getFormattedBasePrice())
.sendPrefixedMessage(e.player);
if (requester.isOnline())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(requester.getPlayer()))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getBasePrice())).sendPrefixedMessage(requester.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(requester, this.auctionItem.getCurrency().split("/")[0], this.auctionItem.getCurrency().split("/")[1]), this.auctionItem.getCurrency(), this.auctionItem.getCurrencyItem()))
.processPlaceholder("price", this.auctionItem.getFormattedBasePrice())
.sendPrefixedMessage(requester.getPlayer());
e.gui.close();
return;
}
// languageNodes.put("pricing.moneyremove", "&c&l- $%price% &7(%player_balance%)");
// languageNodes.put("pricing.moneyadd", "&a&l+ $%price% &7(%player_balance%)");
// Check economy
if (!AuctionHouse.getCurrencyManager().has(e.player, buyNowPrice + (Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? tax : 0D))) {
if (!auctionItem.playerHasSufficientMoney(e.player, buyNowPrice + (Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? tax : 0D))) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
SoundManager.getInstance().playSound(e.player, Settings.SOUNDS_NOT_ENOUGH_MONEY.getString());
e.gui.close();
@ -235,7 +238,7 @@ public class GUIConfirmPurchase extends AuctionBaseGUI {
} else {
transferFunds(e.player, buyNowPrice);
if (!located.isInfinite())
AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(located);
AuctionHouse.getAuctionItemManager().sendToGarbage(located);
}
NBT.modify(toGive, nbt -> {
@ -248,24 +251,29 @@ public class GUIConfirmPurchase extends AuctionBaseGUI {
} else {
transferFunds(e.player, buyNowPrice);
if (!located.isInfinite())
AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(located);
AuctionHouse.getAuctionItemManager().sendToGarbage(located);
if (Settings.BIDDING_TAKES_MONEY.getBoolean() && !located.getHighestBidder().equals(located.getOwner())) {
final OfflinePlayer oldBidder = Bukkit.getOfflinePlayer(located.getHighestBidder());
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(
oldBidder.getUniqueId(),
auctionItem.getCurrentPrice(),
auctionItem.getItem(),
AuctionHouse.getInstance().getLocale().getMessage("general.prefix").getMessage(),
PaymentReason.BID_RETURNED
PaymentReason.BID_RETURNED,
auctionItem.getCurrency(),
auctionItem.getCurrencyItem()
), null);
else
AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice());
AuctionHouse.getCurrencyManager().deposit(oldBidder, auctionItem.getCurrentPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem());
if (oldBidder.isOnline())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(located.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder, auctionItem.getCurrency().split("/")[0], auctionItem.getCurrency().split("/")[1]), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", located.getFormattedCurrentPrice())
.sendPrefixedMessage(oldBidder.getPlayer());
}
@ -291,12 +299,14 @@ public class GUIConfirmPurchase extends AuctionBaseGUI {
.processPlaceholder("seller_displayname", AuctionAPI.getInstance().getDisplayName(seller))
.processPlaceholder("amount", auctionItem.getItem().getAmount())
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(auctionItem.getItem()))
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Math.max(auctionItem.getBasePrice(), auctionItem.getCurrentPrice())))
.processPlaceholder("price",
auctionItem.getBasePrice() > auctionItem.getCurrentPrice() ? auctionItem.getFormattedBasePrice() : auctionItem.getFormattedCurrentPrice()
)
.sendPrefixedMessage(player));
}
AuctionHouse.getInstance().getTransactionManager().getPrePurchasePlayers(auctionItem.getId()).forEach(player -> {
AuctionHouse.getInstance().getTransactionManager().removeAllRelatedPlayers(auctionItem.getId());
AuctionHouse.getTransactionManager().getPrePurchasePlayers(auctionItem.getId()).forEach(player -> {
AuctionHouse.getTransactionManager().removeAllRelatedPlayers(auctionItem.getId());
player.closeInventory();
});
@ -329,25 +339,37 @@ public class GUIConfirmPurchase extends AuctionBaseGUI {
private void transferFunds(Player from, double amount) {
double tax = Settings.TAX_ENABLED.getBoolean() ? (Settings.TAX_SALES_TAX_BUY_NOW_PERCENTAGE.getDouble() / 100) * amount : 0D;
AuctionAPI.getInstance().withdrawBalance(from, Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? amount + tax : amount) : Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? amount + tax : amount);
AuctionAPI.getInstance().depositBalance(Bukkit.getOfflinePlayer(this.auctionItem.getOwner()), Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? amount : amount - tax) : Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? amount : amount - tax, auctionItem.getItem(), from);
AuctionAPI.getInstance().withdrawBalance(from, Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? amount + tax : amount) : Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? amount + tax : amount, auctionItem);
AuctionAPI.getInstance().depositBalance(Bukkit.getOfflinePlayer(this.auctionItem.getOwner()), Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? amount : amount - tax) : Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? amount : amount - tax, auctionItem.getItem(), from, auctionItem);
}
private void sendMessages(GuiClickEvent e, AuctionedItem located, boolean overwritePrice, double price, int qtyOverride) {
double totalPrice = overwritePrice ? price : located.getBasePrice();
double tax = Settings.TAX_ENABLED.getBoolean() ? (Settings.TAX_SALES_TAX_BUY_NOW_PERCENTAGE.getDouble() / 100) * totalPrice : 0D;
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(e.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice - tax : totalPrice)).sendPrefixedMessage(e.player);
AuctionHouse.getInstance().getLocale().getMessage("general.bought_item").processPlaceholder("amount", qtyOverride).processPlaceholder("item", AuctionAPI.getInstance().getItemName(located.getItem())).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice - tax : totalPrice)).sendPrefixedMessage(e.player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(e.player, auctionItem.getCurrency().split("/")[0], auctionItem.getCurrency().split("/")[1]), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice - tax : totalPrice, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.sendPrefixedMessage(e.player);
AuctionHouse.getInstance().getLocale().getMessage("general.bought_item")
.processPlaceholder("amount", qtyOverride).processPlaceholder("item", AuctionAPI.getInstance().getItemName(located.getItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice - tax : totalPrice, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.sendPrefixedMessage(e.player);
if (Bukkit.getOfflinePlayer(located.getOwner()).isOnline()) {
AuctionHouse.getInstance().getLocale().getMessage("auction.itemsold")
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(located.getItem()))
.processPlaceholder("amount", qtyOverride)
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice : totalPrice - tax))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice : totalPrice - tax, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("buyer_name", e.player.getName())
.sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(Bukkit.getOfflinePlayer(located.getOwner())))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice : totalPrice - tax)).sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(Bukkit.getOfflinePlayer(located.getOwner()), auctionItem.getCurrency().split("/")[0], auctionItem.getCurrency().split("/")[1]), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice : totalPrice - tax, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer());
}
}
@ -362,10 +384,10 @@ public class GUIConfirmPurchase extends AuctionBaseGUI {
.name(Settings.GUI_CONFIRM_QTY_INFO_NAME.getString())
.lore(this.player, Replacer.replaceVariables(Settings.GUI_CONFIRM_QTY_INFO_LORE.getStringList(),
"original_stack_size", maxStackSize,
"original_stack_price", AuctionAPI.getInstance().formatNumber(auctionItem.getBasePrice()),
"price_per_item", AuctionAPI.getInstance().formatNumber(pricePerItem),
"original_stack_price", auctionItem.getFormattedBasePrice(),
"price_per_item", AuctionHouse.getAPI().getFinalizedCurrencyNumber(pricePerItem, auctionItem.getCurrency(), auctionItem.getCurrencyItem()),
"purchase_quantity", purchaseQuantity,
"purchase_price", AuctionAPI.getInstance().formatNumber(pricePerItem * purchaseQuantity)
"purchase_price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(pricePerItem * purchaseQuantity, auctionItem.getCurrency(), auctionItem.getCurrencyItem())
))
.make();
}

View File

@ -19,7 +19,6 @@
package ca.tweetzy.auctionhouse.guis.core;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.AuctionPayment;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
@ -32,15 +31,12 @@ import ca.tweetzy.core.gui.events.GuiClickEvent;
import ca.tweetzy.flight.utils.Common;
import ca.tweetzy.flight.utils.QuickItem;
import ca.tweetzy.flight.utils.messages.Titles;
import io.lumine.mythic.utils.time.Time;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import java.time.temporal.TemporalUnit;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -105,19 +101,23 @@ public class GUIActiveAuctions extends AuctionUpdatingPagedGUI<AuctionedItem> {
final OfflinePlayer oldBidder = Bukkit.getOfflinePlayer(item.getHighestBidder());
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(
oldBidder.getUniqueId(),
item.getCurrentPrice(),
item.getItem(),
AuctionHouse.getInstance().getLocale().getMessage("general.prefix").getMessage(),
PaymentReason.BID_RETURNED
PaymentReason.BID_RETURNED,
item.getCurrency(),
item.getCurrencyItem()
), null);
else
AuctionHouse.getCurrencyManager().deposit(oldBidder, item.getCurrentPrice());
if (oldBidder.isOnline())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(item.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder, item.getCurrency().split("/")[0], item.getCurrency().split("/")[1]), item.getCurrency(), item.getCurrencyItem()))
.processPlaceholder("price", item.getFormattedCurrentPrice())
.sendPrefixedMessage(oldBidder.getPlayer());
}
draw();
@ -152,7 +152,10 @@ public class GUIActiveAuctions extends AuctionUpdatingPagedGUI<AuctionedItem> {
}
AuctionHouse.getEconomy().withdrawPlayer(click.player, Settings.LISTING_PRIORITY_TIME_COST_PER_BOOST.getDouble());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(click.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.LISTING_PRIORITY_TIME_COST_PER_BOOST.getDouble())).sendPrefixedMessage(click.player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(click.player, item.getCurrency().split("/")[0], item.getCurrency().split("/")[1]), item.getCurrency(), item.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getNumberAsCurrency(Settings.LISTING_PRIORITY_TIME_COST_PER_BOOST.getDouble(), false))
.sendPrefixedMessage(click.player);
long newBoostTime = item.getPriorityExpiresAt() + (System.currentTimeMillis() + (1000L * Settings.LISTING_PRIORITY_TIME_PER_BOOST.getInt()));

View File

@ -40,6 +40,7 @@ import org.bukkit.inventory.meta.BlockStateMeta;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem> {
@ -198,11 +199,14 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
return;
}
if (!buyingQuantity) if (!AuctionHouse.getCurrencyManager().has(click.player, auctionItem.getBasePrice())) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(click.player);
return;
if (!buyingQuantity) {
if (!auctionItem.playerHasSufficientMoney(click.player, auctionItem.getBasePrice())) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(click.player);
return;
}
}
if (buyingQuantity) {
if (auctionItem.getBidStartingPrice() <= 0 || !Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean()) {
if (!Settings.ALLOW_PURCHASE_OF_SPECIFIC_QUANTITIES.getBoolean()) return;
@ -231,7 +235,7 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
cancelTask();
click.manager.showGUI(click.player, new GUIConfirmPurchase(this.auctionPlayer, auctionItem, false));
AuctionHouse.getInstance().getTransactionManager().addPrePurchase(click.player, auctionItem.getId());
AuctionHouse.getTransactionManager().addPrePurchase(click.player, auctionItem.getId());
}
return;
}
@ -255,7 +259,7 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
@Override
public void onExit(Player player) {
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIAuctionHouse(GUIAuctionHouse.this.auctionPlayer));
AuctionHouse.getGuiManager().showGUI(player, new GUIAuctionHouse(GUIAuctionHouse.this.auctionPlayer));
}
@Override
@ -286,7 +290,7 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
} else {
if (Settings.BID_MUST_BE_HIGHER_THAN_PREVIOUS.getBoolean()) {
click.manager.showGUI(click.player, new GUIAuctionHouse(GUIAuctionHouse.this.auctionPlayer));
AuctionHouse.getInstance().getLocale().getMessage("pricing.bidmusthigherthanprevious").processPlaceholder("current_bid", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice())).sendPrefixedMessage(click.player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.bidmusthigherthanprevious").processPlaceholder("current_bid", AuctionHouse.getAPI().getFinalizedCurrencyNumber(auctionItem.getCurrentPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem())).sendPrefixedMessage(click.player);
return true;
}
@ -298,9 +302,9 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
newBiddingAmount = Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(newBiddingAmount) : newBiddingAmount;
if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !AuctionHouse.getCurrencyManager().has(click.player, newBiddingAmount)) {
if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !auctionItem.playerHasSufficientMoney(click.player, newBiddingAmount)) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(click.player);
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIAuctionHouse(GUIAuctionHouse.this.auctionPlayer));
AuctionHouse.getGuiManager().showGUI(player, new GUIAuctionHouse(GUIAuctionHouse.this.auctionPlayer));
return true;
}
@ -321,7 +325,7 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
if (Settings.BIDDING_TAKES_MONEY.getBoolean()) {
final double oldBidAmount = auctionItem.getCurrentPrice();
if (!AuctionHouse.getCurrencyManager().has(click.player, newBiddingAmount)) {
if (!auctionItem.playerHasSufficientMoney(click.player, newBiddingAmount)) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(click.player);
return true;
}
@ -332,14 +336,22 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
if (!auctionItem.getHighestBidder().equals(auctionItem.getOwner())) {
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(oldBidder.getUniqueId(), oldBidAmount, auctionItem.getItem(), AuctionHouse.getInstance().getLocale().getMessage("general.prefix").getMessage(), PaymentReason.BID_RETURNED), null);
else AuctionHouse.getCurrencyManager().deposit(oldBidder, oldBidAmount);
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(oldBidder.getUniqueId(), oldBidAmount, auctionItem.getItem(), AuctionHouse.getInstance().getLocale().getMessage("general.prefix").getMessage(), PaymentReason.BID_RETURNED, auctionItem.getCurrency(), auctionItem.getCurrencyItem()), null);
else
AuctionHouse.getCurrencyManager().deposit(oldBidder, oldBidAmount, auctionItem.getCurrency(), auctionItem.getCurrencyItem());
if (oldBidder.isOnline())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(oldBidAmount)).sendPrefixedMessage(oldBidder.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder, auctionItem.getCurrency().split("/")[0], auctionItem.getCurrency().split("/")[1]), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(oldBidAmount, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.sendPrefixedMessage(oldBidder.getPlayer());
}
AuctionHouse.getCurrencyManager().withdraw(click.player, newBiddingAmount);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(click.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(newBiddingAmount)).sendPrefixedMessage(click.player);
AuctionHouse.getCurrencyManager().withdraw(click.player, newBiddingAmount, auctionItem.getCurrency(), auctionItem.getCurrencyItem());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(click.player, auctionItem.getCurrency().split("/")[0], auctionItem.getCurrency().split("/")[1]), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(newBiddingAmount, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.sendPrefixedMessage(click.player);
}
@ -360,11 +372,11 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
}
if (owner.isOnline()) {
AuctionHouse.getInstance().getLocale().getMessage("auction.placedbid").processPlaceholder("player", click.player.getName()).processPlaceholder("player_displayname", AuctionAPI.getInstance().getDisplayName(click.player)).processPlaceholder("amount", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice())).processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack)).sendPrefixedMessage(owner.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("auction.placedbid").processPlaceholder("player", click.player.getName()).processPlaceholder("player_displayname", AuctionAPI.getInstance().getDisplayName(click.player)).processPlaceholder("amount", AuctionHouse.getAPI().getFinalizedCurrencyNumber(auctionItem.getCurrentPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem())).processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack)).sendPrefixedMessage(owner.getPlayer());
}
if (Settings.BROADCAST_AUCTION_BID.getBoolean()) {
Bukkit.getOnlinePlayers().forEach(player -> AuctionHouse.getInstance().getLocale().getMessage("auction.broadcast.bid").processPlaceholder("player", click.player.getName()).processPlaceholder("player_displayname", AuctionAPI.getInstance().getDisplayName(click.player)).processPlaceholder("amount", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice())).processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack)).sendPrefixedMessage(player));
Bukkit.getOnlinePlayers().forEach(player -> AuctionHouse.getInstance().getLocale().getMessage("auction.broadcast.bid").processPlaceholder("player", click.player.getName()).processPlaceholder("player_displayname", AuctionAPI.getInstance().getDisplayName(click.player)).processPlaceholder("amount", AuctionHouse.getAPI().getFinalizedCurrencyNumber(auctionItem.getCurrentPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem())).processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack)).sendPrefixedMessage(player));
}
click.manager.showGUI(click.player, new GUIAuctionHouse(GUIAuctionHouse.this.auctionPlayer));
@ -432,7 +444,7 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
setButton(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_SLOT.getInt(), QuickItem
.of(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_ITEM.getString())
.name(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_NAME.getString())
.lore(this.player, Replacer.replaceVariables(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_LORE.getStringList(), "active_player_auctions", auctionPlayer.getItems(false).size(), "player_balance", Settings.USE_SHORT_NUMBERS_ON_PLAYER_BALANCE.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(AuctionHouse.getCurrencyManager().getBalance(auctionPlayer.getPlayer())) : AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(auctionPlayer.getPlayer())))).make(), e -> {
.lore(this.player, Replacer.replaceVariables(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_LORE.getStringList(), "active_player_auctions", auctionPlayer.getItems(false).size(), "player_balance", AuctionHouse.getAPI().getNumberAsCurrency(AuctionHouse.getCurrencyManager().getBalance(auctionPlayer.getPlayer())))).make(), e -> {
cancelTask();
e.manager.showGUI(e.player, new GUIActiveAuctions(this.auctionPlayer));
@ -477,7 +489,7 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
.lore(this.player, Settings.GUI_AUCTION_HOUSE_ITEMS_LIST_ITEM_LORE.getStringList())
.make(), e -> {
if (AuctionHouse.getInstance().getBanManager().isStillBanned(e.player, BanType.EVERYTHING, BanType.SELL)) return;
if (AuctionHouse.getBanManager().isStillBanned(e.player, BanType.EVERYTHING, BanType.SELL)) return;
// using this will ignore the "SELL_MENU_REQUIRES_USER_TO_HOLD_ITEM" setting
if (FloodGateHook.isFloodGateUser(e.player)) {
@ -492,25 +504,25 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
if (Settings.SELL_MENU_SKIPS_TYPE_SELECTION.getBoolean()) {
if (Settings.FORCE_AUCTION_USAGE.getBoolean()) {
cancelTask();
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.AUCTION));
AuctionHouse.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.AUCTION));
return;
}
if (!Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean()) {
cancelTask();
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.BIN));
AuctionHouse.getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.BIN));
return;
}
cancelTask();
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellListingType(this.auctionPlayer, selected -> {
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellPlaceItem(this.auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected));
AuctionHouse.getGuiManager().showGUI(player, new GUISellListingType(this.auctionPlayer, selected -> {
AuctionHouse.getGuiManager().showGUI(player, new GUISellPlaceItem(this.auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected));
}));
} else {
cancelTask();
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellListingType(this.auctionPlayer, selected -> {
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellPlaceItem(this.auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected));
AuctionHouse.getGuiManager().showGUI(player, new GUISellListingType(this.auctionPlayer, selected -> {
AuctionHouse.getGuiManager().showGUI(player, new GUISellPlaceItem(this.auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected));
}));
}
@ -536,12 +548,12 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
if (Settings.GUI_REFRESH_BTN_ENABLED.getBoolean()) {
setButton(Settings.GUI_REFRESH_BTN_SLOT.getInt(), getRefreshButton(), ClickType.LEFT, e -> {
if (Settings.USE_REFRESH_COOL_DOWN.getBoolean()) {
if (AuctionHouse.getInstance().getAuctionPlayerManager().getCooldowns().containsKey(this.auctionPlayer.getPlayer().getUniqueId())) {
if (AuctionHouse.getInstance().getAuctionPlayerManager().getCooldowns().get(this.auctionPlayer.getPlayer().getUniqueId()) > System.currentTimeMillis()) {
if (AuctionHouse.getAuctionPlayerManager().getCooldowns().containsKey(this.auctionPlayer.getPlayer().getUniqueId())) {
if (AuctionHouse.getAuctionPlayerManager().getCooldowns().get(this.auctionPlayer.getPlayer().getUniqueId()) > System.currentTimeMillis()) {
return;
}
}
AuctionHouse.getInstance().getAuctionPlayerManager().addCooldown(this.auctionPlayer.getPlayer().getUniqueId());
AuctionHouse.getAuctionPlayerManager().addCooldown(this.auctionPlayer.getPlayer().getUniqueId());
}
cancelTask();
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
@ -674,10 +686,15 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI<AuctionedItem
//======================================================================================================//
private void updatePlayerFilter(AuctionPlayer player) {
AuctionHouse.getInstance().getDataManager().updateAuctionPlayer(player, (error, success) -> {
AuctionHouse.getDataManager().updateAuctionPlayer(player, (error, success) -> {
if (error == null && success)
if (!Settings.DISABLE_PROFILE_UPDATE_MSG.getBoolean()) AuctionHouse.getInstance().getLogger().info("Updating profile for player: " + player.getPlayer().getName());
});
}
@Override
protected List<Integer> fillSlots() {
return Settings.GUI_AUCTION_HOUSE_FILL_SLOTS.getIntegerList();
}
}

View File

@ -66,7 +66,7 @@ public class GUIPaymentCollection extends AuctionPagedGUI<AuctionPayment> {
protected ItemStack makeDisplayItem(AuctionPayment payment) {
return QuickItem
.of(Settings.GUI_PAYMENT_COLLECTION_PAYMENT_ITEM.getString())
.name(Replacer.replaceVariables(Settings.GUI_PAYMENT_COLLECTION_PAYMENT_NAME.getString(), "payment_amount", AuctionAPI.getInstance().formatNumber(payment.getAmount())))
.name(Replacer.replaceVariables(Settings.GUI_PAYMENT_COLLECTION_PAYMENT_NAME.getString(), "payment_amount", AuctionHouse.getAPI().getNumberAsCurrency(payment.getAmount(), false)))
.lore(this.player, Replacer.replaceVariables(Settings.GUI_PAYMENT_COLLECTION_PAYMENT_LORE.getStringList(),
"item_name", AuctionAPI.getInstance().getItemName(payment.getItem()),
"from_name", payment.getFromName(),

View File

@ -118,7 +118,7 @@ public class GUIBid extends AuctionBaseGUI {
double newBiddingAmount = 0;
if (Settings.USE_REALISTIC_BIDDING.getBoolean()) {
if (value < auctionItem.getCurrentPrice() + auctionItem.getBidIncrementPrice()) {
AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice() + auctionItem.getBidIncrementPrice())).sendPrefixedMessage(e.player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(auctionItem.getCurrentPrice() + auctionItem.getBidIncrementPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem())).sendPrefixedMessage(e.player);
return false;
}
@ -127,7 +127,7 @@ public class GUIBid extends AuctionBaseGUI {
} else {
if (Settings.BID_MUST_BE_HIGHER_THAN_PREVIOUS.getBoolean()) {
e.manager.showGUI(e.player, new GUIAuctionHouse(GUIBid.this.auctionPlayer));
AuctionHouse.getInstance().getLocale().getMessage("pricing.bidmusthigherthanprevious").processPlaceholder("current_bid", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice())).sendPrefixedMessage(e.player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.bidmusthigherthanprevious").processPlaceholder("current_bid", AuctionHouse.getAPI().getFinalizedCurrencyNumber(auctionItem.getCurrentPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem())).sendPrefixedMessage(e.player);
return true;
}
@ -135,7 +135,7 @@ public class GUIBid extends AuctionBaseGUI {
}
} else {
if (value < auctionItem.getBidIncrementPrice()) {
AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(auctionItem.getBidIncrementPrice())).sendPrefixedMessage(e.player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(auctionItem.getBidIncrementPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem())).sendPrefixedMessage(e.player);
return false;
}
@ -177,21 +177,29 @@ public class GUIBid extends AuctionBaseGUI {
if (!auctionItem.getHighestBidder().equals(auctionItem.getOwner())) {
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(
oldBidder.getUniqueId(),
oldBidAmount,
auctionItem.getItem(),
AuctionHouse.getInstance().getLocale().getMessage("general.prefix").getMessage(),
PaymentReason.BID_RETURNED
PaymentReason.BID_RETURNED,
auctionItem.getCurrency(),
auctionItem.getCurrencyItem()
), null);
else
AuctionHouse.getCurrencyManager().deposit(oldBidder, oldBidAmount);
AuctionHouse.getCurrencyManager().deposit(oldBidder, oldBidAmount, auctionItem.getCurrency(), auctionItem.getCurrencyItem());
if (oldBidder.isOnline())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(oldBidAmount)).sendPrefixedMessage(oldBidder.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(oldBidder, auctionItem.getCurrency().split("/")[0], auctionItem.getCurrency().split("/")[1]), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(oldBidAmount, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.sendPrefixedMessage(oldBidder.getPlayer());
}
AuctionHouse.getCurrencyManager().withdraw(e.player, newBiddingAmount);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(e.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(newBiddingAmount)).sendPrefixedMessage(e.player);
AuctionHouse.getCurrencyManager().withdraw(e.player, newBiddingAmount, auctionItem.getCurrency(), auctionItem.getCurrencyItem());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove")
.processPlaceholder("player_balance", AuctionHouse.getAPI().getFinalizedCurrencyNumber(AuctionHouse.getCurrencyManager().getBalance(e.player, auctionItem.getCurrency().split("/")[0], auctionItem.getCurrency().split("/")[1]), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(newBiddingAmount, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.sendPrefixedMessage(e.player);
}
@ -219,7 +227,7 @@ public class GUIBid extends AuctionBaseGUI {
AuctionHouse.getInstance().getLocale().getMessage("auction.placedbid")
.processPlaceholder("player", e.player.getName())
.processPlaceholder("player_displayname", AuctionAPI.getInstance().getDisplayName(e.player))
.processPlaceholder("amount", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice()))
.processPlaceholder("amount", AuctionHouse.getAPI().getFinalizedCurrencyNumber(auctionItem.getCurrentPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack))
.sendPrefixedMessage(owner.getPlayer());
}
@ -228,7 +236,7 @@ public class GUIBid extends AuctionBaseGUI {
Bukkit.getOnlinePlayers().forEach(player -> AuctionHouse.getInstance().getLocale().getMessage("auction.broadcast.bid")
.processPlaceholder("player", e.player.getName())
.processPlaceholder("player_displayname", AuctionAPI.getInstance().getDisplayName(e.player))
.processPlaceholder("amount", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice()))
.processPlaceholder("amount", AuctionHouse.getAPI().getFinalizedCurrencyNumber(auctionItem.getCurrentPrice(), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack))
.sendPrefixedMessage(player));
}

View File

@ -0,0 +1,109 @@
package ca.tweetzy.auctionhouse.guis.selector;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
import ca.tweetzy.auctionhouse.api.currency.IconableCurrency;
import ca.tweetzy.auctionhouse.guis.AuctionPagedGUI;
import ca.tweetzy.auctionhouse.impl.currency.FundsCurrency;
import ca.tweetzy.auctionhouse.impl.currency.ItemCurrency;
import ca.tweetzy.auctionhouse.impl.currency.UltraEconomyCurrency;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.gui.Gui;
import ca.tweetzy.core.gui.events.GuiClickEvent;
import ca.tweetzy.flight.comp.enums.CompMaterial;
import ca.tweetzy.flight.gui.helper.InventoryBorder;
import ca.tweetzy.flight.utils.QuickItem;
import ca.tweetzy.flight.utils.Replacer;
import lombok.NonNull;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
public final class GUICurrencyPicker extends AuctionPagedGUI<AbstractCurrency> {
private final BiConsumer<AbstractCurrency, ItemStack> selectedCurrency;
public GUICurrencyPicker(final Gui parent, @NonNull final Player player, @NonNull final BiConsumer<AbstractCurrency, ItemStack> selectedCurrency) {
super(parent, player, Settings.GUI_CURRENCY_PICKER_TITLE.getString(), 6, AuctionHouse.getCurrencyManager().getManagerContent().stream().filter(currency -> !currency.getOwningPlugin().equalsIgnoreCase("auctionhouse")).collect(Collectors.toList()));
this.selectedCurrency = selectedCurrency;
setAcceptsItems(true);
setAllowClose(false);
draw();
}
@Override
protected void drawFixed() {
applyBackExit();
// custom item
setButton(getRows() - 1, 4, QuickItem
.of(CompMaterial.HOPPER)
.name(Settings.GUI_CURRENCY_PICKER_ITEMS_CUSTOM_NAME.getString())
.lore(Settings.GUI_CURRENCY_PICKER_ITEMS_CUSTOM_LORE.getStringList()).make(), click -> {
if (click.clickType == ClickType.RIGHT) {
click.manager.showGUI(click.player, new GUIMaterialPicker(null, click.player, null, item -> {
if (item != null) {
this.selectedCurrency.accept(new ItemCurrency(), item);
}
}));
}
if (click.clickType == ClickType.LEFT) {
final ItemStack cursor = click.cursor;
if (cursor != null && cursor.getType() != CompMaterial.AIR.parseMaterial()) {
final ItemStack currency = cursor.clone();
currency.setAmount(1);
setAllowClose(true);
this.selectedCurrency.accept(new ItemCurrency(), currency);
}
}
});
}
@Override
protected ItemStack makeDisplayItem(AbstractCurrency currency) {
QuickItem quickItem = QuickItem.of(CompMaterial.PAPER);
if (currency instanceof IconableCurrency) {
IconableCurrency iconableCurrency = (IconableCurrency) currency;
quickItem = QuickItem.of(iconableCurrency.getIcon());
}
if (currency instanceof FundsCurrency) {
FundsCurrency fundsCurrency = (FundsCurrency) currency;
quickItem.name(fundsCurrency.getDisplayName());
} else if (currency instanceof UltraEconomyCurrency) {
UltraEconomyCurrency ultraEconomyCurrency = (UltraEconomyCurrency) currency;
quickItem.name(ultraEconomyCurrency.getDisplayName());
} else {
quickItem.name(currency.getCurrencyName().equalsIgnoreCase("vault") ? "&a" + Settings.CURRENCY_VAULT_SYMBOL.getString() : "&e" + currency.getCurrencyName());
}
quickItem.lore(Replacer.replaceVariables(Arrays.asList(
"&7Owning Plugin&f: &e%currency_owning_plugin%",
"",
"&a&lLeft Click &7to select this currency"
), "currency_owning_plugin", currency.getOwningPlugin()));
return quickItem.make();
}
@Override
protected void onClick(AbstractCurrency currency, GuiClickEvent event) {
setAllowClose(true);
this.selectedCurrency.accept(currency, null);
}
@Override
protected List<Integer> fillSlots() {
return InventoryBorder.getInsideBorders(6);
}
}

View File

@ -0,0 +1,117 @@
package ca.tweetzy.auctionhouse.guis.selector;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.guis.AuctionPagedGUI;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.gui.Gui;
import ca.tweetzy.core.gui.events.GuiClickEvent;
import ca.tweetzy.flight.comp.enums.CompMaterial;
import ca.tweetzy.flight.gui.helper.InventoryBorder;
import ca.tweetzy.flight.gui.helper.InventorySafeMaterials;
import ca.tweetzy.flight.utils.ChatUtil;
import ca.tweetzy.flight.utils.Common;
import ca.tweetzy.flight.utils.Filterer;
import ca.tweetzy.flight.utils.QuickItem;
import ca.tweetzy.flight.utils.input.TitleInput;
import lombok.NonNull;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
public final class GUIMaterialPicker extends AuctionPagedGUI<ItemStack> {
private final Gui parent;
private final String searchQuery;
private final Consumer<ItemStack> selected;
public GUIMaterialPicker(final Gui parent, Player player, final String searchQuery, @NonNull final Consumer<ItemStack> selected) {
super(parent, player, Settings.GUI_MATERIAL_PICKER_TITLE.getString(), 6, new ArrayList<>());
setAcceptsItems(true);
setAllowClose(false);
this.searchQuery = searchQuery;
this.selected = selected;
this.parent = parent;
draw();
}
@Override
protected void prePopulate() {
final List<ItemStack> validMaterials = InventorySafeMaterials.get().stream().map(CompMaterial::parseItem).collect(Collectors.toList());
this.items.addAll(validMaterials);
if (this.searchQuery != null) {
this.items = this.items.stream().filter(mat -> Filterer.searchByItemInfo(this.searchQuery, mat)).collect(Collectors.toList());
}
}
@Override
protected void drawFixed() {
setButton(5, 4, buildSearchButton(), click -> {
click.gui.exit();
new TitleInput(
AuctionHouse.getInstance(),
click.player,
Common.colorize(AuctionHouse.getInstance().getLocale().getMessage("titles.material search.title").getMessage()),
Common.colorize(AuctionHouse.getInstance().getLocale().getMessage("titles.material search.subtitle").getMessage())
) {
@Override
public boolean onResult(String string) {
if (string.isEmpty()) return false;
click.manager.showGUI(click.player, new GUIMaterialPicker(GUIMaterialPicker.this.parent, click.player, string, GUIMaterialPicker.this.selected));
return true;
}
@Override
public void onExit(Player player) {
click.manager.showGUI(click.player, GUIMaterialPicker.this);
}
};
});
if (this.searchQuery != null)
setButton(5, 7, buildResetButton(), click -> click.manager.showGUI(click.player, new GUIMaterialPicker(this.parent, click.player, this.searchQuery, this.selected)));
applyBackExit(this.parent);
}
@Override
protected ItemStack makeDisplayItem(ItemStack item) {
return QuickItem.of(item)
.name("&e&l" + ChatUtil.capitalizeFully(item.getType()))
.lore(this.player, Settings.GUI_MATERIAL_PICKER_ITEMS_MATERIAL_LORE.getStringList())
.make();
}
protected ItemStack buildSearchButton() {
return QuickItem.of(CompMaterial.OAK_SIGN)
.name(Settings.GUI_MATERIAL_PICKER_ITEMS_SEARCH_NAME.getString())
.lore(this.player, Settings.GUI_MATERIAL_PICKER_ITEMS_SEARCH_LORE.getStringList())
.make();
}
protected ItemStack buildResetButton() {
return QuickItem
.of(CompMaterial.LAVA_BUCKET)
.name(Settings.GUI_MATERIAL_PICKER_ITEMS_RESET_NAME.getString())
.lore(this.player, Settings.GUI_MATERIAL_PICKER_ITEMS_RESET_LORE.getStringList())
.make();
}
@Override
protected void onClick(ItemStack object, GuiClickEvent clickEvent) {
this.selected.accept(object);
}
@Override
protected List<Integer> fillSlots() {
return InventoryBorder.getInsideBorders(5);
}
}

View File

@ -106,7 +106,7 @@ public final class GUIRequestItem extends AuctionBaseGUI {
setButton(3, 6, QuickItem
.of(Settings.GUI_REQUEST_ITEMS_PRICE_ITEM.getString())
.name(Settings.GUI_REQUEST_ITEMS_PRICE_NAME.getString())
.lore(this.player, Replacer.replaceVariables(Settings.GUI_REQUEST_ITEMS_PRICE_LORE.getStringList(), "request_price", AuctionAPI.getInstance().formatNumber(price)))
.lore(this.player, Replacer.replaceVariables(Settings.GUI_REQUEST_ITEMS_PRICE_LORE.getStringList(), "request_price", AuctionHouse.getAPI().getNumberAsCurrency(price, false)))
.make(), click -> {
click.gui.exit();

View File

@ -28,6 +28,7 @@ import ca.tweetzy.auctionhouse.auction.enums.AuctionStackType;
import ca.tweetzy.auctionhouse.guis.AuctionBaseGUI;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIListingConfirm;
import ca.tweetzy.auctionhouse.guis.core.GUIAuctionHouse;
import ca.tweetzy.auctionhouse.guis.selector.GUICurrencyPicker;
import ca.tweetzy.auctionhouse.helpers.AuctionCreator;
import ca.tweetzy.auctionhouse.helpers.BundleUtil;
import ca.tweetzy.auctionhouse.helpers.input.TitleInput;
@ -56,7 +57,10 @@ public final class GUISellAuction extends AuctionBaseGUI {
private final long listingTime;
private boolean allowBuyNow;
public GUISellAuction(@NonNull final AuctionPlayer auctionPlayer, final double binPrice, final double startingBid, final double bidIncrement, final long listingTime, final boolean allowBuyNow) {
private String currency;
private ItemStack currencyItem;
public GUISellAuction(@NonNull final AuctionPlayer auctionPlayer, final double binPrice, final double startingBid, final double bidIncrement, final long listingTime, final boolean allowBuyNow, String currency, ItemStack currencyItem) {
super(null, auctionPlayer.getPlayer(), Settings.GUI_SELL_AUCTION_TITLE.getString(), 6);
this.auctionPlayer = auctionPlayer;
this.binPrice = binPrice;
@ -64,6 +68,8 @@ public final class GUISellAuction extends AuctionBaseGUI {
this.bidIncrement = bidIncrement;
this.listingTime = listingTime;
this.allowBuyNow = allowBuyNow;
this.currencyItem = currencyItem;
this.currency = currency;
setDefaultItem(QuickItem.bg(QuickItem.of(Settings.GUI_SELL_AUCTION_BG_ITEM.getString()).make()));
@ -83,6 +89,10 @@ public final class GUISellAuction extends AuctionBaseGUI {
draw();
}
public GUISellAuction(@NonNull final AuctionPlayer auctionPlayer, final double binPrice, final double startingBid, final double bidIncrement, final long listingTime, final boolean allowBuyNow) {
this(auctionPlayer, binPrice, startingBid, bidIncrement, listingTime, allowBuyNow, null, null);
}
@Override
protected void draw() {
reset();
@ -93,6 +103,22 @@ public final class GUISellAuction extends AuctionBaseGUI {
click.manager.showGUI(click.player, new GUISellPlaceItem(this.auctionPlayer, BundleUtil.isBundledItem(this.auctionPlayer.getItemBeingListed()) ? GUISellPlaceItem.ViewMode.BUNDLE_ITEM : GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.BIN));
});
if (Settings.CURRENCY_ALLOW_PICK.getBoolean())
setButton(getRows() - 1, 8, QuickItem
.of(Settings.GUI_SELL_ITEM_ITEM_CURRENCY_ITEM.getString())
.name(Settings.GUI_SELL_ITEM_ITEM_CURRENCY_NAME.getString())
.lore(this.player, Settings.GUI_SELL_ITEM_ITEM_CURRENCY_LORE.getStringList())
.make(), click -> click.manager.showGUI(click.player, new GUICurrencyPicker(this, click.player, (currency, itemCurrency) -> {
this.currency = currency.getStoreableName();
if (itemCurrency != null)
this.currencyItem = itemCurrency;
click.manager.showGUI(click.player, new GUISellAuction(this.auctionPlayer, this.binPrice, this.startingBid, this.bidIncrement, this.listingTime, this.allowBuyNow, this.currency, this.currencyItem));
})));
if (Settings.ALLOW_PLAYERS_TO_DEFINE_AUCTION_TIME.getBoolean()) {
final long[] times = AuctionAPI.getInstance().getRemainingTimeValues(this.listingTime);
@ -134,7 +160,9 @@ public final class GUISellAuction extends AuctionBaseGUI {
GUISellAuction.this.startingBid,
GUISellAuction.this.bidIncrement,
AuctionAPI.toTicks(string),
GUISellAuction.this.allowBuyNow
GUISellAuction.this.allowBuyNow,
GUISellAuction.this.currency,
GUISellAuction.this.currencyItem
));
return true;
}
@ -152,7 +180,7 @@ public final class GUISellAuction extends AuctionBaseGUI {
setButton(3, 4, QuickItem
.of(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_PRICE_ITEM.getString())
.name(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_PRICE_NAME.getString())
.lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_PRICE_LORE.getStringList(), "listing_bin_price", AuctionAPI.getInstance().formatNumber(binPrice)))
.lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_PRICE_LORE.getStringList(), "listing_bin_price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(binPrice, this.currency, this.currencyItem)))
.make(), click -> {
click.gui.exit();
@ -190,7 +218,9 @@ public final class GUISellAuction extends AuctionBaseGUI {
GUISellAuction.this.startingBid,
GUISellAuction.this.bidIncrement,
GUISellAuction.this.listingTime,
GUISellAuction.this.allowBuyNow
GUISellAuction.this.allowBuyNow,
GUISellAuction.this.currency,
GUISellAuction.this.currencyItem
));
return true;
@ -201,7 +231,7 @@ public final class GUISellAuction extends AuctionBaseGUI {
setButton(3, 3, QuickItem
.of(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_STARTING_PRICE_ITEM.getString())
.name(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_STARTING_PRICE_NAME.getString())
.lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_STARTING_PRICE_LORE.getStringList(), "listing_start_price", AuctionAPI.getInstance().formatNumber(startingBid)))
.lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_STARTING_PRICE_LORE.getStringList(), "listing_start_price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(startingBid, this.currency, this.currencyItem)))
.make(), click -> {
click.gui.exit();
@ -230,7 +260,7 @@ public final class GUISellAuction extends AuctionBaseGUI {
if (Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() && GUISellAuction.this.allowBuyNow)
if (Settings.BASE_PRICE_MUST_BE_HIGHER_THAN_BID_START.getBoolean() && listingAmount >= GUISellAuction.this.binPrice) {
// listingAmount = GUISellAuction.this.binPrice / 2 <= 0 ? Settings.MIN_AUCTION_START_PRICE.getDouble() : GUISellAuction.this.binPrice / 2;
AuctionHouse.getInstance().getLocale().getMessage("pricing.startingpricetoohigh").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(GUISellAuction.this.binPrice)).sendPrefixedMessage(player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.startingpricetoohigh").processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(GUISellAuction.this.binPrice, GUISellAuction.this.currency, GUISellAuction.this.currencyItem)).sendPrefixedMessage(player);
return false;
}
@ -248,7 +278,9 @@ public final class GUISellAuction extends AuctionBaseGUI {
listingAmount,
GUISellAuction.this.bidIncrement,
GUISellAuction.this.listingTime,
GUISellAuction.this.allowBuyNow
GUISellAuction.this.allowBuyNow,
GUISellAuction.this.currency,
GUISellAuction.this.currencyItem
));
return true;
@ -259,7 +291,7 @@ public final class GUISellAuction extends AuctionBaseGUI {
setButton(3, 5, QuickItem
.of(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_INCREMENT_PRICE_ITEM.getString())
.name(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_INCREMENT_PRICE_NAME.getString())
.lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_INCREMENT_PRICE_LORE.getStringList(), "listing_increment_price", AuctionAPI.getInstance().formatNumber(bidIncrement)))
.lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_INCREMENT_PRICE_LORE.getStringList(), "listing_increment_price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(bidIncrement, this.currency, this.currencyItem)))
.make(), click -> {
click.gui.exit();
@ -297,7 +329,9 @@ public final class GUISellAuction extends AuctionBaseGUI {
GUISellAuction.this.startingBid,
listingAmount,
GUISellAuction.this.listingTime,
GUISellAuction.this.allowBuyNow
GUISellAuction.this.allowBuyNow,
GUISellAuction.this.currency,
GUISellAuction.this.currencyItem
));
return true;
@ -378,7 +412,7 @@ public final class GUISellAuction extends AuctionBaseGUI {
}
private AuctionedItem createListingItem() {
return new AuctionedItem(
AuctionedItem auctionedItem = new AuctionedItem(
UUID.randomUUID(),
auctionPlayer.getUuid(),
auctionPlayer.getUuid(),
@ -393,5 +427,12 @@ public final class GUISellAuction extends AuctionBaseGUI {
true, false,
System.currentTimeMillis() + (this.listingTime * 1000L)
);
if (this.currency != null)
auctionedItem.setCurrency(this.currency);
auctionedItem.setCurrencyItem(this.currencyItem);
return auctionedItem;
}
}

View File

@ -28,6 +28,7 @@ import ca.tweetzy.auctionhouse.auction.enums.AuctionStackType;
import ca.tweetzy.auctionhouse.guis.AuctionBaseGUI;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIListingConfirm;
import ca.tweetzy.auctionhouse.guis.core.GUIAuctionHouse;
import ca.tweetzy.auctionhouse.guis.selector.GUICurrencyPicker;
import ca.tweetzy.auctionhouse.helpers.AuctionCreator;
import ca.tweetzy.auctionhouse.helpers.BundleUtil;
import ca.tweetzy.auctionhouse.helpers.input.TitleInput;
@ -54,12 +55,18 @@ public final class GUISellBin extends AuctionBaseGUI {
private final long listingTime;
private boolean allowPartialBuy;
public GUISellBin(@NonNull final AuctionPlayer auctionPlayer, final double listingPrice, final long listingTime, boolean allowPartialBuy) {
private String currency;
private ItemStack currencyItem;
public GUISellBin(@NonNull final AuctionPlayer auctionPlayer, final double listingPrice, final long listingTime, boolean allowPartialBuy, String currency, ItemStack currencyItem) {
super(null, auctionPlayer.getPlayer(), Settings.GUI_SELL_BIN_TITLE.getString(), 6);
this.auctionPlayer = auctionPlayer;
this.listingPrice = listingPrice;
this.listingTime = listingTime;
this.allowPartialBuy = allowPartialBuy;
this.currencyItem = currencyItem;
this.currency = currency;
setDefaultItem(QuickItem.bg(QuickItem.of(Settings.GUI_SELL_BIN_BG_ITEM.getString()).make()));
setOnClose(close -> {
@ -79,6 +86,10 @@ public final class GUISellBin extends AuctionBaseGUI {
draw();
}
public GUISellBin(@NonNull final AuctionPlayer auctionPlayer, final double listingPrice, final long listingTime, boolean allowPartialBuy) {
this(auctionPlayer, listingPrice, listingTime, allowPartialBuy, null, null);
}
@Override
protected void draw() {
reset();
@ -88,6 +99,21 @@ public final class GUISellBin extends AuctionBaseGUI {
click.manager.showGUI(click.player, new GUISellPlaceItem(this.auctionPlayer, BundleUtil.isBundledItem(this.auctionPlayer.getItemBeingListed()) ? GUISellPlaceItem.ViewMode.BUNDLE_ITEM : GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.BIN));
});
if (Settings.CURRENCY_ALLOW_PICK.getBoolean())
setButton(getRows() - 1, 8, QuickItem
.of(Settings.GUI_SELL_ITEM_ITEM_CURRENCY_ITEM.getString())
.name(Settings.GUI_SELL_ITEM_ITEM_CURRENCY_NAME.getString())
.lore(this.player, Settings.GUI_SELL_ITEM_ITEM_CURRENCY_LORE.getStringList())
.make(), click -> click.manager.showGUI(click.player, new GUICurrencyPicker(this, click.player, (currency, itemCurrency) -> {
this.currency = currency.getStoreableName();
if (itemCurrency != null)
this.currencyItem = itemCurrency;
click.manager.showGUI(click.player, new GUISellBin(this.auctionPlayer, this.listingPrice, this.listingTime, this.allowPartialBuy, this.currency, this.currencyItem));
})));
if (Settings.ALLOW_PLAYERS_TO_DEFINE_AUCTION_TIME.getBoolean()) {
final long[] times = AuctionAPI.getInstance().getRemainingTimeValues(this.listingTime);
@ -131,10 +157,11 @@ public final class GUISellBin extends AuctionBaseGUI {
});
}
setButton(3, 4, QuickItem
.of(Settings.GUI_SELL_BIN_ITEM_ITEMS_PRICE_ITEM.getString())
.name(Settings.GUI_SELL_BIN_ITEM_ITEMS_PRICE_NAME.getString())
.lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_BIN_ITEM_ITEMS_PRICE_LORE.getStringList(), "listing_bin_price", AuctionAPI.getInstance().formatNumber(listingPrice)))
.lore(this.player, Replacer.replaceVariables(Settings.GUI_SELL_BIN_ITEM_ITEMS_PRICE_LORE.getStringList(), "listing_bin_price", AuctionHouse.getAPI().getNumberAsCurrency(listingPrice)))
.make(), click -> {
click.gui.exit();
@ -163,7 +190,7 @@ public final class GUISellBin extends AuctionBaseGUI {
if (listingAmount < Settings.MIN_AUCTION_PRICE.getDouble()) listingAmount = Settings.MIN_AUCTION_PRICE.getDouble();
if (listingAmount > Settings.MAX_AUCTION_PRICE.getDouble()) listingAmount = Settings.MAX_AUCTION_PRICE.getDouble();
click.manager.showGUI(click.player, new GUISellBin(GUISellBin.this.auctionPlayer, listingAmount, GUISellBin.this.listingTime, GUISellBin.this.allowPartialBuy));
click.manager.showGUI(click.player, new GUISellBin(GUISellBin.this.auctionPlayer, listingAmount, GUISellBin.this.listingTime, GUISellBin.this.allowPartialBuy, GUISellBin.this.currency, GUISellBin.this.currencyItem));
return true;
}
@ -236,6 +263,12 @@ public final class GUISellBin extends AuctionBaseGUI {
final AuctionedItem item = new AuctionedItem(UUID.randomUUID(), auctionPlayer.getUuid(), auctionPlayer.getUuid(), auctionPlayer.getPlayer().getName(), auctionPlayer.getPlayer().getName(), MaterialCategorizer.getMaterialCategory(this.auctionPlayer.getItemBeingListed()), this.auctionPlayer.getItemBeingListed(), this.listingPrice, 0, 0, this.listingPrice, false, false, System.currentTimeMillis() + (this.listingTime * 1000L));
item.setAllowPartialBuy(this.allowPartialBuy);
if (this.currency != null)
item.setCurrency(this.currency);
item.setCurrencyItem(this.currencyItem);
return item;
}
}

View File

@ -82,7 +82,7 @@ public final class GUIStatisticLeaderboard extends AuctionPagedGUI<Pair<UUID, Do
.lore(this.player, Replacer.replaceVariables(Settings.GUI_STATS_LEADERBOARD_ITEMS_PLAYER_LORE.getStringList(),
"player_name", targetUser.getName() == null ? "&e&lUsername not found" : targetUser.getName(),
"auction_statistic_name", statisticType.getTranslatedType(),
"auction_statistic_value", AuctionAPI.getInstance().formatNumber(entry.getSecond())
"auction_statistic_value", AuctionHouse.getAPI().getNumberAsCurrency(entry.getSecond())
)).make();
}

View File

@ -87,7 +87,7 @@ public class GUITransactionView extends AuctionBaseGUI {
"transaction_id", transaction.getId().toString(),
"sale_type", transaction.getAuctionSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM ? AuctionHouse.getInstance().getLocale().getMessage("transaction.sale_type.bid_won").getMessage() : AuctionHouse.getInstance().getLocale().getMessage("transaction.sale_type.immediate_buy").getMessage(),
"transaction_date", AuctionAPI.getInstance().convertMillisToDate(transaction.getTransactionTime()),
"final_price", AuctionAPI.getInstance().formatNumber(transaction.getFinalPrice()),
"final_price", AuctionHouse.getAPI().getNumberAsCurrency(transaction.getFinalPrice()),
"item_name", AuctionAPI.getInstance().getItemName(transaction.getItem())
))
.make());

View File

@ -84,37 +84,38 @@ public final class AuctionCreator {
if (!auctionItem.isRequest())
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);
instance.getLocale().getMessage("pricing.minitemprice")
.processPlaceholder("price", AuctionHouse.getAPI().getNumberAsCurrency(AuctionHouse.getMinItemPriceManager().getMinPrice(auctionItem.getItem()).getPrice(), false))
.sendPrefixedMessage(seller);
result.accept(auctionItem, MINIMUM_PRICE_NOT_MET);
return;
}
final ItemStack finalItemToSell = auctionItem.getItem().clone();
final double originalBasePrice = auctionItem.getBasePrice();
final double originalStartPrice = auctionItem.getBidStartingPrice();
final double originalIncrementPrice = auctionItem.getBidIncrementPrice();
/*
auctionedItem.setBasePrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(this.isAllowingBuyNow ? buyNowPrice : -1) : this.isAllowingBuyNow ? buyNowPrice : -1);
auctionedItem.setBidStartingPrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(this.isBiddingItem ? this.bidStartPrice : 0) : this.isBiddingItem ? this.bidStartPrice : 0);
auctionedItem.setBidIncrementPrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(this.isBiddingItem ? this.bidIncrementPrice != null ? this.bidIncrementPrice : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 0) : this.isBiddingItem ? this.bidIncrementPrice != null ? this.bidIncrementPrice : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 0);
auctionedItem.setCurrentPrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(this.isBiddingItem ? this.bidStartPrice : this.buyNowPrice <= -1 ? this.bidStartPrice : this.buyNowPrice) : this.isBiddingItem ? this.bidStartPrice : this.buyNowPrice <= -1 ? this.bidStartPrice : this.buyNowPrice);
*/
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() && !auctionItem.isServerItem() && !auctionItem.isRequest()) {
if (!AuctionHouse.getCurrencyManager().has(seller, listingFee)) {
instance.getLocale().getMessage("auction.tax.cannotpaylistingfee").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(listingFee)).sendPrefixedMessage(seller);
instance.getLocale().getMessage("auction.tax.cannotpaylistingfee")
.processPlaceholder("price", AuctionHouse.getAPI().getNumberAsCurrency(listingFee, false))
.sendPrefixedMessage(seller);
result.accept(auctionItem, CANNOT_PAY_LISTING_FEE);
return;
}
AuctionHouse.getCurrencyManager().withdraw(seller, listingFee);
AuctionHouse.getInstance().getLocale().getMessage("auction.tax.paidlistingfee").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(listingFee)).sendPrefixedMessage(seller);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(seller))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(listingFee)).sendPrefixedMessage(seller);
AuctionHouse.getInstance().getLocale().getMessage("auction.tax.paidlistingfee")
.processPlaceholder("price", AuctionHouse.getAPI().getNumberAsCurrency(listingFee, false))
.sendPrefixedMessage(seller);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove")
.processPlaceholder("player_balance", AuctionHouse.getCurrencyManager().getFormattedBalance(seller, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getNumberAsCurrency(listingFee, false))
.sendPrefixedMessage(seller);
}
// final item adjustments
@ -159,17 +160,17 @@ public final class AuctionCreator {
String msg = AuctionHouse.getInstance().getLocale().getMessage(auctionItem.isRequest() ? "auction.listed.request" : auctionItem.isBidItem() ? "auction.listed.withbid" : "auction.listed.nobid")
.processPlaceholder("amount", finalItemToSell.getAmount())
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(finalItemToSell))
.processPlaceholder("base_price", auctionItem.getBasePrice() <= -1 ? NAX : AuctionAPI.getInstance().formatNumber(auctionItem.getBasePrice()))
.processPlaceholder("start_price", AuctionAPI.getInstance().formatNumber(auctionItem.getBidStartingPrice()))
.processPlaceholder("increment_price", AuctionAPI.getInstance().formatNumber(auctionItem.getBidIncrementPrice())).getMessage();
.processPlaceholder("base_price", auctionItem.getBasePrice() <= -1 ? NAX : auctionItem.getFormattedBasePrice())
.processPlaceholder("start_price", auctionItem.getFormattedStartingPrice())
.processPlaceholder("increment_price", auctionItem.getFormattedIncrementPrice()).getMessage();
if (seller != null && !auctionItem.isServerItem()) {
if (AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(seller.getUniqueId()) == null) {
if (AuctionHouse.getAuctionPlayerManager().getPlayer(seller.getUniqueId()) == null) {
AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + seller.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender());
AuctionHouse.getInstance().getAuctionPlayerManager().addPlayer(new AuctionPlayer(seller));
AuctionHouse.getAuctionPlayerManager().addPlayer(new AuctionPlayer(seller));
}
if (AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(seller.getUniqueId()).isShowListingInfo()) {
if (AuctionHouse.getAuctionPlayerManager().getPlayer(seller.getUniqueId()).isShowListingInfo()) {
AuctionHouse.getInstance().getLocale().newMessage(msg).sendPrefixedMessage(seller);
}
}
@ -177,7 +178,7 @@ public final class AuctionCreator {
//====================================================================================
// Actually attempt the insertion now
AuctionHouse.getInstance().getDataManager().insertAuction(auctionItem, (error, inserted) -> {
AuctionHouse.getDataManager().insertAuction(auctionItem, (error, inserted) -> {
if (auctionPlayer != null)
auctionPlayer.setItemBeingListed(null);
@ -205,23 +206,29 @@ 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() && !auctionItem.isServerItem() && !auctionItem.isRequest() && seller != null) {
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(
AuctionHouse.getDataManager().insertAuctionPayment(new AuctionPayment(
seller.getUniqueId(),
listingFee,
auctionItem.getItem(),
AuctionHouse.getInstance().getLocale().getMessage("general.prefix").getMessage(),
PaymentReason.LISTING_FAILED
PaymentReason.LISTING_FAILED,
auctionItem.getCurrency(),
auctionItem.getCurrencyItem()
), null);
else
AuctionHouse.getCurrencyManager().deposit(seller, listingFee);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(seller))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(listingFee)).sendPrefixedMessage(seller);
AuctionHouse.getCurrencyManager().deposit(seller, listingFee, auctionItem.getCurrency(), auctionItem.getCurrencyItem());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getCurrencyManager().getFormattedBalance(seller, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getNumberAsCurrency(listingFee, false))
.sendPrefixedMessage(seller);
}
result.accept(auctionItem, UNKNOWN);
return;
}
AuctionHouse.getInstance().getAuctionItemManager().addAuctionItem(auctionItem);
AuctionHouse.getAuctionItemManager().addAuctionItem(auctionItem);
//====================================================================================
// ANOTHER VERY SHIT BROADCAST THAT IS IN FACT BROKEN
@ -234,9 +241,9 @@ public final class AuctionCreator {
.processPlaceholder("player", auctionItem.isServerItem() ? SERVER_LISTING_NAME : seller.getName())
.processPlaceholder("player_displayname", auctionItem.isServerItem() ? SERVER_LISTING_NAME : AuctionAPI.getInstance().getDisplayName(seller))
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(finalItemToSell))
.processPlaceholder("base_price", auctionItem.getBasePrice() <= -1 ? NAX : AuctionAPI.getInstance().formatNumber(auctionItem.getBasePrice()))
.processPlaceholder("start_price", AuctionAPI.getInstance().formatNumber(auctionItem.getBidStartingPrice()))
.processPlaceholder("increment_price", AuctionAPI.getInstance().formatNumber(auctionItem.getBidIncrementPrice())).getMessage();
.processPlaceholder("base_price", auctionItem.getBasePrice() <= -1 ? NAX : auctionItem.getFormattedBasePrice())
.processPlaceholder("start_price", auctionItem.getFormattedStartingPrice())
.processPlaceholder("increment_price", auctionItem.getFormattedIncrementPrice()).getMessage();
Bukkit.getOnlinePlayers().forEach(p -> {
if (seller != null && p.getUniqueId().equals(seller.getUniqueId())) return;

View File

@ -1,101 +0,0 @@
/*
* Auction House
* Copyright 2018-2022 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.hooks;
import ca.tweetzy.auctionhouse.exception.UltraEconomyCurrencyException;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.hooks.economies.Economy;
import ca.tweetzy.core.utils.TextUtils;
import me.TechsCode.UltraEconomy.UltraEconomy;
import me.TechsCode.UltraEconomy.objects.Account;
import me.TechsCode.UltraEconomy.objects.Currency;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
/**
* The current file has been created by Kiran Hart
* Date Created: October 05 2021
* Time Created: 9:18 p.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
*/
public final class UltraEconomyHook extends Economy {
private Currency currency;
public UltraEconomyHook() {
if (!isEnabled()) {
Bukkit.getConsoleSender().sendMessage(TextUtils.formatText("&bUltraEconomy &7hook cannot be created&f: &cUltraEconomy not installed"));
return;
}
final String[] ultraEconomyCurrencyName = Settings.ECONOMY_PLUGIN.getString().split(":");
if (ultraEconomyCurrencyName.length < 2 && ultraEconomyCurrencyName[0].equalsIgnoreCase("UltraEconomy")) {
Bukkit.getConsoleSender().sendMessage(TextUtils.formatText("&cInvalid UltraEconomy format, use -> &bUltraEconomy&f:&bTheCurrencyName &cinstead"));
return;
}
if (!ultraEconomyCurrencyName[0].equalsIgnoreCase("UltraEconomy")) return;
this.currency = UltraEconomy.getInstance().getCurrencies().name(ultraEconomyCurrencyName[1]).orElse(null);
if (this.currency == null) {
throw new UltraEconomyCurrencyException("AuctionHouse could not find the currency: " + ultraEconomyCurrencyName[0]);
}
}
@Override
public double getBalance(OfflinePlayer player) {
final Account account = UltraEconomy.getInstance().getAccounts().uuid(player.getUniqueId()).orElse(null);
return account == null ? 0 : account.getBalance(this.currency).getSum();
}
@Override
public boolean hasBalance(OfflinePlayer player, double cost) {
return getBalance(player) >= cost;
}
@Override
public boolean withdrawBalance(OfflinePlayer player, double cost) {
final Account account = UltraEconomy.getInstance().getAccounts().uuid(player.getUniqueId()).orElse(null);
if (account == null) return false;
account.removeBalance(this.currency, cost);
return true;
}
@Override
public boolean deposit(OfflinePlayer player, double amount) {
final Account account = UltraEconomy.getInstance().getAccounts().uuid(player.getUniqueId()).orElse(null);
if (account == null) return false;
account.addBalance(this.currency, amount);
return true;
}
@Override
public String getName() {
return "UltraEconomy";
}
@Override
public boolean isEnabled() {
return Bukkit.getPluginManager().getPlugin("UltraEconomy") != null;
}
}

View File

@ -19,6 +19,92 @@
package ca.tweetzy.auctionhouse.impl;
import ca.tweetzy.auctionhouse.api.AuctionHouseAPI;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.flight.comp.enums.CompMaterial;
import ca.tweetzy.flight.utils.ItemUtil;
import org.bukkit.inventory.ItemStack;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.Locale;
public final class AuctionAPI implements AuctionHouseAPI {
@Override
public String getNumberAsCurrency(double number, boolean hideSymbol) {
final NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance(new Locale.Builder()
.setLanguage(Settings.CURRENCY_FORMAT_LANGUAGE.getString())
.setRegion(Settings.CURRENCY_FORMAT_COUNTRY.getString())
.build()
);
if (hideSymbol)
if (currencyFormatter instanceof DecimalFormat) {
DecimalFormat decimalFormat = (DecimalFormat) currencyFormatter;
DecimalFormatSymbols symbols = decimalFormat.getDecimalFormatSymbols();
symbols.setCurrencySymbol(""); // Set the currency symbol to an empty string
decimalFormat.setDecimalFormatSymbols(symbols);
}
return currencyFormatter.format(number);
}
@Override
public String getNumberAsCurrency(double number) {
return getNumberAsCurrency(number, true);
}
@Override
public String getAbbreviatedNumber(double number, boolean hideSymbol) {
String[] suffixes = {"", "k", "m", "b", "t", "q", "Q", "s", "S", "o", "n", "d"};
int suffixIndex = 0;
double tempNumber = number;
while (tempNumber >= 1000 && suffixIndex < suffixes.length - 1) {
tempNumber /= 1000;
suffixIndex++;
}
DecimalFormat decimalFormat = new DecimalFormat("#.##");
String abbreviatedNumber = decimalFormat.format(tempNumber) + suffixes[suffixIndex];
if (!hideSymbol) {
abbreviatedNumber = getNumberAsCurrency(tempNumber, false) + suffixes[suffixIndex];
}
return abbreviatedNumber;
}
@Override
public String getAbbreviatedNumber(double number) {
return getAbbreviatedNumber(number, true);
}
@Override
public String getFinalizedCurrencyNumber(double number, String currency, ItemStack currencyItem) {
final String baseCurrencyFormat = Settings.CURRENCY_ABBREVIATE_NUMBERS.getBoolean() ? getAbbreviatedNumber(number, false) : getNumberAsCurrency(number, false);
final String currencyUnformatted = Settings.CURRENCY_ABBREVIATE_NUMBERS.getBoolean() ? getAbbreviatedNumber(number) : getNumberAsCurrency(number);
if (currency == null)
return baseCurrencyFormat;
// split the currency string
final String[] currencyProperties = currency.split("/");
// basic vault currency, use normal formatting
if (currencyProperties[0].equalsIgnoreCase("Vault")) {
return baseCurrencyFormat;
}
// using an item currency
if (currencyProperties[0].equalsIgnoreCase("AuctionHouse") && currencyProperties[1].equalsIgnoreCase("Item")) {
final String currencyItemName = currencyItem != null && currencyItem.getType() != CompMaterial.AIR.parseMaterial() ? ItemUtil.getItemName(currencyItem) : currencyProperties[2];
return String.format("%s %s", currencyUnformatted, currencyItemName);
}
// using another currency system with custom name
return String.format("%s %s", currencyUnformatted, currencyProperties[2]);
}
}

View File

@ -0,0 +1,68 @@
package ca.tweetzy.auctionhouse.impl.currency;
import ca.tweetzy.auctionhouse.api.currency.IconableCurrency;
import ca.tweetzy.flight.comp.enums.CompMaterial;
import ca.tweetzy.funds.api.FundsAPI;
import ca.tweetzy.funds.api.interfaces.Account;
import ca.tweetzy.funds.api.interfaces.Currency;
import org.bukkit.OfflinePlayer;
public final class FundsCurrency extends IconableCurrency {
private final Currency currency;
public FundsCurrency(String currencyName) {
super("Funds", currencyName, "", CompMaterial.PAPER.parseItem());
this.currency = FundsAPI.getInstance().getCurrency(currencyName);
if (this.currency != null) {
setDisplayName(this.currency.getName());
setIcon(this.currency.getIcon().parseItem());
}
}
@Override
public boolean has(OfflinePlayer player, double amount) {
final Account account = FundsAPI.getInstance().getAccount(player);
if (account == null || this.currency == null)
return false;
return account.getCurrencies().getOrDefault(this.currency, 0D) >= amount;
}
@Override
public boolean withdraw(OfflinePlayer player, double amount) {
final Account account = FundsAPI.getInstance().getAccount(player);
if (account == null || this.currency == null)
return false;
account.withdrawCurrency(this.currency, amount);
account.sync(true);
return true;
}
@Override
public boolean deposit(OfflinePlayer player, double amount) {
final Account account = FundsAPI.getInstance().getAccount(player);
if (account == null || this.currency == null)
return false;
account.depositCurrency(this.currency, amount);
account.sync(true);
return true;
}
@Override
public double getBalance(OfflinePlayer player) {
final Account account = FundsAPI.getInstance().getAccount(player);
if (account == null || this.currency == null)
return 0;
return account.getCurrencies().getOrDefault(this.currency, 0D);
}
}

View File

@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
public final class ItemCurrency extends AbstractCurrency {
public ItemCurrency() {
super("Markets", "Item", "&bCustom Item");
super("AuctionHouse", "Item", "&bCustom Item");
}
public boolean has(OfflinePlayer player, double amount, ItemStack item) {

View File

@ -0,0 +1,42 @@
package ca.tweetzy.auctionhouse.model.currency;
import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
import ca.tweetzy.auctionhouse.impl.currency.FundsCurrency;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.funds.api.FundsAPI;
import ca.tweetzy.funds.api.interfaces.Currency;
import java.util.ArrayList;
import java.util.List;
public final class FundsEconomyLoader extends CurrencyLoader {
public FundsEconomyLoader() {
super("Funds");
}
@Override
public List<AbstractCurrency> getCurrencies() {
final List<AbstractCurrency> currencies = new ArrayList<>();
for (Currency currency : FundsAPI.getInstance().getCurrencies()) {
boolean blackListed = false;
for (String blacklisted : Settings.CURRENCY_BLACKLISTED.getStringList()) {
final String[] blacklistSplit = blacklisted.split(":");
if (blacklistSplit.length != 2) continue;
if (!blacklistSplit[0].equalsIgnoreCase(this.owningPlugin)) continue;
if (blacklistSplit[1].equalsIgnoreCase(currency.getName()))
blackListed = true;
}
if (!blackListed)
currencies.add(new FundsCurrency(currency.getId()));
}
return currencies;
}
}

View File

@ -18,7 +18,7 @@
package ca.tweetzy.auctionhouse.model.discord;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.helpers.AuctionCreator;
import ca.tweetzy.auctionhouse.settings.Settings;
@ -121,32 +121,32 @@ public final class DiscordMessageCreator {
}
public DiscordWebhook.EmbedObject applyBidInfo(DiscordWebhook.EmbedObject embed) {
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_VALUE.getString().replace("%starting_price%", AuctionAPI.getInstance().formatNumber(this.listing.getBidStartingPrice())), Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_VALUE.getString().replace("%starting_price%", this.listing.getFormattedStartingPrice()), Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_BIDDER_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_BIDDER_VALUE.getString().replace("%bidder%", this.bidder.getName()), Settings.DISCORD_MSG_FIELD_AUCTION_BIDDER_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_BID_AMT_NAME.getString(), Settings.DISCORD_MSG_FIELD_BID_AMT_VALUE.getString().replace("%bid_amount%", AuctionAPI.getInstance().formatNumber(this.bidAmount)), Settings.DISCORD_MSG_FIELD_BID_AMT_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_CURRENT_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_CURRENT_PRICE_VALUE.getString().replace("%current_price%", AuctionAPI.getInstance().formatNumber(this.listing.getCurrentPrice())), Settings.DISCORD_MSG_FIELD_AUCTION_CURRENT_PRICE_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_BID_AMT_NAME.getString(), Settings.DISCORD_MSG_FIELD_BID_AMT_VALUE.getString().replace("%bid_amount%", AuctionHouse.getAPI().getFinalizedCurrencyNumber(this.bidAmount, this.listing.getCurrency(), this.listing.getCurrencyItem())), Settings.DISCORD_MSG_FIELD_BID_AMT_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_CURRENT_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_CURRENT_PRICE_VALUE.getString().replace("%current_price%", this.listing.getFormattedCurrentPrice()), Settings.DISCORD_MSG_FIELD_AUCTION_CURRENT_PRICE_INLINE.getBoolean());
return embed;
}
public DiscordWebhook.EmbedObject applyAuctionWonInfo(DiscordWebhook.EmbedObject embed) {
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_VALUE.getString().replace("%starting_price%", AuctionAPI.getInstance().formatNumber(this.listing.getBidStartingPrice())), Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_WON_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_WON_VALUE.getString().replace("%final_price%", AuctionAPI.getInstance().formatNumber(this.listing.getCurrentPrice())), Settings.DISCORD_MSG_FIELD_AUCTION_WON_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_VALUE.getString().replace("%starting_price%", this.listing.getFormattedStartingPrice()), Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_WON_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_WON_VALUE.getString().replace("%final_price%", this.listing.getFormattedCurrentPrice()), Settings.DISCORD_MSG_FIELD_AUCTION_WON_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_WINNER_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_WINNER_VALUE.getString().replace("%winner%", this.buyer.getName()), Settings.DISCORD_MSG_FIELD_AUCTION_WINNER_INLINE.getBoolean());
return embed;
}
public DiscordWebhook.EmbedObject applyBinInfo(DiscordWebhook.EmbedObject embed) {
embed.addField(Settings.DISCORD_MSG_FIELD_BIN_LISTING_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_BIN_LISTING_PRICE_VALUE.getString().replace("%item_price%", AuctionAPI.getInstance().formatNumber(this.listing.getBasePrice())), Settings.DISCORD_MSG_FIELD_BIN_LISTING_PRICE_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_BIN_LISTING_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_BIN_LISTING_PRICE_VALUE.getString().replace("%item_price%", this.listing.getFormattedBasePrice()), Settings.DISCORD_MSG_FIELD_BIN_LISTING_PRICE_INLINE.getBoolean());
return embed;
}
public DiscordWebhook.EmbedObject applyAuctionInfo(DiscordWebhook.EmbedObject embed) {
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_VALUE.getString().replace("%starting_price%", AuctionAPI.getInstance().formatNumber(this.listing.getBidStartingPrice())), Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_VALUE.getString().replace("%starting_price%", this.listing.getFormattedStartingPrice()), Settings.DISCORD_MSG_FIELD_AUCTION_START_PRICE_INLINE.getBoolean());
if (this.listing.getBasePrice() != -1)
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_BUYOUT_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_BUYOUT_PRICE_VALUE.getString().replace("%buy_now_price%", AuctionAPI.getInstance().formatNumber(this.listing.getBasePrice())), Settings.DISCORD_MSG_FIELD_AUCTION_BUYOUT_PRICE_INLINE.getBoolean());
embed.addField(Settings.DISCORD_MSG_FIELD_AUCTION_BUYOUT_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_AUCTION_BUYOUT_PRICE_VALUE.getString().replace("%buy_now_price%", this.listing.getFormattedBasePrice()), Settings.DISCORD_MSG_FIELD_AUCTION_BUYOUT_PRICE_INLINE.getBoolean());
return embed;
}

View File

@ -5,8 +5,10 @@ import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
import ca.tweetzy.auctionhouse.api.manager.ListManager;
import ca.tweetzy.auctionhouse.impl.currency.ItemCurrency;
import ca.tweetzy.auctionhouse.impl.currency.VaultCurrency;
import ca.tweetzy.auctionhouse.model.currency.FundsEconomyLoader;
import ca.tweetzy.auctionhouse.model.currency.UltraEconomyLoader;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.flight.comp.enums.CompMaterial;
import lombok.NonNull;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -53,17 +55,33 @@ public final class CurrencyManager extends ListManager<AbstractCurrency> {
return locateCurrency(owningPlugin, currencyName).deposit(offlinePlayer, amount);
}
public boolean deposit(@NonNull final OfflinePlayer offlinePlayer, double amount, @NonNull final String currency, ItemStack currencyItem) {
if (currencyItem != null && currencyItem.getType() != CompMaterial.AIR.parseMaterial())
return deposit(offlinePlayer, currencyItem, (int) amount);
final String[] currSplit = currency.split("/");
return locateCurrency(currSplit[0], currSplit[1]).deposit(offlinePlayer, amount);
}
public boolean withdraw(@NonNull final OfflinePlayer offlinePlayer, double amount, @NonNull final String currency, ItemStack currencyItem) {
if (currencyItem != null && currencyItem.getType() != CompMaterial.AIR.parseMaterial())
return withdraw(offlinePlayer, currencyItem, (int) amount);
final String[] currSplit = currency.split("/");
return locateCurrency(currSplit[0], currSplit[1]).withdraw(offlinePlayer, amount);
}
public boolean has(@NonNull final OfflinePlayer offlinePlayer, @NonNull final ItemStack itemStack, final int amount) {
return ((ItemCurrency) locateCurrency("Markets", "Item")).has(offlinePlayer, amount, itemStack);
return ((ItemCurrency) locateCurrency("AuctionHouse", "Item")).has(offlinePlayer, amount, itemStack);
}
public boolean withdraw(@NonNull final OfflinePlayer offlinePlayer, @NonNull final ItemStack itemStack, final int amount) {
return ((ItemCurrency) locateCurrency("Markets", "Item")).withdraw(offlinePlayer, amount, itemStack);
return ((ItemCurrency) locateCurrency("AuctionHouse", "Item")).withdraw(offlinePlayer, amount, itemStack);
}
public boolean deposit(@NonNull final OfflinePlayer offlinePlayer, @NonNull final ItemStack itemStack, final int amount) {
return ((ItemCurrency) locateCurrency("Markets", "Item")).deposit(offlinePlayer, amount, itemStack);
return ((ItemCurrency) locateCurrency("AuctionHouse", "Item")).deposit(offlinePlayer, amount, itemStack);
}
public boolean has(@NonNull final OfflinePlayer offlinePlayer, final double amount) {
@ -87,16 +105,23 @@ public final class CurrencyManager extends ListManager<AbstractCurrency> {
return getBalance(offlinePlayer, CURRENCY_DEFAULT[0], CURRENCY_DEFAULT[1]);
}
public String getFormattedBalance(@NonNull final OfflinePlayer offlinePlayer, String currency, ItemStack currencyItem) {
return AuctionHouse.getAPI().getFinalizedCurrencyNumber(getBalance(offlinePlayer, currency.split("/")[0], currency.split("/")[1]), currency, currencyItem);
}
@Override
public void load() {
clear();
// add vault by default
add(new VaultCurrency());
// add(new ItemCurrency());
add(new ItemCurrency());
// load currencies from providers that allow multiple currencies
if (Bukkit.getServer().getPluginManager().isPluginEnabled("UltraEconomy"))
new UltraEconomyLoader().getCurrencies().forEach(this::add);
if (Bukkit.getServer().getPluginManager().isPluginEnabled("Funds"))
new FundsEconomyLoader().getCurrencies().forEach(this::add);
}
}

View File

@ -78,7 +78,7 @@ public class LocaleSettings {
languageNodes.put("general.something_went_wrong_while_listing", "&cSomething went wrong while listing item.");
languageNodes.put("general.toggled listing.on", "&aYou turned on listing messages");
languageNodes.put("general.toggled listing.off", "&cYou turned off listing messages");
languageNodes.put("general.bought_item", "&aYou bought &fx%amount% %item%&a for &a$%price%");
languageNodes.put("general.bought_item", "&aYou bought &fx%amount% %item%&a for &a%price%");
languageNodes.put("general.wait_to_list", "&cPlease wait &4%time%&cs before listing another item");
languageNodes.put("general.please_enter_at_least_one_number", "&cPlease enter at least 1 valid number!");
languageNodes.put("general.cannot cancel item with bid", "&cYou cannot cancel a listing that already has a bid!");
@ -107,18 +107,18 @@ public class LocaleSettings {
languageNodes.put("general.priority boost.boosted", "&aSuccessfully boosted this item to the top of the Auction House");
languageNodes.put("general.priority boost.already boosted", "&cThis item already has priority listing");
languageNodes.put("pricing.minbaseprice", "&cThe minimum base price must be &a$%price%");
languageNodes.put("pricing.minstartingprice", "&cThe minimum starting bid price must be &a$%price%");
languageNodes.put("pricing.minbidincrementprice", "&cThe minimum bid increment must be &a$%price%");
languageNodes.put("pricing.maxbaseprice", "&cThe maximum base price is &a$%price%");
languageNodes.put("pricing.maxstartingprice", "&cThe maximum starting bid price is &a$%price%");
languageNodes.put("pricing.maxbidincrementprice", "&cThe maximum bid increment is &a$%price%");
languageNodes.put("pricing.minbaseprice", "&cThe minimum base price must be &a%price%");
languageNodes.put("pricing.minstartingprice", "&cThe minimum starting bid price must be &a%price%");
languageNodes.put("pricing.minbidincrementprice", "&cThe minimum bid increment must be &a%price%");
languageNodes.put("pricing.maxbaseprice", "&cThe maximum base price is &a%price%");
languageNodes.put("pricing.maxstartingprice", "&cThe maximum starting bid price is &a%price%");
languageNodes.put("pricing.maxbidincrementprice", "&cThe maximum bid increment is &a%price%");
languageNodes.put("pricing.basepricetoolow", "&cThe buy now price must be higher than the starting bid.");
languageNodes.put("pricing.startingpricetoohigh", "&cThe starting bid cannot be higher than buyout. &f(&a%price%&f)");
languageNodes.put("pricing.moneyremove", "&c&l- $%price% &7(%player_balance%)");
languageNodes.put("pricing.moneyadd", "&a&l+ $%price% &7(%player_balance%)");
languageNodes.put("pricing.bidmusthigherthanprevious", "&cYour bid must be higher than &4%current_bid%");
languageNodes.put("pricing.minitemprice", "&cThe minimum price for this item must be &a$%price%");
languageNodes.put("pricing.minitemprice", "&cThe minimum price for this item must be &a%price%");
languageNodes.put("titles.end all confirm.title", "&eConfirm End All");
@ -155,6 +155,8 @@ public class LocaleSettings {
languageNodes.put("titles.ban length.title", "&eBan Length");
languageNodes.put("titles.ban length.subtitle", "&fEnter ban length in chat. (ex. 1 day 12 hours)");
languageNodes.put("titles.material search.title", "&eSearch for material");
languageNodes.put("titles.material search.subtitle", "&fEnter item/material name in chat");
languageNodes.put("transaction.sale_type.bid_won", "Won Auction");
languageNodes.put("transaction.sale_type.immediate_buy", "Bought Immediately");
@ -219,7 +221,7 @@ public class LocaleSettings {
languageNodes.put("auction.broadcast.sold", "&e&fx%amount% &6%item% &esold to %player% for &a%price%");
languageNodes.put("auction.broadcast.serverlisting", "&e&fx%amount% &6%item% &ehas appeared on the auction house.");
languageNodes.put("auction.broadcast.bid", "&e%player% increased the bid to &a$%amount% &eon &6%item%");
languageNodes.put("auction.broadcast.bid", "&e%player% increased the bid to &a%amount% &eon &6%item%");
languageNodes.put("auction.broadcast.ending", "&eAuction for &6%item% &eis ending in &6%seconds%&es");
languageNodes.put("auction.bidwon", "&eYou won the bid for&fx%amount% &6%item% &efor &a%price%");
@ -227,7 +229,7 @@ public class LocaleSettings {
languageNodes.put("auction.itemnotavailable", "&cThat item is no longer available :(");
languageNodes.put("auction.biditemwithdisabledbuynow", "&CN/A");
languageNodes.put("auction.outbid", "&6%player% &ehas out bid you for &6%item%");
languageNodes.put("auction.placedbid", "&6%player% &eincreased the bid to &a$%amount% &eon &6%item%");
languageNodes.put("auction.placedbid", "&6%player% &eincreased the bid to &a%amount% &eon &6%item%");
languageNodes.put("auction.nobids", "&cNo Bids");
languageNodes.put("auction.tax.cannotpaylistingfee", "&cYou do not have enough money to pay the listing fee &f(&4$%price%&f)");

View File

@ -23,7 +23,6 @@ import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.compatibility.XSound;
import ca.tweetzy.core.configuration.Config;
import ca.tweetzy.core.configuration.ConfigSetting;
import ca.tweetzy.core.hooks.EconomyManager;
import ca.tweetzy.flight.comp.enums.CompMaterial;
import java.util.Arrays;
@ -42,14 +41,15 @@ public class Settings {
static final Config config = AuctionHouse.getInstance().getCoreConfig();
public static final ConfigSetting LANG = new ConfigSetting(config, "lang", "en_US", "Default language file");
public static final ConfigSetting ECONOMY_PLUGIN = new ConfigSetting(config, "economy provider", EconomyManager.getEconomy() == null ? "Vault" : EconomyManager.getEconomy().getName(),
"Which economy should auction house use?",
"You have the following supported economy plugins installed: \"" + EconomyManager.getManager().getPossiblePlugins().stream().collect(Collectors.joining("\", \"")) + "\"."
);
public static final ConfigSetting CURRENCY_ALLOW_PICK = new ConfigSetting(config, "economy.currency.allow pick", true, "If true, players will be able to select which currency they want to use.");
public static final ConfigSetting CURRENCY_DEFAULT_SELECTED = new ConfigSetting(config, "economy.currency.default selection", "Vault/Vault", "The default currency selection, PluginName/CurrencyName -> Ex. Vault/Vault or UltraEconomy/Gems etc");
public static final ConfigSetting CURRENCY_VAULT_SYMBOL = new ConfigSetting(config, "economy.currency.vault symbol", "$", "When using default/vault currency, what symbol should be used.");
public static final ConfigSetting CURRENCY_BLACKLISTED = new ConfigSetting(config, "economy.currency.black listed", Collections.singletonList("UltraEconomy:Test"), "A list of owning plugins & the currency to be blacklisted. Ex. UltraEconomy:Test");
public static final ConfigSetting CURRENCY_FORMAT_LANGUAGE = new ConfigSetting(config, "economy.currency.format.language", "en", "An ISO 639 alpha-2 or alpha-3 language code.");
public static final ConfigSetting CURRENCY_FORMAT_COUNTRY = new ConfigSetting(config, "economy.currency.format.country", "US", "An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.");
public static final ConfigSetting CURRENCY_ABBREVIATE_NUMBERS = new ConfigSetting(config, "economy.currency.abbreviate numbers", false, "Should numbers be abbreviated?. Example: 123,000 will become 123k ");
public static final ConfigSetting CMD_ALIAS_MAIN = new ConfigSetting(config, "command aliases.main", Arrays.asList("ah", "auctions", "auctionhouses", "ahgui", "auctiongui"), "Command aliases for the main command");
public static final ConfigSetting CMD_ALIAS_SUB_ACTIVE = new ConfigSetting(config, "command aliases.subcommands.active", Collections.singletonList("active"), "Command aliases for the active command");
@ -115,8 +115,6 @@ public class Settings {
public static final ConfigSetting MAX_REQUEST_AMOUNT = new ConfigSetting(config, "auction setting.max request amount", 64, "How much of an item should a player be able to ask for in a single request?");
public static final ConfigSetting AUTO_REFRESH_AUCTION_PAGES = new ConfigSetting(config, "auction setting.auto refresh auction pages", true, "Should auction pages auto refresh?");
public static final ConfigSetting AUTO_REFRESH_ACTIVE_AUCTION_PAGES = new ConfigSetting(config, "auction setting.auto refresh active auction pages", false, "Should the /ah active pages be auto refreshed?");
public static final ConfigSetting USE_SHORT_NUMBERS_ON_ITEMS = new ConfigSetting(config, "auction setting.use short numbers", false, "Should numbers be shortened into a prefixed form?");
public static final ConfigSetting USE_SHORT_NUMBERS_ON_PLAYER_BALANCE = new ConfigSetting(config, "auction setting.use short numbers on balance", false, "Should numbers be shortened into a prefixed form for the player balance?");
public static final ConfigSetting INCREASE_TIME_ON_BID = new ConfigSetting(config, "auction setting.increase time on bid", true, "Should the remaining time be increased when a bid is placed?");
public static final ConfigSetting TIME_TO_INCREASE_BY_ON_BID = new ConfigSetting(config, "auction setting.time to increase by on the bid", 20, "How many seconds should be added to the remaining time?");
public static final ConfigSetting ALLOW_SALE_OF_DAMAGED_ITEMS = new ConfigSetting(config, "auction setting.allow sale of damaged items", true, "If true, player's can sell items that are damaged (not max durability)");
@ -124,7 +122,6 @@ public class Settings {
public static final ConfigSetting RESTRICT_ALL_TRANSACTIONS_TO_PERM = new ConfigSetting(config, "auction setting.restrict viewing all transactions", false, "If true, player's will need the perm: auctionhouse.transactions.viewall to view all transactions");
public static final ConfigSetting BLOCKED_WORLDS = new ConfigSetting(config, "auction setting.blocked worlds", Collections.singletonList("creative"), "A list of worlds that Auction House will be disabled in");
public static final ConfigSetting PREVENT_SALE_OF_REPAIRED_ITEMS = new ConfigSetting(config, "auction setting.prevent sale of repaired items", false, "Items repaired before this setting is turned on will still be able to be listed.");
public static final ConfigSetting SYNCHRONIZE_ITEM_ADD = new ConfigSetting(config, "auction setting.synchronize item add", false, "If an item is being added to a player's inventory, the process will be ran synchronously");
public static final ConfigSetting ITEM_COPY_REQUIRES_GMC = new ConfigSetting(config, "auction setting.admin copy requires creative", false, "If true when using the admin copy option the player must be in creative");
public static final ConfigSetting LOG_ADMIN_ACTIONS = new ConfigSetting(config, "auction setting.log admin actions", true, "If true, any admin actions made will be logged");
public static final ConfigSetting ROUND_ALL_PRICES = new ConfigSetting(config, "auction setting.round all prices", false, "If true, any decimal numbers will be rounded to the nearest whole number");
@ -188,18 +185,11 @@ public class Settings {
public static final ConfigSetting BASE_PRICE_MUST_BE_HIGHER_THAN_BID_START = new ConfigSetting(config, "auction setting.base price must be higher than bid start", true, "Should the base price (buy now price) be higher than the initial bid starting price?");
public static final ConfigSetting SYNC_BASE_PRICE_TO_HIGHEST_PRICE = new ConfigSetting(config, "auction setting.sync the base price to the current price", true, "Ex. If the buy now price was 100, and the current price exceeds 100 to say 200, the buy now price will become 200.");
public static final ConfigSetting CURRENCY_FORMAT = new ConfigSetting(config, "auction setting.currency format", "%,.2f");
public static final ConfigSetting STRIP_ZEROS_ON_WHOLE_NUMBERS = new ConfigSetting(config, "auction setting.strip zeros on whole numbers", false, "If the price / amount is a whole number (ex. 40.00) it will drop the .00");
public static final ConfigSetting ADMIN_OPTION_SHOW_RETURN_ITEM = new ConfigSetting(config, "auction setting.admin option.show return to player", true);
public static final ConfigSetting ADMIN_OPTION_SHOW_CLAIM_ITEM = new ConfigSetting(config, "auction setting.admin option.show claim item", true);
public static final ConfigSetting ADMIN_OPTION_SHOW_DELETE_ITEM = new ConfigSetting(config, "auction setting.admin option.show delete item", true);
public static final ConfigSetting ADMIN_OPTION_SHOW_COPY_ITEM = new ConfigSetting(config, "auction setting.admin option.show copy item", true);
public static final ConfigSetting USE_ALTERNATE_CURRENCY_FORMAT = new ConfigSetting(config, "auction setting.use alternate currency format", false, "If true, $123,456.78 will become $123.456,78");
public static final ConfigSetting USE_FLAT_NUMBER_FORMAT = new ConfigSetting(config, "auction setting.use flat number format", false, "If true, $123,456.78 will become $12345678");
public static final ConfigSetting USE_SPACE_SEPARATOR_FOR_NUMBER = new ConfigSetting(config, "auction setting.use space separator for number", false, "If true, $123,456.78 will become $123 456.78");
public static final ConfigSetting DATE_FORMAT = new ConfigSetting(config, "auction setting.date format", "MMM dd, yyyy hh:mm aa", "You can learn more about date formats by googling SimpleDateFormat patterns or visiting this link", "https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html");
public static final ConfigSetting ALLOW_PLAYERS_TO_ACCEPT_BID = new ConfigSetting(config, "auction setting.allow players to accept bid", true, "If true, players can right click a biddable item inside their active listings menu to accept the current bid");
public static final ConfigSetting SELLERS_MUST_WAIT_FOR_TIME_LIMIT_AFTER_BID = new ConfigSetting(config, "auction setting.prevent cancellation of bid on items", false, "If true, players must wait out the duration of the auction listing if there is already a bid on it (makes them commit to selling it)");
@ -538,6 +528,35 @@ public class Settings {
public static final ConfigSetting GUI_REFRESH_BTN_NAME = new ConfigSetting(config, "gui.global items.refresh button.name", "&6&LRefresh Page");
public static final ConfigSetting GUI_REFRESH_BTN_LORE = new ConfigSetting(config, "gui.global items.refresh button.lore", Collections.singletonList("&7Click to refresh the page"));
// currency picker
public static final ConfigSetting GUI_CURRENCY_PICKER_TITLE = new ConfigSetting(config, "gui.currency picker.title", "&7Auction House &f- &ePick Currency");
public static final ConfigSetting GUI_CURRENCY_PICKER_ITEMS_CUSTOM_NAME = new ConfigSetting(config, "gui.currency picker.items.custom currency.name", "&e&lCustom Currency");
public static final ConfigSetting GUI_CURRENCY_PICKER_ITEMS_CUSTOM_LORE = new ConfigSetting(config, "gui.currency picker.items.custom currency.lore",
Arrays.asList(
"&7If you want to use use a specific item for",
"&7the currency, you can set that here.",
"",
"&e&lLeft Click &7with the item you want to use",
"&b&lRight Click &7to open a material picker &eor",
"&7as the currency onto this icon."
)
);
// material picker
public static final ConfigSetting GUI_MATERIAL_PICKER_TITLE = new ConfigSetting(config, "gui.material picker.title", "&7Auction House &f- &ePick an Item");
public static final ConfigSetting GUI_MATERIAL_PICKER_ITEMS_MATERIAL_LORE = new ConfigSetting(config, "gui.material picker.items.material.lore", "&7Click to select this item");
public static final ConfigSetting GUI_MATERIAL_PICKER_ITEMS_SEARCH_NAME = new ConfigSetting(config, "gui.material picker.items.search.name", "&e&lSearch");
public static final ConfigSetting GUI_MATERIAL_PICKER_ITEMS_SEARCH_LORE = new ConfigSetting(config, "gui.material picker.items.search.lore",
Collections.singletonList(
"&7Click to search for materials"
)
);
public static final ConfigSetting GUI_MATERIAL_PICKER_ITEMS_RESET_NAME = new ConfigSetting(config, "gui.material picker.items.reset.name", "&c&lClear Search");
public static final ConfigSetting GUI_MATERIAL_PICKER_ITEMS_RESET_LORE = new ConfigSetting(config, "gui.material picker.items.reset.lore",
Collections.singletonList(
"&7Click to clear search"
)
);
/* ===============================
* MAIN AUCTION GUI
@ -602,7 +621,7 @@ public class Settings {
"&7are currently selling on the auction.",
"",
"&e&l%active_player_auctions% Item(s)",
"&e&lBalance &a$%player_balance%"
"&e&lBalance &a%player_balance%"
));
public static final ConfigSetting GUI_AUCTION_HOUSE_ITEMS_COLLECTION_BIN_ENABLED = new ConfigSetting(config, "gui.auction house.items.collection bin.enabled", true);
@ -665,11 +684,11 @@ public class Settings {
public static final ConfigSetting GUI_CONFIRM_QTY_INFO_NAME = new ConfigSetting(config, "gui.confirm buy.qty info.name", "&ePurchase Information");
public static final ConfigSetting GUI_CONFIRM_QTY_INFO_LORE = new ConfigSetting(config, "gui.confirm buy.qty info.lore", Arrays.asList(
"&7Original Stack Size&f: &e%original_stack_size%",
"&7Price for entire stack&f: &a$%original_stack_price%",
"&7Price per item&f: &a$%price_per_item%",
"&7Price for entire stack&f: &a%original_stack_price%",
"&7Price per item&f: &a%price_per_item%",
"",
"&7Purchase Qty&f: &e%purchase_quantity%",
"&7Total&f: &a$%purchase_price%"
"&7Total&f: &a%purchase_price%"
), "Valid Placeholders", "%original_stack_size%", "%original_stack_price%", "%price_per_item%", "%purchase_quantity%", "%purchase_price%");
public static final ConfigSetting GUI_CONFIRM_BUY_NO_ITEM = new ConfigSetting(config, "gui.confirm buy.no.item", "RED_STAINED_GLASS_PANE");
@ -795,7 +814,7 @@ public class Settings {
));
public static final ConfigSetting GUI_PAYMENT_COLLECTION_PAYMENT_ITEM = new ConfigSetting(config, "gui.payment collection.payment.item", "PAPER");
public static final ConfigSetting GUI_PAYMENT_COLLECTION_PAYMENT_NAME = new ConfigSetting(config, "gui.payment collection.payment.name", "&a&l$%payment_amount%");
public static final ConfigSetting GUI_PAYMENT_COLLECTION_PAYMENT_NAME = new ConfigSetting(config, "gui.payment collection.payment.name", "&a&l%payment_amount%");
public static final ConfigSetting GUI_PAYMENT_COLLECTION_PAYMENT_LORE = new ConfigSetting(config, "gui.payment collection.payment.lore", Arrays.asList(
"&7Item&f: &e%item_name%",
"&7From&f: &e%from_name%",
@ -1180,6 +1199,14 @@ public class Settings {
/* ===============================
* ITEM SELL BIN GUI
* ===============================*/
public static final ConfigSetting GUI_SELL_ITEM_ITEM_CURRENCY_ITEM = new ConfigSetting(config, "gui.global items.currency.item", XMaterial.GOLD_INGOT.name());
public static final ConfigSetting GUI_SELL_ITEM_ITEM_CURRENCY_NAME = new ConfigSetting(config, "gui.global items.currency.name", "&e&lCurrency");
public static final ConfigSetting GUI_SELL_ITEM_ITEM_CURRENCY_LORE = new ConfigSetting(config, "gui.global items.currency.lore", Arrays.asList(
"",
"&7Click to change currency"
));
public static final ConfigSetting GUI_SELL_BIN_TITLE = new ConfigSetting(config, "gui.sell bin item.title", "&7Auction House - &eBin Listing");
public static final ConfigSetting GUI_SELL_BIN_BG_ITEM = new ConfigSetting(config, "gui.sell bin item.bg item", XMaterial.BLACK_STAINED_GLASS_PANE.name());
@ -1203,7 +1230,7 @@ public class Settings {
public static final ConfigSetting GUI_SELL_BIN_ITEM_ITEMS_PRICE_NAME = new ConfigSetting(config, "gui.sell bin item.items.price.name", "&e&lPrice");
public static final ConfigSetting GUI_SELL_BIN_ITEM_ITEMS_PRICE_LORE = new ConfigSetting(config, "gui.sell bin item.items.price.lore", Arrays.asList(
"",
"&7The current price if &F: &a$%listing_bin_price%",
"&7The current price if &F: &a%listing_bin_price%",
"",
"&7Click to edit the listing price"
));
@ -1281,7 +1308,7 @@ public class Settings {
public static final ConfigSetting GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_PRICE_NAME = new ConfigSetting(config, "gui.sell auction item.items.bin price.name", "&e&lBuyout Price");
public static final ConfigSetting GUI_SELL_AUCTION_ITEM_ITEMS_BUYOUT_PRICE_LORE = new ConfigSetting(config, "gui.sell auction item.items.bin price.lore", Arrays.asList(
"",
"&7The current buyout price is&F: &a$%listing_bin_price%",
"&7The current buyout price is&F: &a%listing_bin_price%",
"",
"&7Click to edit the buyout price"
));
@ -1290,7 +1317,7 @@ public class Settings {
public static final ConfigSetting GUI_SELL_AUCTION_ITEM_ITEMS_STARTING_PRICE_NAME = new ConfigSetting(config, "gui.sell auction item.items.starting price.name", "&e&lStarting Price");
public static final ConfigSetting GUI_SELL_AUCTION_ITEM_ITEMS_STARTING_PRICE_LORE = new ConfigSetting(config, "gui.sell auction item.items.starting price.lore", Arrays.asList(
"",
"&7The current starting price is&F: &a$%listing_start_price%",
"&7The current starting price is&F: &a%listing_start_price%",
"",
"&7Click to edit the starting price"
));
@ -1299,7 +1326,7 @@ public class Settings {
public static final ConfigSetting GUI_SELL_AUCTION_ITEM_ITEMS_INCREMENT_PRICE_NAME = new ConfigSetting(config, "gui.sell auction item.items.increment price.name", "&e&lIncrement Price");
public static final ConfigSetting GUI_SELL_AUCTION_ITEM_ITEMS_INCREMENT_PRICE_LORE = new ConfigSetting(config, "gui.sell auction item.items.increment price.lore", Arrays.asList(
"",
"&7The current increment price is&F: &a$%listing_increment_price%",
"&7The current increment price is&F: &a%listing_increment_price%",
"",
"&7Click to edit the increment price"
));
@ -1365,11 +1392,11 @@ public class Settings {
public static final ConfigSetting GUI_STATS_SELF_ITEMS_MONEY_EARNED_ITEM = new ConfigSetting(config, "gui.stat view self.items.money earned.item", XMaterial.LIME_STAINED_GLASS_PANE.name());
public static final ConfigSetting GUI_STATS_SELF_ITEMS_MONEY_EARNED_NAME = new ConfigSetting(config, "gui.stat view self.items.money earned.name", "&e&LMoney Earned");
public static final ConfigSetting GUI_STATS_SELF_ITEMS_MONEY_EARNED_LORE = new ConfigSetting(config, "gui.stat view self.items.money earned.lore", Collections.singletonList("&7You earned &a$%money_earned%"));
public static final ConfigSetting GUI_STATS_SELF_ITEMS_MONEY_EARNED_LORE = new ConfigSetting(config, "gui.stat view self.items.money earned.lore", Collections.singletonList("&7You earned &a%money_earned%"));
public static final ConfigSetting GUI_STATS_SELF_ITEMS_MONEY_SPENT_ITEM = new ConfigSetting(config, "gui.stat view self.items.money spent.item", XMaterial.RED_STAINED_GLASS_PANE.name());
public static final ConfigSetting GUI_STATS_SELF_ITEMS_MONEY_SPENT_NAME = new ConfigSetting(config, "gui.stat view self.items.money spent.name", "&e&LMoney Spent");
public static final ConfigSetting GUI_STATS_SELF_ITEMS_MONEY_SPENT_LORE = new ConfigSetting(config, "gui.stat view self.items.money spent.lore", Collections.singletonList("&7You spent &c$%money_spent%"));
public static final ConfigSetting GUI_STATS_SELF_ITEMS_MONEY_SPENT_LORE = new ConfigSetting(config, "gui.stat view self.items.money spent.lore", Collections.singletonList("&7You spent &c%money_spent%"));
public static final ConfigSetting GUI_STATS_LEADERBOARD_TITLE = new ConfigSetting(config, "gui.stat view leaderboard.items.title", "&7Auction House - &eStat Leaderboard");
public static final ConfigSetting GUI_STATS_LEADERBOARD_BG_ITEM = new ConfigSetting(config, "gui.stat view leaderboard.bg item", XMaterial.BLACK_STAINED_GLASS_PANE.name());
@ -1413,11 +1440,11 @@ public class Settings {
public static final ConfigSetting GUI_STATS_SEARCH_ITEMS_MONEY_EARNED_ITEM = new ConfigSetting(config, "gui.stat view other.items.money earned.item", XMaterial.LIME_STAINED_GLASS_PANE.name());
public static final ConfigSetting GUI_STATS_SEARCH_ITEMS_MONEY_EARNED_NAME = new ConfigSetting(config, "gui.stat view other.items.money earned.name", "&e&LMoney Earned");
public static final ConfigSetting GUI_STATS_SEARCH_ITEMS_MONEY_EARNED_LORE = new ConfigSetting(config, "gui.stat view other.items.money earned.lore", Collections.singletonList("&7They earned &a$%money_earned%"));
public static final ConfigSetting GUI_STATS_SEARCH_ITEMS_MONEY_EARNED_LORE = new ConfigSetting(config, "gui.stat view other.items.money earned.lore", Collections.singletonList("&7They earned &a%money_earned%"));
public static final ConfigSetting GUI_STATS_SEARCH_ITEMS_MONEY_SPENT_ITEM = new ConfigSetting(config, "gui.stat view other.items.money spent.item", XMaterial.RED_STAINED_GLASS_PANE.name());
public static final ConfigSetting GUI_STATS_SEARCH_ITEMS_MONEY_SPENT_NAME = new ConfigSetting(config, "gui.stat view other.items.money spent.name", "&e&LMoney Spent");
public static final ConfigSetting GUI_STATS_SEARCH_ITEMS_MONEY_SPENT_LORE = new ConfigSetting(config, "gui.stat view other.items.money spent.lore", Collections.singletonList("&7They spent &c$%money_spent%"));
public static final ConfigSetting GUI_STATS_SEARCH_ITEMS_MONEY_SPENT_LORE = new ConfigSetting(config, "gui.stat view other.items.money spent.lore", Collections.singletonList("&7They spent &c%money_spent%"));
/* ===============================
@ -1485,7 +1512,7 @@ public class Settings {
""
));
public static final ConfigSetting AUCTION_STACK_DETAILS_REQUEST_PRICE = new ConfigSetting(config, "auction stack.request price lines", Arrays.asList(
"&eOffering: &a$%request_price%"
"&eOffering: &a%request_price%"
));
public static final ConfigSetting AUCTION_STACK_DETAILS_REQUEST_COUNT = new ConfigSetting(config, "auction stack.request count lines", Arrays.asList(
@ -1494,16 +1521,16 @@ public class Settings {
));
public static final ConfigSetting AUCTION_STACK_DETAILS_BUY_NOW = new ConfigSetting(config, "auction stack.buy now lines", Arrays.asList(
"&eBuy Now: &a$%buynowprice%",
"&eBuy Now: &a%buynowprice%",
""
));
public static final ConfigSetting AUCTION_STACK_DETAILS_CURRENT_PRICE = new ConfigSetting(config, "auction stack.current price lines", Collections.singletonList(
"&eCurrent Price: &a$%currentprice%"
"&eCurrent Price: &a%currentprice%"
));
public static final ConfigSetting AUCTION_STACK_DETAILS_BID_INCREMENT = new ConfigSetting(config, "auction stack.bid increment lines", Collections.singletonList(
"&eBid Increment: &a$%bidincrement%"
"&eBid Increment: &a%bidincrement%"
));
public static final ConfigSetting AUCTION_STACK_DETAILS_HIGHEST_BIDDER = new ConfigSetting(config, "auction stack.highest bidder lines", Collections.singletonList(

View File

@ -46,6 +46,15 @@ public final class Settings extends SettingTemp {
public static ConfigEntry MYSQL_PASSWORD = create("settings.mysql.password", "password123", "The password of the database");
public static ConfigEntry MYSQL_PARAMS = create("settings.mysql.params", "?useUnicode=yes&characterEncoding=UTF-8&useServerPrepStmts=false&rewriteBatchedStatements=true&useSSL=true", "Do not touch this if you don't know what your doing");
/*
==============================================================
Multi-Server Options
==============================================================
*/
// public static ConfigEntry MULTI_SERVER_ENABLED = create("settings.multiserver.enabled", false, "Should Auction House run in multi-server mode?");
// public static ConfigEntry MULTI_SERVER_IS_MAIN = create("settings.multiserver.main sever", true, "Is this the main server for Auction House?");
// public static ConfigEntry MULTI_SERVER_SERVER_NAME = create("settings.multiserver.server name", Bukkit.getServer().getName(), "The name of this server");
/*
==============================================================
Economy Settings

View File

@ -126,6 +126,10 @@ public class TickAuctionsTask extends BukkitRunnable {
}
OfflinePlayer auctionWinner = Bukkit.getOfflinePlayer(auctionItem.getHighestBidder());
if (!auctionWinner.isOnline() && auctionItem.hasValidItemCurrency()) {
auctionItem.setExpired(true);
continue;
}
double finalPrice = auctionItem.getCurrentPrice();
double tax = Settings.TAX_ENABLED.getBoolean() ? (Settings.TAX_SALES_TAX_AUCTION_WON_PERCENTAGE.getDouble() / 100) * auctionItem.getCurrentPrice() : 0D;
@ -146,20 +150,23 @@ public class TickAuctionsTask extends BukkitRunnable {
if (!Settings.BIDDING_TAKES_MONEY.getBoolean())
AuctionAPI.getInstance().withdrawBalance(auctionWinner, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice);
AuctionAPI.getInstance().withdrawBalance(auctionWinner, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice, auctionItem);
AuctionAPI.getInstance().depositBalance(Bukkit.getOfflinePlayer(auctionItem.getOwner()), Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax, auctionItem.getItem(), auctionWinner);
AuctionAPI.getInstance().depositBalance(Bukkit.getOfflinePlayer(auctionItem.getOwner()), Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax, auctionItem.getItem(), auctionWinner, auctionItem);
// alert seller and buyer
if (Bukkit.getOfflinePlayer(auctionItem.getOwner()).isOnline()) {
AuctionHouse.getInstance().getLocale().getMessage("auction.itemsold")
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack))
.processPlaceholder("amount", itemStack.clone().getAmount())
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("buyer_name", Bukkit.getOfflinePlayer(auctionItem.getHighestBidder()).getName())
.processPlaceholder("buyer_displayname", AuctionAPI.getInstance().getDisplayName(Bukkit.getOfflinePlayer(auctionItem.getHighestBidder())))
.sendPrefixedMessage(Bukkit.getOfflinePlayer(auctionItem.getOwner()).getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(Bukkit.getOfflinePlayer(auctionItem.getOwner())))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax)).sendPrefixedMessage(Bukkit.getOfflinePlayer(auctionItem.getOwner()).getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd")
.processPlaceholder("player_balance", AuctionHouse.getCurrencyManager().getFormattedBalance(Bukkit.getOfflinePlayer(auctionItem.getOwner()), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.sendPrefixedMessage(Bukkit.getOfflinePlayer(auctionItem.getOwner()).getPlayer());
}
if (auctionWinner.isOnline()) {
@ -167,11 +174,14 @@ public class TickAuctionsTask extends BukkitRunnable {
AuctionHouse.getInstance().getLocale().getMessage("auction.bidwon")
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack))
.processPlaceholder("amount", itemStack.getAmount())
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.sendPrefixedMessage(auctionWinner.getPlayer());
if (!Settings.BIDDING_TAKES_MONEY.getBoolean())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(AuctionHouse.getCurrencyManager().getBalance(auctionWinner.getPlayer()))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice)).sendPrefixedMessage(auctionWinner.getPlayer());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove")
.processPlaceholder("player_balance", AuctionHouse.getCurrencyManager().getFormattedBalance(auctionWinner.getPlayer(), auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.processPlaceholder("price", AuctionHouse.getAPI().getFinalizedCurrencyNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice, auctionItem.getCurrency(), auctionItem.getCurrencyItem()))
.sendPrefixedMessage(auctionWinner.getPlayer());
// remove the dupe tracking
NBT.modify(itemStack, nbt -> {
@ -180,22 +190,12 @@ public class TickAuctionsTask extends BukkitRunnable {
// handle full inventory
if (auctionWinner.getPlayer().getInventory().firstEmpty() == -1) {
if (Settings.ALLOW_PURCHASE_IF_INVENTORY_FULL.getBoolean()) {
if (Settings.SYNCHRONIZE_ITEM_ADD.getBoolean())
AuctionHouse.newChain().sync(() -> PlayerUtils.giveItem(auctionWinner.getPlayer(), itemStack)).execute();
else
PlayerUtils.giveItem(auctionWinner.getPlayer(), itemStack);
AuctionHouse.getAuctionItemManager().sendToGarbage(auctionItem);
AuctionHouse.newChain().sync(() -> PlayerUtils.giveItem(auctionWinner.getPlayer(), itemStack)).execute();
continue;
}
} else {
if (Settings.SYNCHRONIZE_ITEM_ADD.getBoolean())
AuctionHouse.newChain().sync(() -> PlayerUtils.giveItem(auctionWinner.getPlayer(), itemStack)).execute();
else
PlayerUtils.giveItem(auctionWinner.getPlayer(), itemStack);
AuctionHouse.newChain().sync(() -> PlayerUtils.giveItem(auctionWinner.getPlayer(), itemStack)).execute();
AuctionHouse.getAuctionItemManager().sendToGarbage(auctionItem);
continue;
}