From 8c8ffe39147943eec3191fc3cc713a28aebdd794 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Sat, 7 Jan 2023 16:31:57 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A2=20Added=20model=20data=20support?= =?UTF-8?q?=20to=20remaining=20gui=20elements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 13 minutes --- .../guis/AbstractPlaceholderGui.java | 66 +++++++++++++++++-- .../auctionhouse/guis/GUIActiveAuctions.java | 6 +- .../auctionhouse/guis/GUIAuctionHouse.java | 6 +- .../ca/tweetzy/auctionhouse/guis/GUIBans.java | 8 +-- .../ca/tweetzy/auctionhouse/guis/GUIBid.java | 2 +- .../guis/GUIContainerInspect.java | 8 +-- .../auctionhouse/guis/GUIExpiredItems.java | 6 +- .../auctionhouse/guis/GUIMinItemPrices.java | 6 +- .../guis/admin/GUIAdminExpired.java | 4 +- .../auctionhouse/guis/admin/GUIAdminItem.java | 2 +- .../auctionhouse/guis/admin/GUIAdminLogs.java | 4 +- .../guis/confirmation/GUIConfirmBid.java | 7 +- .../guis/confirmation/GUIConfirmCancel.java | 8 +-- .../guis/confirmation/GUIConfirmPurchase.java | 12 ++-- .../guis/confirmation/GUIListingConfirm.java | 6 +- .../guis/filter/GUIFilterSelection.java | 2 +- .../guis/filter/GUIFilterWhitelist.java | 2 +- .../guis/filter/GUIFilterWhitelistList.java | 11 ++-- .../guis/sell/GUISellAuction.java | 4 +- .../auctionhouse/guis/sell/GUISellBin.java | 3 +- .../guis/sell/GUISellListingType.java | 4 +- .../guis/sell/GUISellPlaceItem.java | 4 +- .../statistics/GUIStatisticLeaderboard.java | 12 ++-- .../guis/statistics/GUIStatisticSelf.java | 2 +- .../guis/statistics/GUIStatisticTarget.java | 2 +- .../statistics/GUIStatisticViewSelect.java | 2 +- .../guis/transaction/GUITransactionList.java | 12 ++-- .../guis/transaction/GUITransactionType.java | 2 +- .../guis/transaction/GUITransactionView.java | 2 +- .../helpers/ConfigurationItemHelper.java | 5 ++ 30 files changed, 136 insertions(+), 84 deletions(-) diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/AbstractPlaceholderGui.java b/src/main/java/ca/tweetzy/auctionhouse/guis/AbstractPlaceholderGui.java index 7f50cca..03caaee 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/AbstractPlaceholderGui.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/AbstractPlaceholderGui.java @@ -20,11 +20,12 @@ package ca.tweetzy.auctionhouse.guis; import ca.tweetzy.auctionhouse.api.hook.PlaceholderAPIHook; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; +import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.gui.Gui; -import ca.tweetzy.core.gui.GuiUtils; import ca.tweetzy.core.utils.TextUtils; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; /** * Date Created: April 07 2022 @@ -39,18 +40,75 @@ public abstract class AbstractPlaceholderGui extends Gui { public AbstractPlaceholderGui(Player player) { this.player = player; setUseLockedCells(true); - setDefaultItem(GuiUtils.createButtonItem(Settings.GUI_FILLER.getMaterial(), " ")); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_FILLER.getString())); } public AbstractPlaceholderGui(AuctionPlayer player) { this.player = player.getPlayer(); setUseLockedCells(true); - setDefaultItem(GuiUtils.createButtonItem(Settings.GUI_FILLER.getMaterial(), " ")); - } + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_FILLER.getString())); +} @Override public Gui setTitle(String message) { super.setTitle(this.player == null ? TextUtils.formatText(message) : TextUtils.formatText(PlaceholderAPIHook.PAPIReplacer.tryReplace(this.player, message))); return this; } + + protected ItemStack getPreviousPageItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_BACK_BTN_ITEM.getString(), Settings.GUI_BACK_BTN_NAME.getString(), Settings.GUI_BACK_BTN_LORE.getStringList(), null); + } + + protected ItemStack getNextPageItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_NEXT_BTN_ITEM.getString(), Settings.GUI_NEXT_BTN_NAME.getString(), Settings.GUI_NEXT_BTN_LORE.getStringList(), null); + } + + protected ItemStack getRefreshButtonItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_NEXT_BTN_ITEM.getString(), Settings.GUI_NEXT_BTN_NAME.getString(), Settings.GUI_NEXT_BTN_LORE.getStringList(), null); + } + + protected ItemStack getCloseButtonItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CLOSE_BTN_ITEM.getString(), Settings.GUI_CLOSE_BTN_NAME.getString(), Settings.GUI_CLOSE_BTN_LORE.getStringList(), null); + } + + protected ItemStack getIncreaseQtyButtonItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CONFIRM_INCREASE_QTY_ITEM.getString(), Settings.GUI_CONFIRM_INCREASE_QTY_NAME.getString(), Settings.GUI_CONFIRM_INCREASE_QTY_LORE.getStringList(), null); + } + + protected ItemStack getDecreaseQtyButtonItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CONFIRM_DECREASE_QTY_ITEM.getString(), Settings.GUI_CONFIRM_DECREASE_QTY_NAME.getString(), Settings.GUI_CONFIRM_DECREASE_QTY_LORE.getStringList(), null); + } + + // confirms + protected ItemStack getConfirmCancelYesItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CONFIRM_CANCEL_YES_ITEM.getString(), Settings.GUI_CONFIRM_CANCEL_YES_NAME.getString(), Settings.GUI_CONFIRM_CANCEL_YES_LORE.getStringList(), null); + } + + protected ItemStack getConfirmCancelNoItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CONFIRM_CANCEL_NO_ITEM.getString(), Settings.GUI_CONFIRM_CANCEL_NO_NAME.getString(), Settings.GUI_CONFIRM_CANCEL_NO_LORE.getStringList(), null); + } + + protected ItemStack getConfirmBuyYesItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CONFIRM_BUY_YES_ITEM.getString(), Settings.GUI_CONFIRM_BUY_YES_NAME.getString(), Settings.GUI_CONFIRM_BUY_YES_LORE.getStringList(), null); + } + + protected ItemStack getConfirmBuyNoItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CONFIRM_BUY_NO_ITEM.getString(), Settings.GUI_CONFIRM_BUY_NO_NAME.getString(), Settings.GUI_CONFIRM_BUY_NO_LORE.getStringList(), null); + } + + protected ItemStack getConfirmListingYesItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CONFIRM_LISTING_YES_ITEM.getString(), Settings.GUI_CONFIRM_LISTING_YES_NAME.getString(), Settings.GUI_CONFIRM_LISTING_YES_LORE.getStringList(), null); + } + + protected ItemStack getConfirmListingNoItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CONFIRM_LISTING_NO_ITEM.getString(), Settings.GUI_CONFIRM_LISTING_NO_NAME.getString(), Settings.GUI_CONFIRM_LISTING_NO_LORE.getStringList(), null); + } + + protected ItemStack getConfirmBidYesItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CONFIRM_BID_YES_ITEM.getString(), Settings.GUI_CONFIRM_BID_YES_NAME.getString(), Settings.GUI_CONFIRM_BID_YES_LORE.getStringList(), null); + } + + protected ItemStack getConfirmBidNoItem() { + return ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CONFIRM_BID_NO_ITEM.getString(), Settings.GUI_CONFIRM_BID_NO_NAME.getString(), Settings.GUI_CONFIRM_BID_NO_LORE.getStringList(), null); + } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIActiveAuctions.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIActiveAuctions.java index bcbbebf..722c656 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIActiveAuctions.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIActiveAuctions.java @@ -134,7 +134,7 @@ public class GUIActiveAuctions extends AbstractPlaceholderGui { e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)); }); - setButton(5, 4, new TItemBuilder(Objects.requireNonNull(Settings.GUI_REFRESH_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_REFRESH_BTN_NAME.getString()).setLore(Settings.GUI_REFRESH_BTN_LORE.getStringList()).toItemStack(), e -> e.manager.showGUI(e.player, new GUIActiveAuctions(this.auctionPlayer))); + setButton(5, 4, getRefreshButtonItem(), e -> e.manager.showGUI(e.player, new GUIActiveAuctions(this.auctionPlayer))); setButton(5, 1, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_ACTIVE_AUCTIONS_ITEM.getString(), Settings.GUI_ACTIVE_AUCTIONS_NAME.getString(), Settings.GUI_ACTIVE_AUCTIONS_LORE.getStringList(), null), e -> { this.auctionPlayer.getItems(false).forEach(item -> item.setExpired(true)); @@ -143,8 +143,8 @@ public class GUIActiveAuctions extends AbstractPlaceholderGui { } private void drawPaginationButtons() { - setPrevPage(5, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_BACK_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_BACK_BTN_NAME.getString()).setLore(Settings.GUI_BACK_BTN_LORE.getStringList()).toItemStack()); - setNextPage(5, 5, new TItemBuilder(Objects.requireNonNull(Settings.GUI_NEXT_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_NEXT_BTN_NAME.getString()).setLore(Settings.GUI_NEXT_BTN_LORE.getStringList()).toItemStack()); + setPrevPage(5, 3, getPreviousPageItem()); + setNextPage(5, 5, getNextPageItem()); setOnPage(e -> { draw(); SoundManager.getInstance().playSound(this.auctionPlayer.getPlayer(), Settings.SOUNDS_NAVIGATE_GUI_PAGES.getString(), 1.0F, 1.0F); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java index b38a435..bd9d37f 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java @@ -502,8 +502,8 @@ public class GUIAuctionHouse extends AbstractPlaceholderGui { } private void drawPaginationButtons() { - setPrevPage(Settings.GUI_BACK_BTN_SLOT.getInt(), new TItemBuilder(Objects.requireNonNull(Settings.GUI_BACK_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_BACK_BTN_NAME.getString()).setLore(Settings.GUI_BACK_BTN_LORE.getStringList()).toItemStack()); - setNextPage(Settings.GUI_NEXT_BTN_SLOT.getInt(), new TItemBuilder(Objects.requireNonNull(Settings.GUI_NEXT_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_NEXT_BTN_NAME.getString()).setLore(Settings.GUI_NEXT_BTN_LORE.getStringList()).toItemStack()); + setPrevPage(Settings.GUI_BACK_BTN_SLOT.getInt(), getPreviousPageItem()); + setNextPage(Settings.GUI_NEXT_BTN_SLOT.getInt(), getNextPageItem()); setOnPage(e -> { draw(); @@ -539,7 +539,7 @@ public class GUIAuctionHouse extends AbstractPlaceholderGui { } if (Settings.GUI_REFRESH_BTN_ENABLED.getBoolean()) { - setButton(Settings.GUI_REFRESH_BTN_SLOT.getInt(), new TItemBuilder(Objects.requireNonNull(Settings.GUI_REFRESH_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_REFRESH_BTN_NAME.getString()).setLore(Settings.GUI_REFRESH_BTN_LORE.getStringList()).toItemStack(), e -> { + setButton(Settings.GUI_REFRESH_BTN_SLOT.getInt(), getRefreshButtonItem(), 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()) { diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIBans.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIBans.java index c8caa2a..d6b6d42 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIBans.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIBans.java @@ -25,7 +25,6 @@ import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.utils.TextUtils; import ca.tweetzy.core.utils.TimeUtils; -import ca.tweetzy.core.utils.items.TItemBuilder; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -35,7 +34,6 @@ import org.bukkit.scheduler.BukkitTask; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; /** @@ -53,7 +51,7 @@ public class GUIBans extends AbstractPlaceholderGui { public GUIBans(Player player) { super(player); setTitle(TextUtils.formatText(Settings.GUI_BANS_TITLE.getString())); - setDefaultItem(Settings.GUI_BANS_BG_ITEM.getMaterial().parseItem()); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_BANS_BG_ITEM.getString())); setUseLockedCells(true); setAcceptsItems(false); setAllowDrops(false); @@ -75,8 +73,8 @@ public class GUIBans extends AbstractPlaceholderGui { return this.bans.stream().skip((page - 1) * 45L).limit(45L).collect(Collectors.toList()); }).asyncLast((data) -> { pages = (int) Math.max(1, Math.ceil(this.bans.size() / (double) 45L)); - setPrevPage(5, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_BACK_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_BACK_BTN_NAME.getString()).setLore(Settings.GUI_BACK_BTN_LORE.getStringList()).toItemStack()); - setNextPage(5, 5, new TItemBuilder(Objects.requireNonNull(Settings.GUI_NEXT_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_NEXT_BTN_NAME.getString()).setLore(Settings.GUI_NEXT_BTN_LORE.getStringList()).toItemStack()); + setPrevPage(5, 3, getPreviousPageItem()); + setNextPage(5, 5, getNextPageItem()); setOnPage(e -> draw()); int slot = 0; diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIBid.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIBid.java index 0ad99bd..d56d41e 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIBid.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIBid.java @@ -52,7 +52,7 @@ public class GUIBid extends AbstractPlaceholderGui { this.auctionPlayer = auctionPlayer; this.auctionItem = auctionItem; setTitle(TextUtils.formatText(Settings.GUI_BIDDING_TITLE.getString())); - setDefaultItem(Settings.GUI_BIDDING_BG_ITEM.getMaterial().parseItem()); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_BIDDING_BG_ITEM.getString())); setUseLockedCells(true); setAcceptsItems(false); setAllowDrops(false); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIContainerInspect.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIContainerInspect.java index 13c3218..133d3ab 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIContainerInspect.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIContainerInspect.java @@ -26,7 +26,6 @@ import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmPurchase; import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.utils.TextUtils; -import ca.tweetzy.core.utils.items.TItemBuilder; import ca.tweetzy.core.utils.nms.NBTEditor; import org.bukkit.block.ShulkerBox; import org.bukkit.inventory.ItemStack; @@ -35,7 +34,6 @@ import org.bukkit.inventory.meta.BlockStateMeta; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; /** @@ -65,7 +63,7 @@ public class GUIContainerInspect extends AbstractPlaceholderGui { this.container = container; this.fromPurchaseGUI = false; setTitle(TextUtils.formatText(Settings.GUI_INSPECT_TITLE.getString())); - setDefaultItem(Settings.GUI_INSPECT_BG_ITEM.getMaterial().parseItem()); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_INSPECT_BG_ITEM.getString())); setUseLockedCells(false); setAcceptsItems(false); setAllowDrops(false); @@ -111,7 +109,7 @@ public class GUIContainerInspect extends AbstractPlaceholderGui { for (int i : fillSlots) setItem(i, getDefaultItem()); - setPrevPage(5, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_BACK_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_BACK_BTN_NAME.getString()).setLore(Settings.GUI_BACK_BTN_LORE.getStringList()).toItemStack()); + setPrevPage(5, 3, getPreviousPageItem()); setButton(5, 4, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CLOSE_BTN_ITEM.getString(), Settings.GUI_CLOSE_BTN_NAME.getString(), Settings.GUI_CLOSE_BTN_LORE.getStringList(), null), e -> { if (fromPurchaseGUI) { AuctionHouse.getInstance().getTransactionManager().addPrePurchase(e.player, auctionItem.getId()); @@ -120,7 +118,7 @@ public class GUIContainerInspect extends AbstractPlaceholderGui { e.manager.showGUI(e.player, new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(e.player.getUniqueId()))); } }); - setNextPage(5, 5, new TItemBuilder(Objects.requireNonNull(Settings.GUI_NEXT_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_NEXT_BTN_NAME.getString()).setLore(Settings.GUI_NEXT_BTN_LORE.getStringList()).toItemStack()); + setNextPage(5, 5, getNextPageItem()); setOnPage(e -> draw()); int slot = 9; diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIExpiredItems.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIExpiredItems.java index c2690c9..3f51dc2 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIExpiredItems.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIExpiredItems.java @@ -76,9 +76,9 @@ public class GUIExpiredItems extends AbstractPlaceholderGui { return this.items.stream().sorted(Comparator.comparingLong(AuctionedItem::getExpiresAt).reversed()).skip((page - 1) * 45L).limit(45).collect(Collectors.toList()); }).asyncLast((data) -> { pages = (int) Math.max(1, Math.ceil(this.auctionPlayer.getItems(true).size() / (double) 45)); - setPrevPage(5, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_BACK_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_BACK_BTN_NAME.getString()).setLore(Settings.GUI_BACK_BTN_LORE.getStringList()).toItemStack()); - setButton(5, 4, new TItemBuilder(Objects.requireNonNull(Settings.GUI_REFRESH_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_REFRESH_BTN_NAME.getString()).setLore(Settings.GUI_REFRESH_BTN_LORE.getStringList()).toItemStack(), e -> draw()); - setNextPage(5, 5, new TItemBuilder(Objects.requireNonNull(Settings.GUI_NEXT_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_NEXT_BTN_NAME.getString()).setLore(Settings.GUI_NEXT_BTN_LORE.getStringList()).toItemStack()); + setPrevPage(5, 3, getPreviousPageItem()); + setButton(5, 4, getRefreshButtonItem(), e -> draw()); + setNextPage(5, 5, getNextPageItem()); setOnPage(e -> { draw(); SoundManager.getInstance().playSound(this.auctionPlayer.getPlayer(), Settings.SOUNDS_NAVIGATE_GUI_PAGES.getString(), 1.0F, 1.0F); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIMinItemPrices.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIMinItemPrices.java index 8547371..e4f1233 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIMinItemPrices.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIMinItemPrices.java @@ -24,13 +24,11 @@ import ca.tweetzy.auctionhouse.auction.MinItemPrice; import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.utils.TextUtils; -import ca.tweetzy.core.utils.items.TItemBuilder; import org.bukkit.entity.Player; import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; /** @@ -57,8 +55,8 @@ public final class GUIMinItemPrices extends AbstractPlaceholderGui { pages = (int) Math.max(1, Math.ceil(this.minPrices.size() / (double) 45)); - setPrevPage(5, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_BACK_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_BACK_BTN_NAME.getString()).setLore(Settings.GUI_BACK_BTN_LORE.getStringList()).toItemStack()); - setNextPage(5, 5, new TItemBuilder(Objects.requireNonNull(Settings.GUI_NEXT_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_NEXT_BTN_NAME.getString()).setLore(Settings.GUI_NEXT_BTN_LORE.getStringList()).toItemStack()); + setPrevPage(5, 3, getPreviousPageItem()); + setNextPage(5, 5, getNextPageItem()); setOnPage(e -> draw()); int slot = 0; diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminExpired.java b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminExpired.java index 4aa79a0..a084452 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminExpired.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminExpired.java @@ -60,8 +60,8 @@ public final class GUIAdminExpired extends AbstractPlaceholderGui { AuctionHouse.newChain().asyncFirst(() -> this.items.stream().sorted(Comparator.comparingLong(AuctionedItem::getExpiresAt).reversed()).skip((page - 1) * 45L).limit(45).collect(Collectors.toList())).asyncLast(data -> { pages = (int) Math.max(1, Math.ceil(this.items.size() / (double) 45)); - setPrevPage(5, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_BACK_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_BACK_BTN_NAME.getString()).setLore(Settings.GUI_BACK_BTN_LORE.getStringList()).toItemStack()); - setNextPage(5, 5, new TItemBuilder(Objects.requireNonNull(Settings.GUI_NEXT_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_NEXT_BTN_NAME.getString()).setLore(Settings.GUI_NEXT_BTN_LORE.getStringList()).toItemStack()); + setPrevPage(5, 3, getPreviousPageItem()); + setNextPage(5, 5, getNextPageItem()); setOnPage(e -> { draw(); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminItem.java b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminItem.java index 42fe887..cdcff4d 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminItem.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminItem.java @@ -53,7 +53,7 @@ public class GUIAdminItem extends AbstractPlaceholderGui { this.auctionPlayer = auctionPlayer; this.auctionItem = auctionItem; setTitle(TextUtils.formatText(Settings.GUI_ITEM_ADMIN_TITLE.getString())); - setDefaultItem(Settings.GUI_ITEM_ADMIN_BG_ITEM.getMaterial().parseItem()); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_ITEM_ADMIN_BG_ITEM.getString())); setRows(3); setAcceptsItems(false); setUseLockedCells(true); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminLogs.java b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminLogs.java index 0bff791..2a61fd7 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminLogs.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/admin/GUIAdminLogs.java @@ -57,8 +57,8 @@ public final class GUIAdminLogs extends AbstractPlaceholderGui { reset(); pages = (int) Math.max(1, Math.ceil(this.logs.size() / (double) 45)); - setPrevPage(5, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_BACK_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_BACK_BTN_NAME.getString()).setLore(Settings.GUI_BACK_BTN_LORE.getStringList()).toItemStack()); - setNextPage(5, 5, new TItemBuilder(Objects.requireNonNull(Settings.GUI_NEXT_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_NEXT_BTN_NAME.getString()).setLore(Settings.GUI_NEXT_BTN_LORE.getStringList()).toItemStack()); + setPrevPage(5, 3, getPreviousPageItem()); + setNextPage(5, 5, getNextPageItem()); setOnPage(e -> draw()); int slot = 0; diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java index 1bed39c..36f2e53 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java @@ -28,15 +28,12 @@ import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.core.utils.TextUtils; -import ca.tweetzy.core.utils.items.TItemBuilder; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitTask; -import java.util.Objects; - /** * The current file has been created by Kiran Hart * Date Created: March 17 2021 @@ -84,9 +81,9 @@ public class GUIConfirmBid extends AbstractPlaceholderGui { } private void draw() { - setItems(0, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_BID_YES_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_BID_YES_NAME.getString()).setLore(Settings.GUI_CONFIRM_BID_YES_LORE.getStringList()).toItemStack()); + setItems(0, 3, getConfirmBidYesItem()); placeAuctionItem(); - setItems(5, 8, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_BID_NO_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_BID_NO_NAME.getString()).setLore(Settings.GUI_CONFIRM_BID_NO_LORE.getStringList()).toItemStack()); + setItems(5, 8, getConfirmBidNoItem()); setActionForRange(5, 8, ClickType.LEFT, e -> { cleanup(); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmCancel.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmCancel.java index 2c6cf76..6e765ae 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmCancel.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmCancel.java @@ -28,13 +28,10 @@ import ca.tweetzy.auctionhouse.guis.GUIActiveAuctions; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.core.utils.TextUtils; -import ca.tweetzy.core.utils.items.TItemBuilder; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.event.inventory.ClickType; -import java.util.Objects; - /** * The current file has been created by Kiran Hart * Date Created: May 20 2021 @@ -57,9 +54,9 @@ public class GUIConfirmCancel extends AbstractPlaceholderGui { } private void draw() { - setItems(0, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_CANCEL_YES_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_CANCEL_YES_NAME.getString()).setLore(Settings.GUI_CONFIRM_CANCEL_YES_LORE.getStringList()).toItemStack()); + setItems(0, 3, getConfirmCancelYesItem()); setItem(0, 4, this.auctionItem.getDisplayStack(AuctionStackType.ACTIVE_AUCTIONS_LIST)); - setItems(5, 8, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_CANCEL_NO_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_CANCEL_NO_NAME.getString()).setLore(Settings.GUI_CONFIRM_CANCEL_NO_LORE.getStringList()).toItemStack()); + setItems(5, 8, getConfirmCancelNoItem()); setActionForRange(5, 8, ClickType.LEFT, e -> e.manager.showGUI(e.player, new GUIActiveAuctions(this.auctionPlayer))); setActionForRange(0, 3, ClickType.LEFT, e -> { @@ -81,6 +78,7 @@ public class GUIConfirmCancel extends AbstractPlaceholderGui { AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(located.getCurrentPrice())).sendPrefixedMessage(oldBidder.getPlayer()); } + e.manager.showGUI(e.player, new GUIActiveAuctions(this.auctionPlayer)); }); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java index dde5196..1b8193e 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java @@ -36,7 +36,6 @@ import ca.tweetzy.core.gui.events.GuiClickEvent; import ca.tweetzy.core.hooks.EconomyManager; import ca.tweetzy.core.utils.PlayerUtils; import ca.tweetzy.core.utils.TextUtils; -import ca.tweetzy.core.utils.items.TItemBuilder; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.block.ShulkerBox; @@ -46,7 +45,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BlockStateMeta; import java.util.HashMap; -import java.util.Objects; /** * The current file has been created by Kiran Hart @@ -81,7 +79,7 @@ public class GUIConfirmPurchase extends AbstractPlaceholderGui { if (this.buyingSpecificQuantity) { setUseLockedCells(Settings.GUI_CONFIRM_FILL_BG_ON_QUANTITY.getBoolean()); - setDefaultItem(Settings.GUI_CONFIRM_BG_ITEM.getMaterial().parseItem()); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CONFIRM_BG_ITEM.getString())); this.purchaseQuantity = preAmount; this.maxStackSize = preAmount; this.pricePerItem = this.auctionItem.getBasePrice() / this.maxStackSize; @@ -103,9 +101,9 @@ public class GUIConfirmPurchase extends AbstractPlaceholderGui { private void draw() { ItemStack deserializeItem = this.auctionItem.getItem().clone(); - setItems(this.buyingSpecificQuantity ? 9 : 0, this.buyingSpecificQuantity ? 12 : 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_BUY_YES_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_BUY_YES_NAME.getString()).setLore(Settings.GUI_CONFIRM_BUY_YES_LORE.getStringList()).toItemStack()); + setItems(this.buyingSpecificQuantity ? 9 : 0, this.buyingSpecificQuantity ? 12 : 3, getConfirmBuyYesItem()); setItem(this.buyingSpecificQuantity ? 1 : 0, 4, this.auctionItem.getDisplayStack(AuctionStackType.LISTING_PREVIEW)); - setItems(this.buyingSpecificQuantity ? 14 : 5, this.buyingSpecificQuantity ? 17 : 8, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_BUY_NO_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_BUY_NO_NAME.getString()).setLore(Settings.GUI_CONFIRM_BUY_NO_LORE.getStringList()).toItemStack()); + setItems(this.buyingSpecificQuantity ? 14 : 5, this.buyingSpecificQuantity ? 17 : 8, getConfirmBuyNoItem()); setAction(this.buyingSpecificQuantity ? 1 : 0, 4, ClickType.LEFT, e -> { if (deserializeItem.getItemMeta() instanceof BlockStateMeta) { @@ -226,14 +224,14 @@ public class GUIConfirmPurchase extends AbstractPlaceholderGui { drawPurchaseInfo(this.maxStackSize); // Decrease Button - setButton(3, 3, new TItemBuilder(Settings.GUI_CONFIRM_DECREASE_QTY_ITEM.getMaterial().parseMaterial()).setName(Settings.GUI_CONFIRM_DECREASE_QTY_NAME.getString()).setLore(Settings.GUI_CONFIRM_DECREASE_QTY_LORE.getStringList()).toItemStack(), e -> { + setButton(3, 3, getDecreaseQtyButtonItem(), e -> { if ((this.purchaseQuantity - 1) <= 0) return; this.purchaseQuantity -= 1; drawPurchaseInfo(this.purchaseQuantity); }); // Increase Button - setButton(3, 5, new TItemBuilder(Settings.GUI_CONFIRM_INCREASE_QTY_ITEM.getMaterial().parseMaterial()).setName(Settings.GUI_CONFIRM_INCREASE_QTY_NAME.getString()).setLore(Settings.GUI_CONFIRM_INCREASE_QTY_LORE.getStringList()).toItemStack(), e -> { + setButton(3, 5, getIncreaseQtyButtonItem(), e -> { if ((this.purchaseQuantity + 1) > this.maxStackSize) return; this.purchaseQuantity += 1; drawPurchaseInfo(this.purchaseQuantity); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java index d367bf5..d78dd3d 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java @@ -23,11 +23,9 @@ import ca.tweetzy.auctionhouse.auction.enums.AuctionStackType; import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.utils.TextUtils; -import ca.tweetzy.core.utils.items.TItemBuilder; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import java.util.Objects; import java.util.function.Consumer; public final class GUIListingConfirm extends AbstractPlaceholderGui { @@ -47,9 +45,9 @@ public final class GUIListingConfirm extends AbstractPlaceholderGui { } private void draw() { - setItems(0, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_LISTING_YES_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_LISTING_YES_NAME.getString()).setLore(Settings.GUI_CONFIRM_LISTING_YES_LORE.getStringList()).toItemStack()); + setItems(0, 3, getConfirmListingYesItem()); setItem(0, 4, this.auctionedItem.getDisplayStack(AuctionStackType.LISTING_PREVIEW)); - setItems(5, 8, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_LISTING_NO_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_LISTING_NO_NAME.getString()).setLore(Settings.GUI_CONFIRM_LISTING_NO_LORE.getStringList()).toItemStack()); + setItems(5, 8, getConfirmListingNoItem()); setActionForRange(5, 8, ClickType.LEFT, e -> { setAllowClose(true); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterSelection.java b/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterSelection.java index 2a33a45..cb3e5f2 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterSelection.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterSelection.java @@ -49,7 +49,7 @@ public class GUIFilterSelection extends AbstractPlaceholderGui { setTitle(TextUtils.formatText(Settings.GUI_FILTER_TITLE.getString())); setRows(4); setAcceptsItems(false); - setDefaultItem(Settings.GUI_FILTER_BG_ITEM.getMaterial().parseItem()); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_FILTER_BG_ITEM.getString())); setUseLockedCells(true); draw(); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterWhitelist.java b/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterWhitelist.java index c74be03..ce6aee5 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterWhitelist.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterWhitelist.java @@ -38,7 +38,7 @@ public class GUIFilterWhitelist extends AbstractPlaceholderGui { setTitle(TextUtils.formatText(Settings.GUI_FILTER_WHITELIST_TITLE.getString())); setRows(6); setAcceptsItems(false); - setDefaultItem(Settings.GUI_FILTER_WHITELIST_BG_ITEM.getMaterial().parseItem()); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_FILTER_WHITELIST_BG_ITEM.getString())); setUseLockedCells(true); draw(); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterWhitelistList.java b/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterWhitelistList.java index 4495608..ac3bd17 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterWhitelistList.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/filter/GUIFilterWhitelistList.java @@ -22,15 +22,14 @@ import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.auction.AuctionFilterItem; import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory; import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui; +import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.utils.TextUtils; -import ca.tweetzy.core.utils.items.TItemBuilder; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import java.util.Arrays; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; /** @@ -50,7 +49,7 @@ public class GUIFilterWhitelistList extends AbstractPlaceholderGui { setTitle(TextUtils.formatText(Settings.GUI_FILTER_WHITELIST_LIST_TITLE.getString().replace("%filter_category%", filerCategory.getTranslatedType()))); setRows(6); setAcceptsItems(false); - setDefaultItem(Settings.GUI_FILTER_WHITELIST_LIST_BG_ITEM.getMaterial().parseItem()); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_FILTER_WHITELIST_LIST_BG_ITEM.getString())); setUseLockedCells(true); draw(); @@ -59,9 +58,9 @@ public class GUIFilterWhitelistList extends AbstractPlaceholderGui { private void draw() { reset(); - setPrevPage(5, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_BACK_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_BACK_BTN_NAME.getString()).setLore(Settings.GUI_BACK_BTN_LORE.getStringList()).toItemStack()); - setButton(5, 4, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CLOSE_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CLOSE_BTN_NAME.getString()).setLore(Settings.GUI_CLOSE_BTN_LORE.getStringList()).toItemStack(), e -> e.manager.showGUI(e.player, new GUIFilterWhitelist(e.player))); - setNextPage(5, 5, new TItemBuilder(Objects.requireNonNull(Settings.GUI_NEXT_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_NEXT_BTN_NAME.getString()).setLore(Settings.GUI_NEXT_BTN_LORE.getStringList()).toItemStack()); + setPrevPage(5, 3, getPreviousPageItem()); + setButton(5, 4, getCloseButtonItem(), e -> e.manager.showGUI(e.player, new GUIFilterWhitelist(e.player))); + setNextPage(5, 5, getNextPageItem()); setOnPage(e -> draw()); AuctionHouse.newChain().asyncFirst(() -> { diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java index 6318554..dea87d1 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java @@ -30,10 +30,10 @@ import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui; import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse; import ca.tweetzy.auctionhouse.guis.confirmation.GUIListingConfirm; import ca.tweetzy.auctionhouse.helpers.AuctionCreator; +import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.helpers.MaterialCategorizer; import ca.tweetzy.auctionhouse.helpers.input.TitleInput; import ca.tweetzy.auctionhouse.settings.Settings; -import ca.tweetzy.core.gui.GuiUtils; import ca.tweetzy.core.gui.events.GuiClickEvent; import ca.tweetzy.core.utils.NumberUtils; import ca.tweetzy.core.utils.PlayerUtils; @@ -68,7 +68,7 @@ public final class GUISellAuction extends AbstractPlaceholderGui { this.allowBuyNow = allowBuyNow; setTitle(Settings.GUI_SELL_AUCTION_TITLE.getString()); - setDefaultItem(GuiUtils.createButtonItem(Settings.GUI_SELL_AUCTION_BG_ITEM.getMaterial(), " ")); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_AUCTION_BG_ITEM.getString())); setRows(6); setOnClose(close -> { diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java index 8bac626..77b8ffb 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java @@ -30,6 +30,7 @@ import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui; import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse; import ca.tweetzy.auctionhouse.guis.confirmation.GUIListingConfirm; import ca.tweetzy.auctionhouse.helpers.AuctionCreator; +import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.helpers.MaterialCategorizer; import ca.tweetzy.auctionhouse.helpers.input.TitleInput; import ca.tweetzy.auctionhouse.settings.Settings; @@ -64,7 +65,7 @@ public final class GUISellBin extends AbstractPlaceholderGui { this.allowPartialBuy = allowPartialBuy; setTitle(Settings.GUI_SELL_BIN_TITLE.getString()); - setDefaultItem(GuiUtils.createButtonItem(Settings.GUI_SELL_BIN_BG_ITEM.getMaterial(), " ")); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_BIN_BG_ITEM.getString())); setRows(6); setOnClose(close -> { diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellListingType.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellListingType.java index a8a8b89..2ce3500 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellListingType.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellListingType.java @@ -22,8 +22,8 @@ import ca.tweetzy.auctionhouse.ahv3.api.ListingType; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui; import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse; +import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.settings.Settings; -import ca.tweetzy.core.gui.GuiUtils; import ca.tweetzy.flight.utils.QuickItem; import lombok.NonNull; @@ -40,7 +40,7 @@ public final class GUISellListingType extends AbstractPlaceholderGui { this.auctionPlayer = auctionPlayer; this.listingType = listingType; setTitle(Settings.GUI_SELL_LISTING_TYPE_TITLE.getString()); - setDefaultItem(GuiUtils.createButtonItem(Settings.GUI_SELL_LISTING_TYPE_BG_ITEM.getMaterial(), " ")); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_LISTING_TYPE_BG_ITEM.getString())); setRows(3); draw(); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellPlaceItem.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellPlaceItem.java index d45588f..edec259 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellPlaceItem.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellPlaceItem.java @@ -23,8 +23,8 @@ 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.settings.Settings; -import ca.tweetzy.core.gui.GuiUtils; import ca.tweetzy.core.utils.PlayerUtils; import ca.tweetzy.flight.utils.QuickItem; import lombok.NonNull; @@ -51,7 +51,7 @@ public final class GUISellPlaceItem extends AbstractPlaceholderGui { this.viewMode = viewMode; this.listingType = listingType; setTitle(Settings.GUI_SELL_PLACE_ITEM_TITLE.getString()); - setDefaultItem(GuiUtils.createButtonItem(Settings.GUI_SELL_PLACE_ITEM_BG_ITEM.getMaterial(), " ")); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_PLACE_ITEM_BG_ITEM.getString())); setRows(viewMode == ViewMode.SINGLE_ITEM ? 4 : 6); setAcceptsItems(true); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticLeaderboard.java b/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticLeaderboard.java index a6443cf..3accd5c 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticLeaderboard.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticLeaderboard.java @@ -26,12 +26,14 @@ import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui; import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.managers.SoundManager; import ca.tweetzy.auctionhouse.settings.Settings; -import ca.tweetzy.core.utils.items.TItemBuilder; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.inventory.ItemStack; -import java.util.*; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.UUID; import java.util.stream.Collectors; public final class GUIStatisticLeaderboard extends AbstractPlaceholderGui { @@ -46,7 +48,7 @@ public final class GUIStatisticLeaderboard extends AbstractPlaceholderGui { this.auctionPlayer = player; this.statisticType = statisticType; setTitle(Settings.GUI_STATS_LEADERBOARD_TITLE.getString()); - setDefaultItem(Settings.GUI_STATS_LEADERBOARD_BG_ITEM.getMaterial().parseItem()); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_STATS_LEADERBOARD_BG_ITEM.getString())); setUseLockedCells(true); setAcceptsItems(false); setAllowDrops(false); @@ -96,8 +98,8 @@ public final class GUIStatisticLeaderboard extends AbstractPlaceholderGui { } private void drawPaginationButtons() { - setPrevPage(5, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_BACK_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_BACK_BTN_NAME.getString()).setLore(Settings.GUI_BACK_BTN_LORE.getStringList()).toItemStack()); - setNextPage(5, 5, new TItemBuilder(Objects.requireNonNull(Settings.GUI_NEXT_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_NEXT_BTN_NAME.getString()).setLore(Settings.GUI_NEXT_BTN_LORE.getStringList()).toItemStack()); + setPrevPage(5, 3, getPreviousPageItem()); + setNextPage(5, 5, getNextPageItem()); setOnPage(e -> { draw(); SoundManager.getInstance().playSound(this.auctionPlayer.getPlayer(), Settings.SOUNDS_NAVIGATE_GUI_PAGES.getString(), 1.0F, 1.0F); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticSelf.java b/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticSelf.java index 5f6310f..c046a27 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticSelf.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticSelf.java @@ -36,7 +36,7 @@ public final class GUIStatisticSelf extends AbstractPlaceholderGui { super(player); this.auctionPlayer = player; setTitle(Settings.GUI_STATS_SELF_TITLE.getString()); - setDefaultItem(Settings.GUI_STATS_SELF_BG_ITEM.getMaterial().parseItem()); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_STATS_SELF_BG_ITEM.getString())); setUseLockedCells(true); setAcceptsItems(false); setAllowDrops(false); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticTarget.java b/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticTarget.java index f51e2bd..826a5d9 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticTarget.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticTarget.java @@ -38,7 +38,7 @@ public final class GUIStatisticTarget extends AbstractPlaceholderGui { this.auctionPlayer = player; this.targetPlayer = targetPlayer; setTitle(Settings.GUI_STATS_SEARCH_TITLE.getString().replace("%player_name%", targetPlayer.getPlayer().getName())); - setDefaultItem(Settings.GUI_STATS_SEARCH_BG_ITEM.getMaterial().parseItem()); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_STATS_SEARCH_BG_ITEM.getString())); setUseLockedCells(true); setAcceptsItems(false); setAllowDrops(false); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticViewSelect.java b/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticViewSelect.java index d063450..3bcd4cd 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticViewSelect.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/statistics/GUIStatisticViewSelect.java @@ -34,7 +34,7 @@ public final class GUIStatisticViewSelect extends AbstractPlaceholderGui { super(player); this.auctionPlayer = player; setTitle(Settings.GUI_STATS_VIEW_SELECT_TITLE.getString()); - setDefaultItem(Settings.GUI_STATS_VIEW_SELECT_BG_ITEM.getMaterial().parseItem()); + getConfirmBuyNoItem()(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_STATS_VIEW_SELECT_BG_ITEM.getString())); setUseLockedCells(true); setAcceptsItems(false); setAllowDrops(false); 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 1bc3d6a..d26c0f1 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionList.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionList.java @@ -27,12 +27,14 @@ import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.auctionhouse.transaction.Transaction; import ca.tweetzy.core.utils.TextUtils; -import ca.tweetzy.core.utils.items.TItemBuilder; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.util.*; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; import java.util.stream.Collectors; /** @@ -70,9 +72,9 @@ public class GUITransactionList extends AbstractPlaceholderGui { reset(); pages = (int) Math.max(1, Math.ceil(this.transactions.size() / (double) 45)); - setPrevPage(5, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_BACK_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_BACK_BTN_NAME.getString()).setLore(Settings.GUI_BACK_BTN_LORE.getStringList()).toItemStack()); - setButton(5, 4, new TItemBuilder(Objects.requireNonNull(Settings.GUI_REFRESH_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_REFRESH_BTN_NAME.getString()).setLore(Settings.GUI_REFRESH_BTN_LORE.getStringList()).toItemStack(), e -> e.manager.showGUI(e.player, new GUITransactionList(this.player, this.showAll))); - setNextPage(5, 5, new TItemBuilder(Objects.requireNonNull(Settings.GUI_NEXT_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_NEXT_BTN_NAME.getString()).setLore(Settings.GUI_NEXT_BTN_LORE.getStringList()).toItemStack()); + 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()); // Other Buttons 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 1595f2d..3833ca9 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionType.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionType.java @@ -52,7 +52,7 @@ public final class GUITransactionType extends AbstractPlaceholderGui { setRows(4); setAcceptsItems(false); setUseLockedCells(true); - setDefaultItem(Settings.GUI_TRANSACTIONS_TYPE_BG_ITEM.getMaterial().parseItem()); + setDefaultItem(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_TRANSACTIONS_TYPE_BG_ITEM.getString())); draw(); } 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 a193271..57ca036 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionView.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/transaction/GUITransactionView.java @@ -46,7 +46,7 @@ public class GUITransactionView extends AbstractPlaceholderGui { setTitle(TextUtils.formatText(Settings.GUI_TRANSACTION_VIEW_TITLE.getString())); setRows(6); setAcceptsItems(false); - setDefaultItem(Settings.GUI_TRANSACTION_VIEW_BACKGROUND_ITEM.getMaterial().parseItem()); + getConfirmBuyNoItem()(ConfigurationItemHelper.createConfigurationItem(Settings.GUI_TRANSACTION_VIEW_BACKGROUND_ITEM.getString())); setUseLockedCells(Settings.GUI_TRANSACTION_VIEW_BACKGROUND_FILL.getBoolean()); setButton(5, 0, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CLOSE_BTN_ITEM.getString(), Settings.GUI_CLOSE_BTN_NAME.getString(), Settings.GUI_CLOSE_BTN_LORE.getStringList(), null), e -> e.manager.showGUI(e.player, new GUITransactionList(auctionPlayer.getPlayer(), showAll))); diff --git a/src/main/java/ca/tweetzy/auctionhouse/helpers/ConfigurationItemHelper.java b/src/main/java/ca/tweetzy/auctionhouse/helpers/ConfigurationItemHelper.java index 8e5a4c5..6b9691e 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/helpers/ConfigurationItemHelper.java +++ b/src/main/java/ca/tweetzy/auctionhouse/helpers/ConfigurationItemHelper.java @@ -27,6 +27,7 @@ import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Objects; @@ -74,6 +75,10 @@ public class ConfigurationItemHelper { return stack; } + public static ItemStack createConfigurationItem(String item) { + return createConfigurationItem(item, " ", new ArrayList<>(), null); + } + public static ItemStack createConfigurationItem(String item, String title, List lore, HashMap replacements) { String[] split = item.split(":");