mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-22 05:25:11 +01:00
2.8.0
This commit is contained in:
parent
5ad08b99cd
commit
49a51e7d0f
@ -241,4 +241,15 @@ public class AuctionAPI {
|
||||
Matcher matcher = patt.matcher(sentence);
|
||||
return matcher.find();
|
||||
}
|
||||
|
||||
public String formatNumber(double number) {
|
||||
String formatted = String.format("%,.2f", number);
|
||||
return Settings.USE_ALTERNATE_CURRENCY_FORMAT.getBoolean() ? replaceLast(formatted.replace(",", "."), ".", ",") : formatted;
|
||||
}
|
||||
|
||||
private String replaceLast(String string, String substring, String replacement) {
|
||||
int index = string.lastIndexOf(substring);
|
||||
if (index == -1) return string;
|
||||
return string.substring(0, index) + replacement + string.substring(index + substring.length());
|
||||
}
|
||||
}
|
||||
|
@ -82,9 +82,9 @@ public class AuctionItem implements Serializable {
|
||||
|
||||
String theSeller = (this.owner == null) ? "&eSeller Name???" : Bukkit.getOfflinePlayer(this.owner).getName();
|
||||
String highestBidder = (this.bidStartPrice <= 0 || this.bidIncPrice <= 0) ? "" : (this.owner.equals(this.highestBidder)) ? Bukkit.getOfflinePlayer(this.owner).getName() : (Bukkit.getOfflinePlayer(this.highestBidder).isOnline()) ? Bukkit.getOfflinePlayer(this.highestBidder).getPlayer().getName() : "Offline";
|
||||
String basePrice = Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.basePrice) : String.format("%,.2f", this.basePrice);
|
||||
String bidIncPrice = (this.bidStartPrice <= 0 || this.bidIncPrice <= 0) ? "0" : Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.bidIncPrice) : String.format("%,.2f", this.bidIncPrice);
|
||||
String currentPrice = (this.bidStartPrice <= 0 || this.bidIncPrice <= 0) ? "0" : Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.currentPrice) : String.format("%,.2f", this.currentPrice);
|
||||
String basePrice = Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.basePrice) : AuctionAPI.getInstance().formatNumber(this.basePrice);// base
|
||||
String bidIncPrice = (this.bidStartPrice <= 0 || this.bidIncPrice <= 0) ? "0" : Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.bidIncPrice) : AuctionAPI.getInstance().formatNumber(this.bidIncPrice);
|
||||
String currentPrice = (this.bidStartPrice <= 0 || this.bidIncPrice <= 0) ? "0" : Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.currentPrice) : AuctionAPI.getInstance().formatNumber(this.currentPrice);
|
||||
|
||||
long[] times = AuctionAPI.getInstance().getRemainingTimeValues(this.remainingTime);
|
||||
List<String> preLore = type == AuctionStackType.MAIN_AUCTION_HOUSE ? this.bidStartPrice <= 0 || this.bidIncPrice <= 0 ? Settings.AUCTION_ITEM_AUCTION_STACK.getStringList() : Settings.AUCTION_ITEM_AUCTION_STACK_WITH_BID.getStringList() : this.bidStartPrice <= 0 ? Settings.AUCTION_ITEM_LISTING_STACK.getStringList() : Settings.AUCTION_ITEM_LISTING_STACK_WITH_BID.getStringList();
|
||||
|
@ -143,7 +143,7 @@ public class CommandSell extends AbstractCommand {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("auction.listed.nobid")
|
||||
.processPlaceholder("amount", itemToSell.getAmount())
|
||||
.processPlaceholder("item", WordUtils.capitalizeFully(itemToSell.getType().name().replace("_", " ")))
|
||||
.processPlaceholder("base_price", String.format("%,.2f", basePrice))
|
||||
.processPlaceholder("base_price", AuctionAPI.getInstance().formatNumber(basePrice))
|
||||
.sendPrefixedMessage(player);
|
||||
|
||||
if (Settings.BROADCAST_AUCTION_LIST.getBoolean()) {
|
||||
@ -151,7 +151,7 @@ public class CommandSell extends AbstractCommand {
|
||||
.processPlaceholder("player", player.getName())
|
||||
.processPlaceholder("amount", itemToSell.getAmount())
|
||||
.processPlaceholder("item", WordUtils.capitalizeFully(itemToSell.getType().name().replace("_", " ")))
|
||||
.processPlaceholder("base_price", String.format("%,.2f", basePrice))::sendPrefixedMessage);
|
||||
.processPlaceholder("base_price", AuctionAPI.getInstance().formatNumber(basePrice))::sendPrefixedMessage);
|
||||
}
|
||||
|
||||
PlayerUtils.takeActiveItem(player, CompatibleHand.MAIN_HAND, itemToSell.getAmount());
|
||||
@ -242,9 +242,9 @@ public class CommandSell extends AbstractCommand {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("auction.listed.withbid")
|
||||
.processPlaceholder("amount", itemToSell.getAmount())
|
||||
.processPlaceholder("item", WordUtils.capitalizeFully(itemToSell.getType().name().replace("_", " ")))
|
||||
.processPlaceholder("base_price", String.format("%,.2f", basePrice))
|
||||
.processPlaceholder("start_price", String.format("%,.2f", bidStartPrice))
|
||||
.processPlaceholder("increment_price", String.format("%,.2f", bidIncPrice))
|
||||
.processPlaceholder("base_price", AuctionAPI.getInstance().formatNumber(basePrice))
|
||||
.processPlaceholder("start_price", AuctionAPI.getInstance().formatNumber(bidStartPrice))
|
||||
.processPlaceholder("increment_price", AuctionAPI.getInstance().formatNumber(bidIncPrice))
|
||||
.sendPrefixedMessage(player);
|
||||
|
||||
if (Settings.BROADCAST_AUCTION_LIST.getBoolean()) {
|
||||
@ -252,9 +252,9 @@ public class CommandSell extends AbstractCommand {
|
||||
.processPlaceholder("player", player.getName())
|
||||
.processPlaceholder("amount", itemToSell.getAmount())
|
||||
.processPlaceholder("item", WordUtils.capitalizeFully(itemToSell.getType().name().replace("_", " ")))
|
||||
.processPlaceholder("base_price", String.format("%,.2f", basePrice))
|
||||
.processPlaceholder("start_price", String.format("%,.2f", bidStartPrice))
|
||||
.processPlaceholder("increment_price", String.format("%,.2f", bidIncPrice))::sendPrefixedMessage);
|
||||
.processPlaceholder("base_price", AuctionAPI.getInstance().formatNumber(basePrice))
|
||||
.processPlaceholder("start_price", AuctionAPI.getInstance().formatNumber(bidStartPrice))
|
||||
.processPlaceholder("increment_price", AuctionAPI.getInstance().formatNumber(bidIncPrice))::sendPrefixedMessage);
|
||||
}
|
||||
|
||||
PlayerUtils.takeActiveItem(player, CompatibleHand.MAIN_HAND, itemToSell.getAmount());
|
||||
|
@ -101,6 +101,7 @@ public class GUIAuctionHouse extends Gui {
|
||||
// Other Buttons
|
||||
setButton(5, 0, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%active_player_auctions%", auctionPlayer.getItems(false).size());
|
||||
put("%player_balance%", AuctionAPI.getInstance().formatNumber(AuctionHouse.getInstance().getEconomy().getBalance(auctionPlayer.getPlayer())));
|
||||
}}), e -> {
|
||||
cleanup();
|
||||
e.manager.showGUI(e.player, new GUIActiveAuctions(this.auctionPlayer));
|
||||
@ -139,7 +140,12 @@ public class GUIAuctionHouse extends Gui {
|
||||
}
|
||||
});
|
||||
|
||||
setButton(5, 6, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_LORE.getStringList(), null), e -> e.manager.showGUI(e.player, new GUITransactionList(this.auctionPlayer)));
|
||||
// this could be done better tbh
|
||||
setButton(5, 6, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_LORE.getStringList(), new HashMap<String, Object>(){{
|
||||
put("%total_items_bought%", AuctionHouse.getInstance().getTransactionManager().getTransactions().stream().filter(transaction -> transaction.getBuyer().equals(auctionPlayer.getPlayer().getUniqueId())).count());
|
||||
put("%total_items_sold%", AuctionHouse.getInstance().getTransactionManager().getTransactions().stream().filter(transaction -> transaction.getSeller().equals(auctionPlayer.getPlayer().getUniqueId())).count());
|
||||
}}), e -> e.manager.showGUI(e.player, new GUITransactionList(this.auctionPlayer)));
|
||||
|
||||
setButton(5, 7, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_LORE.getStringList(), null), null);
|
||||
setButton(5, 8, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_GUIDE_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_GUIDE_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_GUIDE_LORE.getStringList(), null), null);
|
||||
|
||||
|
@ -148,14 +148,14 @@ public class GUIConfirmPurchase extends Gui {
|
||||
}
|
||||
|
||||
private void sendMessages(GuiClickEvent e, AuctionItem located, boolean overwritePrice, double price) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("price", String.format("%,.2f", overwritePrice ? price : located.getBasePrice())).sendPrefixedMessage(e.player);
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(overwritePrice ? price : located.getBasePrice())).sendPrefixedMessage(e.player);
|
||||
if (Bukkit.getOfflinePlayer(located.getOwner()).isOnline()) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("auction.itemsold")
|
||||
.processPlaceholder("item", WordUtils.capitalizeFully(AuctionAPI.getInstance().deserializeItem(located.getRawItem()).getType().name().replace("_", " ")))
|
||||
.processPlaceholder("price", String.format("%,.2f", overwritePrice ? price : located.getBasePrice()))
|
||||
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(overwritePrice ? price : located.getBasePrice()))
|
||||
.processPlaceholder("buyer_name", e.player.getName())
|
||||
.sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer());
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("price", String.format("%,.2f", overwritePrice ? price : located.getBasePrice())).sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer());
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(overwritePrice ? price : located.getBasePrice())).sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,10 +178,10 @@ public class GUIConfirmPurchase extends Gui {
|
||||
private ItemStack getPurchaseInfoItem(int qty) {
|
||||
ItemStack stack = ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CONFIRM_QTY_INFO_ITEM.getString(), Settings.GUI_CONFIRM_QTY_INFO_NAME.getString(), Settings.GUI_CONFIRM_QTY_INFO_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%original_stack_size%", maxStackSize);
|
||||
put("%original_stack_price%", String.format("%,.2f", auctionItem.getBasePrice()));
|
||||
put("%price_per_item%", String.format("%,.2f", pricePerItem));
|
||||
put("%original_stack_price%", AuctionAPI.getInstance().formatNumber(auctionItem.getBasePrice()));
|
||||
put("%price_per_item%", AuctionAPI.getInstance().formatNumber(pricePerItem));
|
||||
put("%purchase_quantity%", purchaseQuantity);
|
||||
put("%purchase_price%", String.format("%,.2f", pricePerItem * purchaseQuantity));
|
||||
put("%purchase_price%", AuctionAPI.getInstance().formatNumber(pricePerItem * purchaseQuantity));
|
||||
}});
|
||||
stack.setAmount(qty);
|
||||
return stack;
|
||||
|
@ -43,7 +43,7 @@ public class GUITransactionView extends Gui {
|
||||
put("%transaction_id%", transaction.getId().toString());
|
||||
put("%sale_type%", transaction.getAuctionSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM ? "Won Auction" : "Bought Immediately");
|
||||
put("%transaction_date%", AuctionAPI.getInstance().convertMillisToDate(transaction.getTransactionTime()));
|
||||
put("%final_price%", String.format("%,.2f", transaction.getFinalPrice()));
|
||||
put("%final_price%", AuctionAPI.getInstance().formatNumber(transaction.getFinalPrice()));
|
||||
}}));
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ public class Settings {
|
||||
public static final ConfigSetting ASK_FOR_BID_CONFIRMATION = new ConfigSetting(config, "auction setting.ask for bid confirmation", true, "Should Auction House open the confirmation menu for the user to confirm", "whether they actually meant to place a bid or not?");
|
||||
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 USE_ALTERNATE_CURRENCY_FORMAT = new ConfigSetting(config, "auction setting.use alternate currency format", false, "If true, $123,456.78 will become $123.456,78");
|
||||
|
||||
/* ===============================
|
||||
* DATABASE OPTIONS
|
||||
@ -184,8 +185,11 @@ public class Settings {
|
||||
|
||||
public static final ConfigSetting GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_ITEM = new ConfigSetting(config, "gui.auction house.items.transactions.item", "PAPER");
|
||||
public static final ConfigSetting GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_NAME = new ConfigSetting(config, "gui.auction house.items.transactions.name", "&e&lTransactions");
|
||||
public static final ConfigSetting GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_LORE = new ConfigSetting(config, "gui.auction house.items.transactions.lore", Collections.singletonList(
|
||||
"&7Click to view transaction history"
|
||||
public static final ConfigSetting GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_LORE = new ConfigSetting(config, "gui.auction house.items.transactions.lore", Arrays.asList(
|
||||
"&7Click to view transaction history",
|
||||
"",
|
||||
"&eTotal Items Bought&f: &a%total_items_bought%",
|
||||
"&eTotal Items Sold&f: &a%total_items_sold%"
|
||||
));
|
||||
|
||||
public static final ConfigSetting GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_ITEM = new ConfigSetting(config, "gui.auction house.items.how to sell.item", "GOLD_INGOT");
|
||||
|
@ -72,17 +72,17 @@ public class TickAuctionsTask extends BukkitRunnable {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("auction.bidwon")
|
||||
.processPlaceholder("item", WordUtils.capitalizeFully(AuctionAPI.getInstance().deserializeItem(item.getRawItem()).getType().name().replace("_", " ")))
|
||||
.processPlaceholder("amount", AuctionAPI.getInstance().deserializeItem(item.getRawItem()).getAmount())
|
||||
.processPlaceholder("price", String.format("%,.2f", item.getCurrentPrice()))
|
||||
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(item.getCurrentPrice()))
|
||||
.sendPrefixedMessage(offlinePlayer.getPlayer());
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("price", String.format("%,.2f", item.getCurrentPrice())).sendPrefixedMessage(offlinePlayer.getPlayer());
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(item.getCurrentPrice())).sendPrefixedMessage(offlinePlayer.getPlayer());
|
||||
// if the original owner is online, let them know they sold an item
|
||||
if (Bukkit.getOfflinePlayer(item.getOwner()).isOnline()) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("auction.itemsold")
|
||||
.processPlaceholder("item", WordUtils.capitalizeFully(AuctionAPI.getInstance().deserializeItem(item.getRawItem()).getType().name().replace("_", " ")))
|
||||
.processPlaceholder("price", String.format("%,.2f", item.getCurrentPrice()))
|
||||
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(item.getCurrentPrice()))
|
||||
.processPlaceholder("buyer_name", Bukkit.getOfflinePlayer(item.getHighestBidder()).getPlayer().getName())
|
||||
.sendPrefixedMessage(Bukkit.getOfflinePlayer(item.getOwner()).getPlayer());
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("price", String.format("%,.2f", item.getCurrentPrice())).sendPrefixedMessage(Bukkit.getOfflinePlayer(item.getOwner()).getPlayer());
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(item.getCurrentPrice())).sendPrefixedMessage(Bukkit.getOfflinePlayer(item.getOwner()).getPlayer());
|
||||
}
|
||||
|
||||
// since they're online, try to add the item to their inventory
|
||||
@ -119,10 +119,10 @@ public class TickAuctionsTask extends BukkitRunnable {
|
||||
if (Bukkit.getOfflinePlayer(item.getOwner()).isOnline()) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("auction.itemsold")
|
||||
.processPlaceholder("item", WordUtils.capitalizeFully(AuctionAPI.getInstance().deserializeItem(item.getRawItem()).getType().name().replace("_", " ")))
|
||||
.processPlaceholder("price", String.format("%,.2f", item.getCurrentPrice()))
|
||||
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(item.getCurrentPrice()))
|
||||
.processPlaceholder("buyer_name", Bukkit.getOfflinePlayer(item.getHighestBidder()).getPlayer().getName())
|
||||
.sendPrefixedMessage(Bukkit.getOfflinePlayer(item.getOwner()).getPlayer());
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("price", String.format("%,.2f", item.getCurrentPrice())).sendPrefixedMessage(Bukkit.getOfflinePlayer(item.getOwner()).getPlayer());
|
||||
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(item.getCurrentPrice())).sendPrefixedMessage(Bukkit.getOfflinePlayer(item.getOwner()).getPlayer());
|
||||
}
|
||||
|
||||
item.setOwner(offlinePlayer.getUniqueId());
|
||||
|
Loading…
Reference in New Issue
Block a user