✈️ moved shulker/bundle inspect gui to new layout

Took 6 minutes

Took 12 seconds
This commit is contained in:
Kiran Hart 2024-05-29 14:05:42 -04:00
parent c915bc7752
commit 76ab8ba8b0
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3

View File

@ -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<ItemStack> {
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<ItemStack> 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<ItemStack> 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<Integer> 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);
}
}