Search in sources :

Example 16 with PaginatedPane

use of com.github.stefvanschie.inventoryframework.pane.PaginatedPane 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;
}
Also used : OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ChestGui(com.github.stefvanschie.inventoryframework.gui.type.ChestGui) AdaptMessage(fr.rosstail.nodewar.lang.AdaptMessage) Player(org.bukkit.entity.Player) StaticPane(com.github.stefvanschie.inventoryframework.pane.StaticPane) ItemStack(org.bukkit.inventory.ItemStack) ArrayList(java.util.ArrayList) World(org.bukkit.World) GUIs(fr.rosstail.nodewar.guis.GUIs) Pane(com.github.stefvanschie.inventoryframework.pane.Pane) Territory(fr.rosstail.nodewar.territory.zonehandlers.Territory) Nodewar(fr.rosstail.nodewar.Nodewar) WorldTerritoryManager(fr.rosstail.nodewar.territory.zonehandlers.WorldTerritoryManager) Material(org.bukkit.Material) PaginatedPane(com.github.stefvanschie.inventoryframework.pane.PaginatedPane) Territory(fr.rosstail.nodewar.territory.zonehandlers.Territory) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ArrayList(java.util.ArrayList) StaticPane(com.github.stefvanschie.inventoryframework.pane.StaticPane)

Aggregations

PaginatedPane (com.github.stefvanschie.inventoryframework.pane.PaginatedPane)16 GuiItem (com.github.stefvanschie.inventoryframework.gui.GuiItem)15 ChestGui (com.github.stefvanschie.inventoryframework.gui.type.ChestGui)14 ItemStack (org.bukkit.inventory.ItemStack)14 OutlinePane (com.github.stefvanschie.inventoryframework.pane.OutlinePane)13 StaticPane (com.github.stefvanschie.inventoryframework.pane.StaticPane)11 Material (org.bukkit.Material)9 Player (org.bukkit.entity.Player)9 ArrayList (java.util.ArrayList)6 Pane (com.github.stefvanschie.inventoryframework.pane.Pane)5 GUIs (fr.rosstail.nodewar.guis.GUIs)5 AdaptMessage (fr.rosstail.nodewar.lang.AdaptMessage)5 Nodewar (fr.rosstail.nodewar.Nodewar)4 ChatColor (org.bukkit.ChatColor)4 Main (com.gmail.stefvanschiedev.buildinggame.Main)3 MessageManager (com.gmail.stefvanschiedev.buildinggame.managers.messages.MessageManager)3 Territory (fr.rosstail.nodewar.territory.zonehandlers.Territory)3 List (java.util.List)3 Orientable (com.github.stefvanschie.inventoryframework.pane.Orientable)2 PercentageBar (com.github.stefvanschie.inventoryframework.pane.component.PercentageBar)2