Improved the panel

This commit is contained in:
Niels Vergucht 2018-12-06 22:09:40 +01:00
parent e966fb519d
commit a9e417d667
2 changed files with 29 additions and 13 deletions

View File

@ -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<UUID, List<Genbucket>> gens = epicBuckets.getGenbucketManager().getActiveGens();
private ClickableItem[] createItems(HashMap<UUID, List<Genbucket>> gens, Player player) {
List<ClickableItem> 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));
}
}

View File

@ -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