use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project Nodewar by Rosstail.
the class WorldTerritoriesGUIs method initPane.
private static StaticPane initPane(Player player, Nodewar plugin, ChestGui gui, ChestGui previousGui, PaginatedPane paginatedPane, World world, int page) {
StaticPane staticPane = new StaticPane(0, 0, 9, 6);
ArrayList<Territory> territories = new ArrayList<>();
WorldTerritoryManager.getUsedWorlds().forEach((world1, worldTerritoryManager) -> {
worldTerritoryManager.getTerritories().forEach((s, territory) -> {
if (territory.getWorld().equals(world)) {
territories.add(territory);
}
});
});
int index = 45 * page;
int posY = 0;
int posX = 0;
staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.BARRIER, "&9Previous Menu", null, GUIs.adaptLore(player, null)), event -> {
previousGui.show(player);
}), 4, 5);
if (page > 0) {
staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.ARROW, "&9Previous page", null, GUIs.adaptLore(player, null)), event -> {
paginatedPane.setPage(page - 1);
gui.setTitle(AdaptMessage.playerMessage(player, world.getName() + "'s Territories' - Page " + (page)));
gui.update();
}), 0, 5);
}
while (posY != 5) {
while (posX != 9) {
if (territories.size() - 1 < index) {
return staticPane;
}
Territory territory = territories.get(index);
staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.FILLED_MAP, territory.getDisplay(), null, GUIs.adaptLore(player, null)), event -> {
TerritoryGUIs.initGUI(player, plugin, territory, gui);
}), posX, posY);
posX++;
index++;
}
posX = 0;
posY++;
}
if (territories.size() > index) {
staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.SPECTRAL_ARROW, "&Next page", null, GUIs.adaptLore(player, null)), event -> {
paginatedPane.setPage(page + 1);
gui.setTitle(AdaptMessage.playerMessage(player, world.getName() + "'s Territories - Page " + (page + 1)));
gui.update();
}), 8, 5);
}
return staticPane;
}
Aggregations