✈️ move transaction menus to new gui layout

Took 41 minutes
This commit is contained in:
Kiran Hart 2024-06-02 14:57:10 -04:00
parent ea22a27d9e
commit 47e3a8d966
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
3 changed files with 152 additions and 151 deletions

View File

@ -24,15 +24,18 @@ import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory; import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory;
import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType; import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType;
import ca.tweetzy.auctionhouse.auction.enums.AuctionSortType; import ca.tweetzy.auctionhouse.auction.enums.AuctionSortType;
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui;
import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse; import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse;
import ca.tweetzy.auctionhouse.guis.abstraction.AuctionPagedGUI;
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; 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.settings.Settings;
import ca.tweetzy.auctionhouse.transaction.Transaction; import ca.tweetzy.auctionhouse.transaction.Transaction;
import ca.tweetzy.auctionhouse.transaction.TransactionViewFilter; import ca.tweetzy.auctionhouse.transaction.TransactionViewFilter;
import ca.tweetzy.core.compatibility.XSound; import ca.tweetzy.core.compatibility.XSound;
import ca.tweetzy.core.gui.events.GuiClickEvent;
import ca.tweetzy.core.utils.TextUtils; 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.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -48,11 +51,9 @@ import java.util.stream.Collectors;
* Time Created: 7:03 p.m. * Time Created: 7:03 p.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise * 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<Transaction> {
List<Transaction> transactions;
final AuctionPlayer auctionPlayer; final AuctionPlayer auctionPlayer;
final Player player;
final boolean showAll; final boolean showAll;
private UUID searchUUID; private UUID searchUUID;
@ -63,100 +64,57 @@ public class GUITransactionList extends AbstractPlaceholderGui {
} }
public GUITransactionList(Player player, boolean showAll) { public GUITransactionList(Player player, boolean showAll) {
super(player); super(null, player, showAll ? Settings.GUI_TRANSACTIONS_TITLE_ALL.getString() : Settings.GUI_TRANSACTIONS_TITLE.getString(), 6, new ArrayList<>());
this.player = player; this.auctionPlayer = AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(player.getUniqueId());
final AuctionHouse instance = AuctionHouse.getInstance();
this.auctionPlayer = instance.getAuctionPlayerManager().getPlayer(this.player.getUniqueId());
this.showAll = showAll; 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); setAcceptsItems(false);
setNavigateSound(XSound.matchXSound(Settings.SOUNDS_NAVIGATE_GUI_PAGES.getString()).orElse(XSound.ENTITY_BAT_TAKEOFF).parseSound());
draw(); draw();
} }
private void draw() { @Override
reset(); 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());
AuctionHouse.newChain().asyncFirst(() -> {
if (this.searchUUID != null) if (this.searchUUID != null)
this.transactions = this.transactions.stream().filter(transaction -> transaction.getSeller().equals(this.searchUUID) || transaction.getBuyer().equals(this.searchUUID)).collect(Collectors.toList()); this.items = this.items.stream().filter(transaction -> transaction.getSeller().equals(this.searchUUID) || transaction.getBuyer().equals(this.searchUUID)).collect(Collectors.toList());
// perform filter // perform filter
if (this.auctionPlayer.getSelectedTransactionFilter() != AuctionItemCategory.ALL && this.auctionPlayer.getSelectedTransactionFilter() != AuctionItemCategory.SEARCH && this.auctionPlayer.getSelectedTransactionFilter() != AuctionItemCategory.SELF) { 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()); 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) { if (this.auctionPlayer.getSelectedTransactionSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM) {
this.transactions = this.transactions.stream().filter(transaction -> transaction.getAuctionSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM).collect(Collectors.toList()); this.items = this.items.stream().filter(transaction -> transaction.getAuctionSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM).collect(Collectors.toList());
} }
if (this.auctionPlayer.getSelectedTransactionSaleType() == AuctionSaleType.WITHOUT_BIDDING_SYSTEM) { if (this.auctionPlayer.getSelectedTransactionSaleType() == AuctionSaleType.WITHOUT_BIDDING_SYSTEM) {
this.transactions = this.transactions.stream().filter(transaction -> transaction.getAuctionSaleType() == AuctionSaleType.WITHOUT_BIDDING_SYSTEM).collect(Collectors.toList()); 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.ALL) {
if (this.auctionPlayer.getTransactionViewFilter() == TransactionViewFilter.BOUGHT) if (this.auctionPlayer.getTransactionViewFilter() == TransactionViewFilter.BOUGHT)
this.transactions = this.transactions.stream().filter(transaction -> transaction.getBuyer().equals(this.player.getUniqueId())).collect(Collectors.toList()); this.items = this.items.stream().filter(transaction -> transaction.getBuyer().equals(this.player.getUniqueId())).collect(Collectors.toList());
if (this.auctionPlayer.getTransactionViewFilter() == TransactionViewFilter.SOLD) if (this.auctionPlayer.getTransactionViewFilter() == TransactionViewFilter.SOLD)
this.transactions = this.transactions.stream().filter(transaction -> transaction.getSeller().equals(this.player.getUniqueId())).collect(Collectors.toList()); this.items = this.items.stream().filter(transaction -> transaction.getSeller().equals(this.player.getUniqueId())).collect(Collectors.toList());
} }
if (this.auctionPlayer.getTransactionSortType() == AuctionSortType.PRICE) { if (this.auctionPlayer.getTransactionSortType() == AuctionSortType.PRICE) {
this.transactions = this.transactions.stream().sorted(Comparator.comparingDouble(Transaction::getFinalPrice).reversed()).collect(Collectors.toList()); this.items = this.items.stream().sorted(Comparator.comparingDouble(Transaction::getFinalPrice).reversed()).collect(Collectors.toList());
} }
if (this.auctionPlayer.getTransactionSortType() == AuctionSortType.RECENT) { if (this.auctionPlayer.getTransactionSortType() == AuctionSortType.RECENT) {
this.transactions = this.transactions.stream().sorted(Comparator.comparingLong(Transaction::getTransactionTime).reversed()).collect(Collectors.toList()); this.items = this.items.stream().sorted(Comparator.comparingLong(Transaction::getTransactionTime).reversed()).collect(Collectors.toList());
}
} }
return this.transactions.stream().skip((page - 1) * 45L).limit(45).collect(Collectors.toList()); @Override
protected void drawFixed() {
}).asyncLast((data) -> { reset();
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<String, Object>() {{
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 // 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")) { if (Settings.RESTRICT_ALL_TRANSACTIONS_TO_PERM.getBoolean() && !e.player.hasPermission("auctionhouse.transactions.viewall")) {
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
} else { } 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));
}
} }

View File

@ -20,14 +20,13 @@ package ca.tweetzy.auctionhouse.guis.transaction;
import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI; import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui;
import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse; 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.helpers.input.TitleInput;
import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.auctionhouse.transaction.Transaction; import ca.tweetzy.auctionhouse.transaction.Transaction;
import ca.tweetzy.core.utils.NumberUtils; 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.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -41,25 +40,27 @@ import java.util.*;
* Time Created: 5:32 p.m. * Time Created: 5:32 p.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise * 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) { public GUITransactionType(Player player) {
super(player); super(new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(player.getUniqueId())), player, Settings.GUI_TRANSACTIONS_TYPE_TITLE.getString(), 4);
this.player = player; setDefaultItem(QuickItem.bg(QuickItem.of(Settings.GUI_TRANSACTIONS_TYPE_BG_ITEM.getString()).make()));
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()));
draw(); draw();
} }
private void draw() { @Override
protected void draw() {
applyBackExit();
final AuctionHouse instance = AuctionHouse.getInstance(); 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")) { if (Settings.RESTRICT_ALL_TRANSACTIONS_TO_PERM.getBoolean() && !e.player.hasPermission("auctionhouse.transactions.viewall")) {
instance.getLocale().getMessage("commands.no_permission").sendPrefixedMessage(e.player); instance.getLocale().getMessage("commands.no_permission").sendPrefixedMessage(e.player);
return; return;
@ -68,12 +69,20 @@ public final class GUITransactionType extends AbstractPlaceholderGui {
e.manager.showGUI(e.player, new GUITransactionList(e.player, true)); 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 -> { setButton(15, QuickItem
e.manager.showGUI(e.player, new GUITransactionList(e.player, false)); .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")) { 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(); 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()) { 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()))));
} }
} }

View File

@ -22,68 +22,74 @@ import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI; import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType; import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType;
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui; import ca.tweetzy.auctionhouse.guis.abstraction.AuctionBaseGUI;
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.auctionhouse.transaction.Transaction; 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.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import java.util.HashMap;
/** /**
* The current file has been created by Kiran Hart * The current file has been created by Kiran Hart
* Date Created: March 22 2021 * Date Created: March 22 2021
* Time Created: 7:04 p.m. * Time Created: 7:04 p.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise * 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) { public GUITransactionView(AuctionPlayer auctionPlayer, Transaction transaction, boolean showAll) {
super(auctionPlayer); super(new GUITransactionList(auctionPlayer.getPlayer(), showAll), auctionPlayer.getPlayer(), Settings.GUI_TRANSACTION_VIEW_TITLE.getString(), 6);
setTitle(TextUtils.formatText(Settings.GUI_TRANSACTION_VIEW_TITLE.getString())); setDefaultItem(QuickItem.bg(QuickItem.of(Settings.GUI_TRANSACTION_VIEW_BACKGROUND_ITEM.getString()).make()));
setRows(6);
setAcceptsItems(false);
setDefaultItem(ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_TRANSACTION_VIEW_BACKGROUND_ITEM.getString()));
setUseLockedCells(Settings.GUI_TRANSACTION_VIEW_BACKGROUND_FILL.getBoolean()); 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()); setItem(1, 4, transaction.getItem());
final String SERVER_LISTING_NAME = AuctionHouse.getInstance().getLocale().getMessage("general.server listing").getMessage(); final String SERVER_LISTING_NAME = AuctionHouse.getInstance().getLocale().getMessage("general.server listing").getMessage();
final OfflinePlayer seller = Bukkit.getOfflinePlayer(transaction.getSeller()); final OfflinePlayer seller = Bukkit.getOfflinePlayer(transaction.getSeller());
final OfflinePlayer buyer = Bukkit.getOfflinePlayer(transaction.getBuyer()); 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( setItem(3, 6, QuickItem
this.player, .of(AuctionAPI.getInstance().getPlayerHead(Bukkit.getOfflinePlayer(transaction.getBuyer()).getName()))
AuctionAPI.getInstance().getPlayerHead(seller.getName()), .name(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_BUYER_NAME.getString(), "buyer", buyer.getName()))
Settings.GUI_TRANSACTION_VIEW_ITEM_SELLER_NAME.getString(), .lore(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_BUYER_LORE.getStringList(),
Settings.GUI_TRANSACTION_VIEW_ITEM_SELLER_LORE.getStringList(), new HashMap<String, Object>() {{ "transaction_id", transaction.getId().toString(),
put("%transaction_id%", transaction.getId().toString()); "seller", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME,
put("%seller%", seller.hasPlayedBefore() ? seller.getName() : SERVER_LISTING_NAME); "buyer", buyer.getName(),
put("%buyer%", buyer.getName()); "date", AuctionAPI.getInstance().convertMillisToDate(transaction.getTransactionTime())))
put("%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<String, Object>() {{
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<String, Object>() {{ setItem(3, 4, QuickItem
put("%transaction_id%", transaction.getId().toString()); .of(Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_ITEM.getString())
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()); .name(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_NAME.getString(), "transaction_id", transaction.getId().toString()))
put("%transaction_date%", AuctionAPI.getInstance().convertMillisToDate(transaction.getTransactionTime())); .lore(Replacer.replaceVariables(Settings.GUI_TRANSACTION_VIEW_ITEM_INFO_LORE.getStringList(),
put("%final_price%", AuctionAPI.getInstance().formatNumber(transaction.getFinalPrice())); "transaction_id", transaction.getId().toString(),
put("%item_name%", AuctionAPI.getInstance().getItemName(transaction.getItem())); "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());
} }
} }