Search in sources :

Example 1 with TownyInventory

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

the class ResidentUtil method createTownyGUI.

/*
	 * Big credit goes to Hex_27 for the guidance following his ScrollerInventory
	 * https://www.spigotmc.org/threads/infinite-inventory-with-pages.178964/
	 * 
	 * Nice and simple.
	 */
private static void createTownyGUI(Resident resident, ArrayList<ItemStack> items, String name) {
    Inventory page = getBlankPage(name);
    ArrayList<Inventory> pages = new ArrayList<>();
    for (ItemStack item : items) {
        if (page.firstEmpty() == 46) {
            pages.add(page);
            page = getBlankPage(name);
        }
        page.addItem(item);
    }
    pages.add(page);
    resident.setGUIPages(pages);
    resident.setGUIPageNum(0);
    new TownyInventory(resident, pages.get(0), name);
}
Also used : TownyInventory(com.palmergames.bukkit.towny.object.TownyInventory) ArrayList(java.util.ArrayList) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) TownyInventory(com.palmergames.bukkit.towny.object.TownyInventory)

Aggregations

TownyInventory (com.palmergames.bukkit.towny.object.TownyInventory)1 ArrayList (java.util.ArrayList)1 Inventory (org.bukkit.inventory.Inventory)1 ItemStack (org.bukkit.inventory.ItemStack)1