From 76ab8ba8b052305f0c6c36445604c2bb575a1e67 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Wed, 29 May 2024 14:05:42 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=88=EF=B8=8F=20moved=20shulker/bundle=20i?= =?UTF-8?q?nspect=20gui=20to=20new=20layout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 6 minutes Took 12 seconds --- .../guis/GUIContainerInspect.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIContainerInspect.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIContainerInspect.java index b2b2270..761f3e9 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIContainerInspect.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIContainerInspect.java @@ -21,15 +21,19 @@ package ca.tweetzy.auctionhouse.guis; import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.auction.AuctionedItem; +import ca.tweetzy.auctionhouse.guis.abstraction.AuctionPagedGUI; import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmPurchase; import ca.tweetzy.auctionhouse.helpers.BundleUtil; import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.settings.Settings; +import ca.tweetzy.core.gui.events.GuiClickEvent; import ca.tweetzy.core.utils.TextUtils; +import ca.tweetzy.flight.utils.QuickItem; import org.bukkit.block.ShulkerBox; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BlockStateMeta; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -40,12 +44,9 @@ import java.util.stream.Collectors; * Time Created: 12:28 p.m. * Usage of any code found within this class is prohibited unless given explicit permission otherwise */ -public class GUIContainerInspect extends AbstractPlaceholderGui { +public class GUIContainerInspect extends AuctionPagedGUI { - private final int[] fillSlots = {0, 1, 2, 3, 4, 5, 6, 7, 8, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 46, 47, 48, 50, 51, 52, 53}; private final ItemStack container; - private List items; - private AuctionPlayer auctionPlayer; private AuctionedItem auctionItem; private boolean buyingSpecificQuantity; @@ -57,15 +58,13 @@ public class GUIContainerInspect extends AbstractPlaceholderGui { * @param container is the shulker box */ public GUIContainerInspect(AuctionPlayer auctionPlayer, ItemStack container) { - super(auctionPlayer); + super(null, auctionPlayer.getPlayer(), Settings.GUI_INSPECT_TITLE.getString(), 6, new ArrayList<>()); this.container = container; this.fromPurchaseGUI = false; - setTitle(TextUtils.formatText(Settings.GUI_INSPECT_TITLE.getString())); - setDefaultItem(ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_INSPECT_BG_ITEM.getString())); + setDefaultItem(QuickItem.bg(QuickItem.of(Settings.GUI_INSPECT_BG_ITEM.getString()).make())); setUseLockedCells(false); setAcceptsItems(false); setAllowDrops(false); - setRows(6); if (BundleUtil.isBundledItem(this.container)) { this.items = BundleUtil.extractBundleItems(this.container); @@ -77,8 +76,8 @@ public class GUIContainerInspect extends AbstractPlaceholderGui { this.items = Arrays.asList(skulkerBox.getInventory().getContents()); } - draw(); setOnClose(close -> close.manager.showGUI(close.player, new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(close.player.getUniqueId())))); + draw(); } public GUIContainerInspect(ItemStack container, AuctionPlayer auctionPlayer, AuctionedItem auctionItem, boolean buyingSpecificQuantity) { @@ -95,14 +94,9 @@ public class GUIContainerInspect extends AbstractPlaceholderGui { }); } - private void draw() { - reset(); - pages = (int) Math.max(1, Math.ceil(this.items.size() / (double) 36L)); - - for (int i : fillSlots) setItem(i, getDefaultItem()); - - setPrevPage(5, 3, getPreviousPageItem()); - setButton(5, 4, getBackButtonItem(), e -> { + @Override + protected void drawFixed() { + setButton(5, 0, getBackButton(), e -> { if (fromPurchaseGUI) { AuctionHouse.getInstance().getTransactionManager().addPrePurchase(e.player, auctionItem.getId()); e.manager.showGUI(e.player, new GUIConfirmPurchase(this.auctionPlayer, this.auctionItem, this.buyingSpecificQuantity)); @@ -110,13 +104,19 @@ public class GUIContainerInspect extends AbstractPlaceholderGui { e.manager.showGUI(e.player, new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(e.player.getUniqueId()))); } }); - setNextPage(5, 5, getNextPageItem()); - setOnPage(e -> draw()); + } - int slot = 0; - List data = this.items.stream().skip((page - 1) * 36L).limit(36L).collect(Collectors.toList()); - for (ItemStack item : data) { - setItem(slot++, item); - } + @Override + protected ItemStack makeDisplayItem(ItemStack item) { + return item; + } + + @Override + protected void onClick(ItemStack item, GuiClickEvent click) { + } + + @Override + protected List fillSlots() { + return Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 46, 47, 48, 50, 51, 52, 53); } }