From 47e3a8d9667cc837c92489662f28404fdc79f013 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Sun, 2 Jun 2024 14:57:10 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=88=EF=B8=8F=20move=20transaction=20menus?= =?UTF-8?q?=20to=20new=20gui=20layout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 41 minutes --- .../guis/transaction/GUITransactionList.java | 170 ++++++++---------- .../guis/transaction/GUITransactionType.java | 49 ++--- .../guis/transaction/GUITransactionView.java | 84 +++++---- 3 files changed, 152 insertions(+), 151 deletions(-) diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionList.java b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionList.java index 083359d..69631a2 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionList.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionList.java @@ -24,15 +24,18 @@ import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory; import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType; import ca.tweetzy.auctionhouse.auction.enums.AuctionSortType; -import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui; import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse; +import ca.tweetzy.auctionhouse.guis.abstraction.AuctionPagedGUI; import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; -import ca.tweetzy.auctionhouse.helpers.MaterialCategorizer; +import ca.tweetzy.auctionhouse.model.MaterialCategorizer; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.auctionhouse.transaction.Transaction; import ca.tweetzy.auctionhouse.transaction.TransactionViewFilter; import ca.tweetzy.core.compatibility.XSound; +import ca.tweetzy.core.gui.events.GuiClickEvent; import ca.tweetzy.core.utils.TextUtils; +import ca.tweetzy.flight.utils.QuickItem; +import ca.tweetzy.flight.utils.Replacer; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -48,11 +51,9 @@ import java.util.stream.Collectors; * Time Created: 7:03 p.m. * Usage of any code found within this class is prohibited unless given explicit permission otherwise */ -public class GUITransactionList extends AbstractPlaceholderGui { +public class GUITransactionList extends AuctionPagedGUI { - List transactions; final AuctionPlayer auctionPlayer; - final Player player; final boolean showAll; private UUID searchUUID; @@ -63,100 +64,57 @@ public class GUITransactionList extends AbstractPlaceholderGui { } public GUITransactionList(Player player, boolean showAll) { - super(player); - this.player = player; - final AuctionHouse instance = AuctionHouse.getInstance(); - this.auctionPlayer = instance.getAuctionPlayerManager().getPlayer(this.player.getUniqueId()); + super(null, player, showAll ? Settings.GUI_TRANSACTIONS_TITLE_ALL.getString() : Settings.GUI_TRANSACTIONS_TITLE.getString(), 6, new ArrayList<>()); + this.auctionPlayer = AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(player.getUniqueId()); this.showAll = showAll; - if (showAll) - this.transactions = new ArrayList<>(instance.getTransactionManager().getTransactions().values()); - else - this.transactions = instance.getTransactionManager().getTransactions().values().stream().filter(transaction -> transaction.getSeller().equals(player.getUniqueId()) || transaction.getBuyer().equals(player.getUniqueId())).collect(Collectors.toList()); - - - setTitle(TextUtils.formatText(showAll ? Settings.GUI_TRANSACTIONS_TITLE_ALL.getString() : Settings.GUI_TRANSACTIONS_TITLE.getString())); - setRows(6); setAcceptsItems(false); - setNavigateSound(XSound.matchXSound(Settings.SOUNDS_NAVIGATE_GUI_PAGES.getString()).orElse(XSound.ENTITY_BAT_TAKEOFF).parseSound()); draw(); } - private void draw() { + @Override + protected void prePopulate() { + this.items = this.showAll ? new ArrayList<>(AuctionHouse.getInstance().getTransactionManager().getTransactions().values()) : AuctionHouse.getInstance().getTransactionManager().getTransactions().values().stream().filter(transaction -> transaction.getSeller().equals(player.getUniqueId()) || transaction.getBuyer().equals(player.getUniqueId())).collect(Collectors.toList()); + + + if (this.searchUUID != null) + this.items = this.items.stream().filter(transaction -> transaction.getSeller().equals(this.searchUUID) || transaction.getBuyer().equals(this.searchUUID)).collect(Collectors.toList()); + + // perform filter + if (this.auctionPlayer.getSelectedTransactionFilter() != AuctionItemCategory.ALL && this.auctionPlayer.getSelectedTransactionFilter() != AuctionItemCategory.SEARCH && this.auctionPlayer.getSelectedTransactionFilter() != AuctionItemCategory.SELF) { + this.items = this.items.stream().filter(item -> MaterialCategorizer.getMaterialCategory(item.getItem()) == this.auctionPlayer.getSelectedTransactionFilter()).collect(Collectors.toList()); + } + + if (this.auctionPlayer.getSelectedTransactionSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM) { + this.items = this.items.stream().filter(transaction -> transaction.getAuctionSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM).collect(Collectors.toList()); + } + + if (this.auctionPlayer.getSelectedTransactionSaleType() == AuctionSaleType.WITHOUT_BIDDING_SYSTEM) { + this.items = this.items.stream().filter(transaction -> transaction.getAuctionSaleType() == AuctionSaleType.WITHOUT_BIDDING_SYSTEM).collect(Collectors.toList()); + } + + if (this.auctionPlayer.getTransactionViewFilter() != TransactionViewFilter.ALL) { + if (this.auctionPlayer.getTransactionViewFilter() == TransactionViewFilter.BOUGHT) + this.items = this.items.stream().filter(transaction -> transaction.getBuyer().equals(this.player.getUniqueId())).collect(Collectors.toList()); + + if (this.auctionPlayer.getTransactionViewFilter() == TransactionViewFilter.SOLD) + this.items = this.items.stream().filter(transaction -> transaction.getSeller().equals(this.player.getUniqueId())).collect(Collectors.toList()); + } + + if (this.auctionPlayer.getTransactionSortType() == AuctionSortType.PRICE) { + this.items = this.items.stream().sorted(Comparator.comparingDouble(Transaction::getFinalPrice).reversed()).collect(Collectors.toList()); + } + + if (this.auctionPlayer.getTransactionSortType() == AuctionSortType.RECENT) { + this.items = this.items.stream().sorted(Comparator.comparingLong(Transaction::getTransactionTime).reversed()).collect(Collectors.toList()); + } + } + + @Override + protected void drawFixed() { reset(); - AuctionHouse.newChain().asyncFirst(() -> { - if (this.searchUUID != null) - this.transactions = this.transactions.stream().filter(transaction -> transaction.getSeller().equals(this.searchUUID) || transaction.getBuyer().equals(this.searchUUID)).collect(Collectors.toList()); - - // perform filter - if (this.auctionPlayer.getSelectedTransactionFilter() != AuctionItemCategory.ALL && this.auctionPlayer.getSelectedTransactionFilter() != AuctionItemCategory.SEARCH && this.auctionPlayer.getSelectedTransactionFilter() != AuctionItemCategory.SELF) { - this.transactions = this.transactions.stream().filter(item -> MaterialCategorizer.getMaterialCategory(item.getItem()) == this.auctionPlayer.getSelectedTransactionFilter()).collect(Collectors.toList()); - } - - if (this.auctionPlayer.getSelectedTransactionSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM) { - this.transactions = this.transactions.stream().filter(transaction -> transaction.getAuctionSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM).collect(Collectors.toList()); - } - - if (this.auctionPlayer.getSelectedTransactionSaleType() == AuctionSaleType.WITHOUT_BIDDING_SYSTEM) { - this.transactions = this.transactions.stream().filter(transaction -> transaction.getAuctionSaleType() == AuctionSaleType.WITHOUT_BIDDING_SYSTEM).collect(Collectors.toList()); - } - - if (this.auctionPlayer.getTransactionViewFilter() != TransactionViewFilter.ALL) { - if (this.auctionPlayer.getTransactionViewFilter() == TransactionViewFilter.BOUGHT) - this.transactions = this.transactions.stream().filter(transaction -> transaction.getBuyer().equals(this.player.getUniqueId())).collect(Collectors.toList()); - - if (this.auctionPlayer.getTransactionViewFilter() == TransactionViewFilter.SOLD) - this.transactions = this.transactions.stream().filter(transaction -> transaction.getSeller().equals(this.player.getUniqueId())).collect(Collectors.toList()); - } - - if (this.auctionPlayer.getTransactionSortType() == AuctionSortType.PRICE) { - this.transactions = this.transactions.stream().sorted(Comparator.comparingDouble(Transaction::getFinalPrice).reversed()).collect(Collectors.toList()); - } - - if (this.auctionPlayer.getTransactionSortType() == AuctionSortType.RECENT) { - this.transactions = this.transactions.stream().sorted(Comparator.comparingLong(Transaction::getTransactionTime).reversed()).collect(Collectors.toList()); - } - - return this.transactions.stream().skip((page - 1) * 45L).limit(45).collect(Collectors.toList()); - - }).asyncLast((data) -> { - pages = (int) Math.max(1, Math.ceil(this.transactions.size() / (double) 45L)); - setPrevPage(5, 3, getPreviousPageItem()); - setButton(5, 4, getRefreshButtonItem(), e -> e.manager.showGUI(e.player, new GUITransactionList(this.player, this.showAll))); - setNextPage(5, 5, getNextPageItem()); - setOnPage(e -> draw()); - - int slot = 0; - final String SERVER_LISTING_NAME = AuctionHouse.getInstance().getLocale().getMessage("general.server listing").getMessage(); - - - for (Transaction transaction : data) { - final ItemStack item = transaction.getItem().clone(); - final OfflinePlayer seller = Bukkit.getOfflinePlayer(transaction.getSeller()); - - setButton(slot++, ConfigurationItemHelper.createConfigurationItem(this.player, item, Settings.GUI_TRANSACTIONS_ITEM_TRANSACTION_NAME.getString(), Settings.GUI_TRANSACTIONS_ITEM_TRANSACTION_LORE.getStringList(), new HashMap() {{ - put("%transaction_id%", transaction.getId().toString()); - put("%seller%", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME); - put("%buyer%", Bukkit.getOfflinePlayer(transaction.getBuyer()).getName()); - put("%date%", AuctionAPI.getInstance().convertMillisToDate(transaction.getTransactionTime())); - put("%item_name%", AuctionAPI.getInstance().getItemName(item)); - }}), e -> { - - if (e.clickType == ClickType.DROP && (player.isOp() || player.hasPermission("auctionhouse.admin"))) { - AuctionHouse.getInstance().getDataManager().deleteTransactions(Collections.singleton(transaction.getId())); - AuctionHouse.getInstance().getTransactionManager().removeTransaction(transaction.getId()); - e.manager.showGUI(e.player, new GUITransactionList(this.player, this.showAll)); - } - - if (e.clickType == ClickType.LEFT) - e.manager.showGUI(e.player, new GUITransactionView(this.auctionPlayer, transaction, this.showAll)); - }); - } - - }).execute(); - // Other Buttons - setButton(5, 0, getBackButtonItem(), e -> { + setButton(5, 0, getBackButton(), e -> { if (Settings.RESTRICT_ALL_TRANSACTIONS_TO_PERM.getBoolean() && !e.player.hasPermission("auctionhouse.transactions.viewall")) { e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); } else { @@ -210,4 +168,34 @@ public class GUITransactionList extends AbstractPlaceholderGui { } }); } + + @Override + protected ItemStack makeDisplayItem(Transaction transaction) { + final ItemStack item = transaction.getItem().clone(); + final OfflinePlayer seller = Bukkit.getOfflinePlayer(transaction.getSeller()); + final String SERVER_LISTING_NAME = AuctionHouse.getInstance().getLocale().getMessage("general.server listing").getMessage(); + + return QuickItem + .of(item) + .name(Replacer.replaceVariables(Settings.GUI_TRANSACTIONS_ITEM_TRANSACTION_NAME.getString(),"transaction_id", transaction.getId().toString())) + .lore(Replacer.replaceVariables(Settings.GUI_TRANSACTIONS_ITEM_TRANSACTION_LORE.getStringList(), + "transaction_id",transaction.getId().toString(), + "seller", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME, + "buyer", Bukkit.getOfflinePlayer(transaction.getBuyer()).getName(), + "date", AuctionAPI.getInstance().convertMillisToDate(transaction.getTransactionTime()), + "item_name", AuctionAPI.getInstance().getItemName(item) + )).make(); + } + + @Override + protected void onClick(Transaction transaction, GuiClickEvent click) { + if (click.clickType == ClickType.DROP && (player.isOp() || player.hasPermission("auctionhouse.admin"))) { + AuctionHouse.getInstance().getDataManager().deleteTransactions(Collections.singleton(transaction.getId())); + AuctionHouse.getInstance().getTransactionManager().removeTransaction(transaction.getId()); + click.manager.showGUI(click.player, new GUITransactionList(this.player, this.showAll)); + } + + if (click.clickType == ClickType.LEFT) + click.manager.showGUI(click.player, new GUITransactionView(this.auctionPlayer, transaction, this.showAll)); + } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionType.java b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionType.java index 0731317..6a47664 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionType.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionType.java @@ -20,14 +20,13 @@ package ca.tweetzy.auctionhouse.guis.transaction; import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.api.AuctionAPI; -import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui; import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse; -import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; +import ca.tweetzy.auctionhouse.guis.abstraction.AuctionBaseGUI; import ca.tweetzy.auctionhouse.helpers.input.TitleInput; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.auctionhouse.transaction.Transaction; import ca.tweetzy.core.utils.NumberUtils; -import ca.tweetzy.core.utils.TextUtils; +import ca.tweetzy.flight.utils.QuickItem; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -41,25 +40,27 @@ import java.util.*; * Time Created: 5:32 p.m. * Usage of any code found within this class is prohibited unless given explicit permission otherwise */ -public final class GUITransactionType extends AbstractPlaceholderGui { +public final class GUITransactionType extends AuctionBaseGUI { - private final Player player; public GUITransactionType(Player player) { - super(player); - this.player = player; - setTitle(TextUtils.formatText(Settings.GUI_TRANSACTIONS_TYPE_TITLE.getString())); - setRows(4); - setAcceptsItems(false); - setUseLockedCells(true); - setDefaultItem(ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_TRANSACTIONS_TYPE_BG_ITEM.getString())); + super(new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(player.getUniqueId())), player, Settings.GUI_TRANSACTIONS_TYPE_TITLE.getString(), 4); + setDefaultItem(QuickItem.bg(QuickItem.of(Settings.GUI_TRANSACTIONS_TYPE_BG_ITEM.getString()).make())); draw(); } - private void draw() { + @Override + protected void draw() { + applyBackExit(); + final AuctionHouse instance = AuctionHouse.getInstance(); -// (player.hasPermission("auctionhouse.admin") || player.isOp()) - setButton(11, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_TRANSACTIONS_TYPE_ITEMS_ALL_TRANSACTIONS_ITEM.getString(), Settings.GUI_TRANSACTIONS_TYPE_ITEMS_ALL_TRANSACTIONS_NAME.getString(), Settings.GUI_TRANSACTIONS_TYPE_ITEMS_ALL_TRANSACTIONS_LORE.getStringList(), null), e -> { + + setButton(11, QuickItem + .of(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_ALL_TRANSACTIONS_ITEM.getString()) + .name(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_ALL_TRANSACTIONS_NAME.getString()) + .lore(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_ALL_TRANSACTIONS_LORE.getStringList()) + .make(), e -> { + if (Settings.RESTRICT_ALL_TRANSACTIONS_TO_PERM.getBoolean() && !e.player.hasPermission("auctionhouse.transactions.viewall")) { instance.getLocale().getMessage("commands.no_permission").sendPrefixedMessage(e.player); return; @@ -68,12 +69,20 @@ public final class GUITransactionType extends AbstractPlaceholderGui { e.manager.showGUI(e.player, new GUITransactionList(e.player, true)); }); - setButton(15, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_ITEM.getString(), Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_NAME.getString(), Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_LORE.getStringList(), null), e -> { - e.manager.showGUI(e.player, new GUITransactionList(e.player, false)); - }); + setButton(15, QuickItem + .of(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_ITEM.getString()) + .name(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_NAME.getString()) + .lore(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_LORE.getStringList()) + .make(), e -> e.manager.showGUI(e.player, new GUITransactionList(e.player, false))); if (player.isOp() || player.hasPermission("auctionhouse.admin")) { - setButton(3, 8, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_TRANSACTIONS_TYPE_ITEMS_DELETE_ITEM.getString(), Settings.GUI_TRANSACTIONS_TYPE_ITEMS_DELETE_NAME.getString(), Settings.GUI_TRANSACTIONS_TYPE_ITEMS_DELETE_LORE.getStringList(), null), e -> { + + setButton(3, 8, QuickItem + .of(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_DELETE_ITEM.getString()) + .name(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_DELETE_NAME.getString()) + .lore(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_DELETE_LORE.getStringList()) + .make(), e -> { + e.gui.close(); new TitleInput(player, AuctionHouse.getInstance().getLocale().getMessage("titles.enter deletion range.title").getMessage(), AuctionHouse.getInstance().getLocale().getMessage("titles.enter deletion range.subtitle").getMessage()) { @@ -125,7 +134,5 @@ public final class GUITransactionType extends AbstractPlaceholderGui { }; }); } - - setButton(3, 0, getBackButtonItem(), null, e -> e.manager.showGUI(e.player, new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(e.player.getUniqueId())))); } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionView.java b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionView.java index 6c869ee..eea9222 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionView.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionView.java @@ -22,68 +22,74 @@ import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.api.AuctionAPI; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType; -import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui; -import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; +import ca.tweetzy.auctionhouse.guis.abstraction.AuctionBaseGUI; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.auctionhouse.transaction.Transaction; -import ca.tweetzy.core.utils.TextUtils; +import ca.tweetzy.flight.utils.QuickItem; +import ca.tweetzy.flight.utils.Replacer; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import java.util.HashMap; - /** * The current file has been created by Kiran Hart * Date Created: March 22 2021 * Time Created: 7:04 p.m. * Usage of any code found within this class is prohibited unless given explicit permission otherwise */ -public class GUITransactionView extends AbstractPlaceholderGui { +public class GUITransactionView extends AuctionBaseGUI { + + private final Transaction transaction; public GUITransactionView(AuctionPlayer auctionPlayer, Transaction transaction, boolean showAll) { - super(auctionPlayer); - setTitle(TextUtils.formatText(Settings.GUI_TRANSACTION_VIEW_TITLE.getString())); - setRows(6); - setAcceptsItems(false); - setDefaultItem(ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_TRANSACTION_VIEW_BACKGROUND_ITEM.getString())); + super(new GUITransactionList(auctionPlayer.getPlayer(), showAll), auctionPlayer.getPlayer(), Settings.GUI_TRANSACTION_VIEW_TITLE.getString(), 6); + setDefaultItem(QuickItem.bg(QuickItem.of(Settings.GUI_TRANSACTION_VIEW_BACKGROUND_ITEM.getString()).make())); setUseLockedCells(Settings.GUI_TRANSACTION_VIEW_BACKGROUND_FILL.getBoolean()); + this.transaction = transaction; + + draw(); + } + + @Override + protected void draw() { + applyBackExit(); - setButton(5, 0, getBackButtonItem(), e -> e.manager.showGUI(e.player, new GUITransactionList(auctionPlayer.getPlayer(), showAll))); setItem(1, 4, transaction.getItem()); final String SERVER_LISTING_NAME = AuctionHouse.getInstance().getLocale().getMessage("general.server listing").getMessage(); final OfflinePlayer seller = Bukkit.getOfflinePlayer(transaction.getSeller()); final OfflinePlayer buyer = Bukkit.getOfflinePlayer(transaction.getBuyer()); + setItem(3, 2, QuickItem + .of(AuctionAPI.getInstance().getPlayerHead(seller.getName())) + .name(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_SELLER_NAME.getString(), "seller", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME)) + .lore(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_SELLER_LORE.getStringList(), + "transaction_id", transaction.getId().toString(), + "seller", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME, + "buyer", buyer.getName(), + "date", AuctionAPI.getInstance().convertMillisToDate(transaction.getTransactionTime()))) + .make()); - setItem(3, 2, ConfigurationItemHelper.createConfigurationItem( - this.player, - AuctionAPI.getInstance().getPlayerHead(seller.getName()), - Settings.GUI_TRANSACTION_VIEW_ITEM_SELLER_NAME.getString(), - Settings.GUI_TRANSACTION_VIEW_ITEM_SELLER_LORE.getStringList(), new HashMap() {{ - put("%transaction_id%", transaction.getId().toString()); - put("%seller%", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME); - put("%buyer%", buyer.getName()); - put("%date%", AuctionAPI.getInstance().convertMillisToDate(transaction.getTransactionTime())); - }})); + setItem(3, 6, QuickItem + .of(AuctionAPI.getInstance().getPlayerHead(Bukkit.getOfflinePlayer(transaction.getBuyer()).getName())) + .name(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_BUYER_NAME.getString(), "buyer", buyer.getName())) + .lore(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_BUYER_LORE.getStringList(), + "transaction_id", transaction.getId().toString(), + "seller", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME, + "buyer", buyer.getName(), + "date", AuctionAPI.getInstance().convertMillisToDate(transaction.getTransactionTime()))) + .make()); - setItem(3, 6, ConfigurationItemHelper.createConfigurationItem( - this.player, - AuctionAPI.getInstance().getPlayerHead(Bukkit.getOfflinePlayer(transaction.getBuyer()).getName()), - Settings.GUI_TRANSACTION_VIEW_ITEM_BUYER_NAME.getString(), - Settings.GUI_TRANSACTION_VIEW_ITEM_BUYER_LORE.getStringList(), new HashMap() {{ - put("%transaction_id%", transaction.getId().toString()); - put("%seller%", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME); - put("%buyer%", buyer.getName()); - put("%date%", AuctionAPI.getInstance().convertMillisToDate(transaction.getTransactionTime())); - }})); - setItem(3, 4, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_ITEM.getString(), Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_NAME.getString(), Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_LORE.getStringList(), new HashMap() {{ - put("%transaction_id%", transaction.getId().toString()); - put("%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()); - put("%transaction_date%", AuctionAPI.getInstance().convertMillisToDate(transaction.getTransactionTime())); - put("%final_price%", AuctionAPI.getInstance().formatNumber(transaction.getFinalPrice())); - put("%item_name%", AuctionAPI.getInstance().getItemName(transaction.getItem())); - }})); + setItem(3, 4, QuickItem + .of(Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_ITEM.getString()) + .name(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_NAME.getString(), "transaction_id", transaction.getId().toString())) + .lore(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_LORE.getStringList(), + "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()), + "item_name", AuctionAPI.getInstance().getItemName(transaction.getItem()) + )) + .make()); } }