|
| 1 | +package net.swofty.type.skyblockgeneric.gui.inventories; |
| 2 | + |
| 3 | +import net.minestom.server.event.inventory.InventoryPreClickEvent; |
| 4 | +import net.minestom.server.inventory.InventoryType; |
| 5 | +import net.minestom.server.item.ItemStack; |
| 6 | +import net.swofty.type.generic.data.datapoints.DatapointInteger; |
| 7 | +import net.swofty.type.generic.gui.inventory.HypixelInventoryGUI; |
| 8 | +import net.swofty.type.generic.gui.inventory.ItemStackCreator; |
| 9 | +import net.swofty.type.generic.gui.inventory.item.GUIClickableItem; |
| 10 | +import net.swofty.type.generic.user.HypixelPlayer; |
| 11 | +import net.swofty.type.skyblockgeneric.data.SkyBlockDataHandler; |
| 12 | +import net.swofty.type.skyblockgeneric.item.SkyBlockItem; |
| 13 | +import net.swofty.type.skyblockgeneric.item.components.SoulflowComponent; |
| 14 | +import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer; |
| 15 | + |
| 16 | +public class GUIConsumeSoulflow extends HypixelInventoryGUI { |
| 17 | + |
| 18 | + private final SkyBlockItem item; |
| 19 | + |
| 20 | + public GUIConsumeSoulflow(SkyBlockItem item) { |
| 21 | + super("Consume Soulflow?", InventoryType.CHEST_4_ROW); |
| 22 | + this.item = item; |
| 23 | + |
| 24 | + if (!item.hasComponent(SoulflowComponent.class)) { |
| 25 | + throw new IllegalArgumentException("Item does not have SoulflowComponent"); |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + @Override |
| 30 | + public void onOpen(InventoryGUIOpenEvent e) { |
| 31 | + fill(FILLER_ITEM); |
| 32 | + set(new GUIClickableItem(13) { |
| 33 | + @Override |
| 34 | + public void run(InventoryPreClickEvent e, HypixelPlayer p) { |
| 35 | + SkyBlockPlayer player = (SkyBlockPlayer) p; |
| 36 | + SkyBlockDataHandler data = player.getSkyblockDataHandler(); |
| 37 | + int soulflow = data.get(SkyBlockDataHandler.Data.SOULFLOW, DatapointInteger.class).getValue(); |
| 38 | + int itemSoulflow = item.getComponent(SoulflowComponent.class).getAmount(); |
| 39 | + int addition = item.getAmount() * itemSoulflow; |
| 40 | + |
| 41 | + data.get(SkyBlockDataHandler.Data.SOULFLOW, DatapointInteger.class).setValue(soulflow + addition); |
| 42 | + player.sendMessage("§bYou internalized §3+" + addition + "⸎ Soulflow §band have a total of §3" + (soulflow + addition) + "⸎§b!"); |
| 43 | + |
| 44 | + player.getInventory().setItemStack(player.getHeldSlot(), ItemStack.AIR); |
| 45 | + player.closeInventory(); |
| 46 | + } |
| 47 | + |
| 48 | + @Override |
| 49 | + public ItemStack.Builder getItem(HypixelPlayer p) { |
| 50 | + SkyBlockPlayer player = (SkyBlockPlayer) p; |
| 51 | + SkyBlockDataHandler data = player.getSkyblockDataHandler(); |
| 52 | + int soulflow = data.get(SkyBlockDataHandler.Data.SOULFLOW, DatapointInteger.class).getValue(); |
| 53 | + |
| 54 | + int itemSoulflow = item.getComponent(SoulflowComponent.class).getAmount(); |
| 55 | + int addition = item.getAmount() * itemSoulflow; |
| 56 | + |
| 57 | + return ItemStackCreator.getStackHead( |
| 58 | + "§aConsume Soulflow?", |
| 59 | + "94f0c693b85658b0bae792c9f9b717eb024ab8c4b349455648ea08358b50ddc4", |
| 60 | + 1, |
| 61 | + "§7Takes all the §3⸎ Soulflow §7items in", |
| 62 | + "§7your inventory and internalizes them", |
| 63 | + "§7to be ready for use.", |
| 64 | + "", |
| 65 | + "§7Internalized: §3" + soulflow + "⸎", |
| 66 | + "", |
| 67 | + "§7Adding from inventory: §3+" + addition + "⸎ Soulflow", |
| 68 | + "", |
| 69 | + "§eClick to consume!" |
| 70 | + ); |
| 71 | + } |
| 72 | + }); |
| 73 | + set(GUIClickableItem.getCloseItem(31)); |
| 74 | + updateItemStacks(getInventory(), getPlayer()); |
| 75 | + } |
| 76 | + |
| 77 | + @Override |
| 78 | + public boolean allowHotkeying() { |
| 79 | + return false; |
| 80 | + } |
| 81 | + |
| 82 | + @Override |
| 83 | + public void onBottomClick(InventoryPreClickEvent e) { |
| 84 | + e.setCancelled(true); |
| 85 | + } |
| 86 | +} |
0 commit comments