Search in sources :

Example 21 with ChestGui

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

the class TerritoryGUIs method initPane.

private static StaticPane initPane(Player player, Nodewar plugin, ChestGui gui, ChestGui previousGui, Territory territory) {
    StaticPane staticPane = new StaticPane(0, 0, 9, 2);
    vulnerabilityButton(player, plugin, territory, gui, staticPane);
    staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.RED_BANNER, "&9Empire", null, GUIs.adaptLore(player, null)), event -> {
        if (event.isRightClick()) {
            Objective objective = territory.getObjective();
            if (objective != null) {
                objective.reset();
            }
            player.sendMessage(AdaptMessage.playerMessage(player, AdaptMessage.territoryMessage(territory, LangManager.getMessage(LangMessage.TERRITORY_NEUTRALIZE))));
        } else {
            TerritoryEmpireGUIs.initGUI(player, plugin, gui, territory);
        }
    }), 4, 0);
    staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.BEACON, "&9Capture points", null, GUIs.adaptLore(player, null)), event -> {
        TerritoryPointsGUIs.initGUI(player, plugin, territory, gui);
    }), 7, 0);
    staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.BARRIER, "&9Previous Menu", null, GUIs.adaptLore(player, null)), event -> {
        previousGui.show(player);
    }), 4, 1);
    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) LangMessage(fr.rosstail.nodewar.lang.LangMessage) Objective(fr.rosstail.nodewar.territory.zonehandlers.objective.Objective) LangManager(fr.rosstail.nodewar.lang.LangManager) GUIs(fr.rosstail.nodewar.guis.GUIs) TerritoryVulnerabilityToggleEvent(fr.rosstail.nodewar.territory.eventhandlers.customevents.TerritoryVulnerabilityToggleEvent) Pane(com.github.stefvanschie.inventoryframework.pane.Pane) Territory(fr.rosstail.nodewar.territory.zonehandlers.Territory) Nodewar(fr.rosstail.nodewar.Nodewar) Material(org.bukkit.Material) Bukkit(org.bukkit.Bukkit) Objective(fr.rosstail.nodewar.territory.zonehandlers.objective.Objective) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) StaticPane(com.github.stefvanschie.inventoryframework.pane.StaticPane)

Example 22 with ChestGui

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

the class TerritoryGUIs method initGUI.

public static void initGUI(Player player, Nodewar plugin, Territory territory, ChestGui previousGui) {
    int invSize = 2;
    ChestGui gui = new ChestGui(invSize, AdaptMessage.playerMessage(player, territory.getDisplay()));
    StaticPane staticPane = initPane(player, plugin, gui, previousGui, territory);
    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 23 with ChestGui

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

the class TerritoryGUIs method vulnerabilityButton.

private static void vulnerabilityButton(Player player, Nodewar plugin, Territory territory, ChestGui gui, StaticPane staticPane) {
    Material vulnerableMaterial;
    if (territory.isVulnerable()) {
        vulnerableMaterial = Material.REDSTONE_TORCH;
    } else {
        vulnerableMaterial = Material.LEVER;
    }
    staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, vulnerableMaterial, "&9Vulnerability", null, GUIs.adaptLore(player, null)), event -> {
        TerritoryVulnerabilityToggleEvent toggleEvent = new TerritoryVulnerabilityToggleEvent(territory, !territory.isVulnerable());
        Bukkit.getPluginManager().callEvent(toggleEvent);
        if (!toggleEvent.isCancelled()) {
            vulnerabilityButton(player, plugin, territory, gui, staticPane);
            if (territory.isVulnerable()) {
                player.sendMessage(AdaptMessage.playerMessage(player, AdaptMessage.territoryMessage(territory, LangManager.getMessage(LangMessage.TERRITORY_VULNERABLE))));
            } else {
                player.sendMessage(AdaptMessage.playerMessage(player, AdaptMessage.territoryMessage(territory, LangManager.getMessage(LangMessage.TERRITORY_INVULNERABLE))));
            }
        }
        gui.update();
    }), 1, 0);
}
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) LangMessage(fr.rosstail.nodewar.lang.LangMessage) Objective(fr.rosstail.nodewar.territory.zonehandlers.objective.Objective) LangManager(fr.rosstail.nodewar.lang.LangManager) GUIs(fr.rosstail.nodewar.guis.GUIs) TerritoryVulnerabilityToggleEvent(fr.rosstail.nodewar.territory.eventhandlers.customevents.TerritoryVulnerabilityToggleEvent) Pane(com.github.stefvanschie.inventoryframework.pane.Pane) Territory(fr.rosstail.nodewar.territory.zonehandlers.Territory) Nodewar(fr.rosstail.nodewar.Nodewar) Material(org.bukkit.Material) Bukkit(org.bukkit.Bukkit) GuiItem(com.github.stefvanschie.inventoryframework.gui.GuiItem) Material(org.bukkit.Material) TerritoryVulnerabilityToggleEvent(fr.rosstail.nodewar.territory.eventhandlers.customevents.TerritoryVulnerabilityToggleEvent)

Example 24 with ChestGui

use of com.github.stefvanschie.inventoryframework.gui.type.ChestGui 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

GuiItem (com.github.stefvanschie.inventoryframework.gui.GuiItem)24 ChestGui (com.github.stefvanschie.inventoryframework.gui.type.ChestGui)24 ItemStack (org.bukkit.inventory.ItemStack)23 OutlinePane (com.github.stefvanschie.inventoryframework.pane.OutlinePane)21 StaticPane (com.github.stefvanschie.inventoryframework.pane.StaticPane)21 PaginatedPane (com.github.stefvanschie.inventoryframework.pane.PaginatedPane)14 Material (org.bukkit.Material)13 Player (org.bukkit.entity.Player)12 Pane (com.github.stefvanschie.inventoryframework.pane.Pane)9 GUIs (fr.rosstail.nodewar.guis.GUIs)9 AdaptMessage (fr.rosstail.nodewar.lang.AdaptMessage)9 Nodewar (fr.rosstail.nodewar.Nodewar)8 ArrayList (java.util.ArrayList)6 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)6 LangManager (fr.rosstail.nodewar.lang.LangManager)5 LangMessage (fr.rosstail.nodewar.lang.LangMessage)5 Territory (fr.rosstail.nodewar.territory.zonehandlers.Territory)5 File (java.io.File)4 IOException (java.io.IOException)4 ChatColor (org.bukkit.ChatColor)4