From a9e417d6677a27fbeae9bcddac8b42776701ab92 Mon Sep 17 00:00:00 2001 From: Niels Vergucht Date: Thu, 6 Dec 2018 22:09:40 +0100 Subject: [PATCH] Improved the panel --- .../com/songoda/epicbuckets/gui/GUIPanel.java | 38 +++++++++++++------ src/main/resources/config.yml | 4 +- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/songoda/epicbuckets/gui/GUIPanel.java b/src/main/java/com/songoda/epicbuckets/gui/GUIPanel.java index fedfd2c..bf18e8f 100644 --- a/src/main/java/com/songoda/epicbuckets/gui/GUIPanel.java +++ b/src/main/java/com/songoda/epicbuckets/gui/GUIPanel.java @@ -10,6 +10,7 @@ import fr.minuskube.inv.content.InventoryContents; import fr.minuskube.inv.content.InventoryProvider; import fr.minuskube.inv.content.Pagination; import fr.minuskube.inv.content.SlotIterator; +import me.lucko.helper.item.ItemStackBuilder; import org.bukkit.Material; import org.bukkit.SkullType; import org.bukkit.entity.Player; @@ -30,14 +31,9 @@ public class GUIPanel implements InventoryProvider { .manager(EpicBuckets.getInstance().getInventoryManager()) .build(); - - @Override - public void init(Player player, InventoryContents inventoryContents) { - HashMap> gens = epicBuckets.getGenbucketManager().getActiveGens(); + private ClickableItem[] createItems(HashMap> gens, Player player) { List itemList = new ArrayList<>(); - Pagination pagination = inventoryContents.pagination(); - for (UUID uuid : gens.keySet()) { if (gens.get(uuid).size() < 1) continue; for (Genbucket genbucket : gens.get(uuid)) { @@ -51,17 +47,37 @@ public class GUIPanel implements InventoryProvider { } } - pagination.setItems(itemList.toArray(new ClickableItem[1])); - pagination.setItemsPerPage(7); - pagination.addToIterator(inventoryContents.newIterator(SlotIterator.Type.HORIZONTAL, 1, 1)); + return itemList.toArray(new ClickableItem[1]); + } - inventoryContents.set(5, 3, ClickableItem.of(new ItemStack(Material.ARROW), + @Override + public void init(Player player, InventoryContents inventoryContents) { + Pagination pagination = inventoryContents.pagination(); + + pagination.setItems(createItems(epicBuckets.getGenbucketManager().getActiveGens(), player)); + pagination.setItemsPerPage(36); + pagination.addToIterator(inventoryContents.newIterator(SlotIterator.Type.HORIZONTAL, 0, 0)); + + inventoryContents.set(5, 0, ClickableItem.of(ItemStackBuilder.of(XMaterial.ARROW.parseMaterial()).name("&fPrevious").build(), e -> PANEL.open(player, pagination.previous().getPage()))); - inventoryContents.set(5, 5, ClickableItem.of(new ItemStack(Material.ARROW), + inventoryContents.set(5, 4, ClickableItem.of(ItemStackBuilder.of(XMaterial.REDSTONE_BLOCK.parseMaterial()).name("&cExit").build(), + e -> PANEL.close(player))); + inventoryContents.set(5, 8, ClickableItem.of(ItemStackBuilder.of(XMaterial.ARROW.parseMaterial()).name("&fNext").build(), e -> PANEL.open(player, pagination.next().getPage()))); } @Override public void update(Player player, InventoryContents inventoryContents) { + int state = inventoryContents.property("state", 0); + inventoryContents.setProperty("state", state + 1); + + if(state % 60 != 0) + return; + + Pagination pagination = inventoryContents.pagination(); + + pagination.setItems(createItems(epicBuckets.getGenbucketManager().getActiveGens(), player)); + pagination.setItemsPerPage(36); + pagination.addToIterator(inventoryContents.newIterator(SlotIterator.Type.HORIZONTAL, 0, 0)); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e3eda4d..09c1423 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -28,11 +28,11 @@ MAX-ACTIVE-GEN-PER-PLAYER: 10 # Amount of gens a player can have active at time PLACE-UNLIMTED-GENS: true # This will override MAX-ACTIVE-GEN-PER-PLAYER and let them place unlimted gens -MAX-VERTICAL-HEIGHT: 256 # Vertical gen height, the gen will stop if y > 256 +MAX-VERTICAL-HEIGHT: 50 # Vertical gen height, the gen will stop if y > 256 MAX-HORIZONTAL-LENGTH: 50 # Horizontal height -DELAY: 10 # If delay is set to 20 it will place one block every second. 10 will place two blocks each second +DELAY: 5 # If delay is set to 20 it will place one block every second. 10 will place two blocks each second DISABLE-GENBUCKETS: false # If enabled placing any genbuckets wont be placeable