Search in sources :

Example 1 with SelectionGUI

use of com.palmergames.bukkit.towny.object.gui.SelectionGUI in project Towny by TownyAdvanced.

the class ResidentUtil method openSelectionGUI.

public static void openSelectionGUI(Resident resident, SelectionGUI.SelectionType selectionType) {
    String inventoryName = Translatable.of("gui_title_select_plot_type").forLocale(resident);
    Inventory page = getBlankPage(inventoryName);
    ArrayList<Inventory> pages = new ArrayList<>();
    for (TownBlockType townBlockType : TownBlockTypeHandler.getTypes().values()) {
        ItemStack item = new ItemStack(Material.GRASS_BLOCK);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(Colors.Gold + townBlockType.getFormattedName());
        item.setItemMeta(meta);
        if (page.firstEmpty() == 46) {
            pages.add(page);
            page = getBlankPage(inventoryName);
        }
        page.addItem(item);
    }
    pages.add(page);
    resident.setGUIPageNum(0);
    resident.setGUIPages(pages);
    new SelectionGUI(resident, pages.get(0), inventoryName, selectionType);
}
Also used : TownBlockType(com.palmergames.bukkit.towny.object.TownBlockType) ArrayList(java.util.ArrayList) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) TownyInventory(com.palmergames.bukkit.towny.object.TownyInventory) ItemMeta(org.bukkit.inventory.meta.ItemMeta) SelectionGUI(com.palmergames.bukkit.towny.object.gui.SelectionGUI)

Aggregations

TownBlockType (com.palmergames.bukkit.towny.object.TownBlockType)1 TownyInventory (com.palmergames.bukkit.towny.object.TownyInventory)1 SelectionGUI (com.palmergames.bukkit.towny.object.gui.SelectionGUI)1 ArrayList (java.util.ArrayList)1 Inventory (org.bukkit.inventory.Inventory)1 ItemStack (org.bukkit.inventory.ItemStack)1 ItemMeta (org.bukkit.inventory.meta.ItemMeta)1