Search in sources :

Example 36 with GuiItem

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

the class EmpiresListGUI method initPane.

private static void initPane(Player player, fr.rosstail.nodewar.Nodewar plugin, FileConfiguration customConfig, StaticPane itemSlot, ChestGui gui) {
    for (String slotName : customConfig.getConfigurationSection("gui.slots").getKeys(false)) {
        String slotPath = "gui.slots." + slotName;
        int posX = customConfig.getInt(slotPath + ".location.x");
        int posY = customConfig.getInt(slotPath + ".location.y");
        String display = AdaptMessage.playerMessage(player, customConfig.getString(slotPath + ".display"));
        Material material = Material.getMaterial(customConfig.getString(slotPath + ".material"));
        List<String> lore = customConfig.getStringList(slotPath + ".lore");
        Map<String, Empire> empires = EmpireManager.getEmpireManager().getEmpires();
        if (empires.containsKey(customConfig.getString(slotPath + ".empire"))) {
            Empire empire = empires.get(customConfig.getString(slotPath + ".empire"));
            itemSlot.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, customConfig, material, display, slotPath, GUIs.adaptLore(player, lore)), event -> {
                if (PlayerInfoManager.getPlayerInfoManager().getPlayerInfoMap().get(player).tryJoinEmpire(empire)) {
                    player.sendMessage(AdaptMessage.playerMessage(player, LangManager.getMessage(LangMessage.EMPIRE_PLAYER_JOIN)));
                }
                initPane(player, plugin, customConfig, itemSlot, gui);
                gui.update();
            }), posX, posY);
        } else {
            itemSlot.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, customConfig, material, display, slotPath, GUIs.adaptLore(player, lore))), posX, posY);
        }
    }
}
Also used : PlayerInfoManager(fr.rosstail.nodewar.datahandlers.PlayerInfoManager) OutlinePane(com.github.stefvanschie.inventoryframework.pane.OutlinePane) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ChestGui(com.github.stefvanschie.inventoryframework.gui.type.ChestGui) EmpireManager(fr.rosstail.nodewar.empires.EmpireManager) AdaptMessage(fr.rosstail.nodewar.lang.AdaptMessage) IOException(java.io.IOException) Player(org.bukkit.entity.Player) File(java.io.File) StaticPane(com.github.stefvanschie.inventoryframework.pane.StaticPane) ItemStack(org.bukkit.inventory.ItemStack) LangMessage(fr.rosstail.nodewar.lang.LangMessage) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) List(java.util.List) LangManager(fr.rosstail.nodewar.lang.LangManager) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) GUIs(fr.rosstail.nodewar.guis.GUIs) Map(java.util.Map) Empire(fr.rosstail.nodewar.empires.Empire) Pane(com.github.stefvanschie.inventoryframework.pane.Pane) Nodewar(fr.rosstail.nodewar.Nodewar) Material(org.bukkit.Material) InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) Empire(fr.rosstail.nodewar.empires.Empire) Material(org.bukkit.Material)

Example 37 with GuiItem

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

the class TerritoryPointsGUIs method initGUI.

public static void initGUI(Player player, Nodewar plugin, Territory territory, ChestGui previousGui) {
    int invSize = 6;
    String display = territory.getDisplay() + "'s points - 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, territory, 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 38 with GuiItem

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

the class WorldsGUIs method initPane.

private static StaticPane initPane(Player player, Nodewar plugin, ChestGui gui, PaginatedPane paginatedPane, int page) {
    StaticPane staticPane = new StaticPane(0, 0, 9, 6);
    List<World> worlds = new ArrayList<>(WorldTerritoryManager.getUsedWorlds().keySet());
    int index = 45 * page;
    int posY = 0;
    int posX = 0;
    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, "&cWorlds - Page " + (page)));
            gui.update();
        }), 0, 5);
    }
    while (posY != 5) {
        while (posX != 9) {
            if (worlds.size() - 1 < index) {
                return staticPane;
            }
            World world = worlds.get(index);
            staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.HEART_OF_THE_SEA, world.getName(), null, GUIs.adaptLore(player, null)), event -> {
                WorldTerritoriesGUIs.initGUI(player, plugin, world, gui);
            }), posX, posY);
            posX++;
            index++;
        }
        posY++;
    }
    if (worlds.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, "Worlds - 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) List(java.util.List) World(org.bukkit.World) GUIs(fr.rosstail.nodewar.guis.GUIs) Pane(com.github.stefvanschie.inventoryframework.pane.Pane) Nodewar(fr.rosstail.nodewar.Nodewar) WorldTerritoryManager(fr.rosstail.nodewar.territory.zonehandlers.WorldTerritoryManager) Material(org.bukkit.Material) PaginatedPane(com.github.stefvanschie.inventoryframework.pane.PaginatedPane) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) ArrayList(java.util.ArrayList) StaticPane(com.github.stefvanschie.inventoryframework.pane.StaticPane) World(org.bukkit.World)

Example 39 with GuiItem

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

the class PlayerAdminGUI method initPane.

private static StaticPane initPane(Player player, Nodewar plugin, ChestGui gui, ChestGui previousGui, Player target) {
    StaticPane staticPane = new StaticPane(0, 0, 9, 1);
    staticPane.addItem(new GuiItem(GUIs.createGuiItem(target, plugin, null, Material.RED_BANNER, "&9Empire", null, GUIs.adaptLore(target, null)), event -> {
        PlayerInfo targetInfo = PlayerInfoManager.getPlayerInfoManager().getPlayerInfoMap().get(target);
        if (event.isRightClick()) {
            targetInfo.leaveEmpire();
        } else {
            PlayerAdminEmpireGUIs.initGUI(player, plugin, gui, target);
        }
    }), 6, 0);
    return staticPane;
}
Also used : PlayerInfoManager(fr.rosstail.nodewar.datahandlers.PlayerInfoManager) 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) PlayerInfo(fr.rosstail.nodewar.datahandlers.PlayerInfo) GUIs(fr.rosstail.nodewar.guis.GUIs) Pane(com.github.stefvanschie.inventoryframework.pane.Pane) Nodewar(fr.rosstail.nodewar.Nodewar) Material(org.bukkit.Material) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) PlayerInfo(fr.rosstail.nodewar.datahandlers.PlayerInfo) StaticPane(com.github.stefvanschie.inventoryframework.pane.StaticPane)

Example 40 with GuiItem

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

the class PlayerInfoGUI method initPane.

private static void initPane(Player player, fr.rosstail.nodewar.Nodewar plugin, FileConfiguration customConfig, StaticPane itemSlot) {
    for (String slotName : customConfig.getConfigurationSection("gui.slots").getKeys(false)) {
        String slotPath = "gui.slots." + slotName;
        int posX = customConfig.getInt(slotPath + ".location.x");
        int posY = customConfig.getInt(slotPath + ".location.y");
        String display = AdaptMessage.playerMessage(player, customConfig.getString(slotPath + ".display"));
        Material material = Material.getMaterial(customConfig.getString(slotPath + ".material"));
        List<String> lore = customConfig.getStringList(slotPath + ".lore");
        itemSlot.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, customConfig, material, display, slotPath, GUIs.adaptLore(player, lore))), posX, posY);
    }
}
Also used : GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) Material(org.bukkit.Material)

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