Search in sources :

Example 6 with GuiItem

use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project Nodewar by Rosstail.

the class TerritoryPointsGUIs method initPane.

private static StaticPane initPane(Player player, Nodewar plugin, ChestGui gui, ChestGui previousGui, PaginatedPane paginatedPane, Territory territory, int page) {
    StaticPane staticPane = new StaticPane(0, 0, 9, 6);
    ArrayList<Territory> subTerritories = new ArrayList<>(territory.getSubTerritories().values());
    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, territory.getDisplay() + "'s points - Page " + (page)));
            gui.update();
        }), 0, 5);
    }
    while (posY != 5) {
        while (posX != 9) {
            if (subTerritories.size() - 1 < index) {
                return staticPane;
            }
            Territory subTerritory = subTerritories.get(index);
            staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.BEACON, subTerritory.getDisplay(), null, GUIs.adaptLore(player, null)), event -> {
                TerritoryPointsGUIs.initGUI(player, plugin, subTerritory, gui);
            }), posX, posY);
            posX++;
            index++;
        }
        posX = 0;
        posY++;
    }
    if (subTerritories.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, territory.getDisplay() + "'s points - 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) 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) 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)

Example 7 with GuiItem

use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project Nodewar by Rosstail.

the class WorldsGUIs method initGUI.

public static void initGUI(Player player, Nodewar plugin) {
    int invSize = 6;
    String display = "Worlds - Page 1";
    ChestGui gui = new ChestGui(invSize, AdaptMessage.playerMessage(player, display));
    PaginatedPane paginatedPane = new PaginatedPane(0, 0, 9, invSize);
    OutlinePane background = new OutlinePane(0, 0, 9, gui.getRows(), Pane.Priority.LOWEST);
    background.addItem(new GuiItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE)));
    background.setRepeat(true);
    gui.addPane(background);
    int page = 0;
    while (true) {
        StaticPane staticPane = initPane(player, plugin, gui, paginatedPane, page);
        paginatedPane.addPane(page, staticPane);
        if (staticPane.getItems().size() < 47) {
            // 9 * 5 lines + 2 buttons
            break;
        }
        page++;
    }
    gui.setOnGlobalClick(event -> {
        event.setCancelled(true);
    });
    gui.addPane(paginatedPane);
    gui.show(player);
}
Also used : ChestGui(com.github.stefvanschie.inventoryframework.gui.type.ChestGui) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) PaginatedPane(com.github.stefvanschie.inventoryframework.pane.PaginatedPane) OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane) StaticPane(com.github.stefvanschie.inventoryframework.pane.StaticPane) ItemStack(org.bukkit.inventory.ItemStack)

Example 8 with GuiItem

use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project Nodewar by Rosstail.

the class PlayerAdminGUI method initGUI.

public static void initGUI(Player player, Nodewar plugin, Player target, ChestGui previousGui) {
    int invSize = 1;
    ChestGui gui = new ChestGui(invSize, AdaptMessage.playerMessage(target, target.getName()));
    StaticPane staticPane = initPane(player, plugin, gui, previousGui, target);
    OutlinePane background = new OutlinePane(0, 0, 9, gui.getRows(), Pane.Priority.LOWEST);
    background.addItem(new GuiItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE)));
    background.setRepeat(true);
    gui.addPane(background);
    gui.setOnGlobalClick(event -> {
        event.setCancelled(true);
    });
    gui.addPane(staticPane);
    gui.show(player);
}
Also used : ChestGui(com.github.stefvanschie.inventoryframework.gui.type.ChestGui) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane) StaticPane(com.github.stefvanschie.inventoryframework.pane.StaticPane) ItemStack(org.bukkit.inventory.ItemStack)

Example 9 with GuiItem

use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project Nodewar by Rosstail.

the class PlayerInfoGUI method initGUI.

public static void initGUI(Player player, fr.rosstail.nodewar.Nodewar plugin) {
    FileConfiguration customConfig = new YamlConfiguration();
    String path = "gui/playerInfoGUI.yml";
    File file = new File(plugin.getDataFolder(), path);
    try {
        customConfig.load(file);
        ChestGui gui = new ChestGui(customConfig.getInt("gui.size"), AdaptMessage.playerMessage(player, customConfig.getString("gui.display")));
        OutlinePane background = new OutlinePane(0, 0, 9, gui.getRows(), Pane.Priority.LOWEST);
        background.addItem(new GuiItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE)));
        background.setRepeat(true);
        gui.addPane(background);
        StaticPane itemSlot = new StaticPane(customConfig.getInt("gui.item-slot.x"), customConfig.getInt("gui.item-slot.y"), 9, gui.getRows(), Pane.Priority.HIGHEST);
        initPane(player, plugin, customConfig, itemSlot);
        gui.setOnGlobalClick(event -> {
            event.setCancelled(true);
            initPane(player, plugin, customConfig, itemSlot);
            gui.update();
        });
        gui.addPane(itemSlot);
        gui.show(player);
    } catch (IOException | InvalidConfigurationException e) {
        AdaptMessage.print("[" + Nodewar.getDimName() + "] Error while reading " + path + " file", AdaptMessage.prints.ERROR);
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) ChestGui(com.github.stefvanschie.inventoryframework.gui.type.ChestGui) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane) StaticPane(com.github.stefvanschie.inventoryframework.pane.StaticPane) IOException(java.io.IOException) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ItemStack(org.bukkit.inventory.ItemStack) File(java.io.File) InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException)

Example 10 with GuiItem

use of com.github.stefvanschie.inventoryframework.gui.GuiItem in project Nodewar by Rosstail.

the class WorldTerritoriesGUIs method initGUI.

public static void initGUI(Player player, Nodewar plugin, World world, ChestGui previousGui) {
    int invSize = 6;
    String display = world.getName() + "'s Territories - Page 1";
    ChestGui gui = new ChestGui(invSize, AdaptMessage.playerMessage(player, display));
    PaginatedPane paginatedPane = new PaginatedPane(0, 0, 9, invSize);
    OutlinePane background = new OutlinePane(0, 0, 9, gui.getRows(), Pane.Priority.LOWEST);
    background.addItem(new GuiItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE)));
    background.setRepeat(true);
    gui.addPane(background);
    int page = 0;
    while (true) {
        StaticPane staticPane = initPane(player, plugin, gui, previousGui, paginatedPane, world, page);
        paginatedPane.addPane(page, staticPane);
        if (staticPane.getItems().size() < 47) {
            // 9 * 5 lines + 2 buttons
            break;
        }
        page++;
    }
    gui.setOnGlobalClick(event -> {
        event.setCancelled(true);
    });
    gui.addPane(paginatedPane);
    gui.show(player);
}
Also used : ChestGui(com.github.stefvanschie.inventoryframework.gui.type.ChestGui) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) PaginatedPane(com.github.stefvanschie.inventoryframework.pane.PaginatedPane) OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane) StaticPane(com.github.stefvanschie.inventoryframework.pane.StaticPane) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

GuiItem (com.github.stefvanschie.inventoryframework.gui.GuiItem)46 ItemStack (org.bukkit.inventory.ItemStack)34 ChestGui (com.github.stefvanschie.inventoryframework.gui.type.ChestGui)28 OutlinePane (com.github.stefvanschie.inventoryframework.pane.OutlinePane)25 StaticPane (com.github.stefvanschie.inventoryframework.pane.StaticPane)21 Player (org.bukkit.entity.Player)20 Material (org.bukkit.Material)18 PaginatedPane (com.github.stefvanschie.inventoryframework.pane.PaginatedPane)15 Pane (com.github.stefvanschie.inventoryframework.pane.Pane)11 ItemBuilder (dte.employme.utils.items.ItemBuilder)11 GUIs (fr.rosstail.nodewar.guis.GUIs)9 AdaptMessage (fr.rosstail.nodewar.lang.AdaptMessage)9 Nodewar (fr.rosstail.nodewar.Nodewar)7 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)7 HumanEntity (org.bukkit.entity.HumanEntity)7 ArrayList (java.util.ArrayList)6 List (java.util.List)5 ChatColor (org.bukkit.ChatColor)5 NotNull (org.jetbrains.annotations.NotNull)5 Main (com.gmail.stefvanschiedev.buildinggame.Main)4