123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
public void openCatalog(Player player, int menuId)
{
if(!pageView.containsKey(player.getUniqueId()))
pageView.put(player.getUniqueId(), 0);
InventoryMenu menu = new InventoryMenu("Banner Catalog: white", 45, Main.plug, new IMenuItemClicked()
{
@Override
public void onMenuItemClicked(MenuItemClicked clickEvent)
{
clickEvent.setCanClose(false);
ItemStack clicked = clickEvent.getItemClicked();
if(clicked.getType() == Material.BANNER)
player.getInventory().addItem(clicked);
else if(clicked.getType() == Material.BARRIER)
{
player.closeInventory();
pageView = null;
}
else if(clicked.getType() == Material.SPRUCE_DOOR_ITEM)
{
CatalogMenu.catalogSelect.open(player);
pageView = null;
}
if(pageView.containsKey(player.getUniqueId()))
{
BTBUtil.log(Prefix.TEST + "UTIL " + pageView);
if(clickEvent.getItemClicked().getType() == Material.STAINED_GLASS_PANE && clickEvent.getItemClicked().getItemMeta().getDisplayName().equalsIgnoreCase("Previous Page"))
{
Integer i = pageView.get(player.getUniqueId());
BTBUtil.log(Prefix.TEST + "MOOMOO_PREV " + i);
pageView.put(player.getUniqueId(), new Integer(i-1));
}
else if(clickEvent.getItemClicked().getType() == Material.STAINED_GLASS_PANE && clickEvent.getItemClicked().getItemMeta().getDisplayName().equalsIgnoreCase("Next Page"))
{
Integer i = pageView.get(player.getUniqueId());
BTBUtil.log(Prefix.TEST + "MOOMOO_NEXT " + i);
pageView.put(player.getUniqueId(), new Integer(i + 1));
}
}
else
pageView.put(player.getUniqueId(), new Integer(0));
}
});
int pitemStart = menu.pageView.get(player.getUniqueId()) * 40;
BTBUtil.log(Prefix.TEST + menu.pageView.get(player.getUniqueId()));
YamlConfiguration banners = YamlConfiguration.loadConfiguration(Main.bannerCatalogs[menuId]);
int x = (int) Math.ceil((double)banners.getConfigurationSection("Banners").getKeys(false).size()/40);
int j = 0;
for(int i = 0; i < 45; i++)
{
if(i == 8)
{
if(menu.pageView.get(player.getUniqueId()) != 0)
menu.setInvOption(8, new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.RED.getData()), "Previous Page", "");
else
menu.setInvOption(8, new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.RED.getData()), "No More Pages", "");
j = 1;
}
else if(i == 17)
{
if(menu.pageView.get(player.getUniqueId()) != x)
menu.setInvOption(17, new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.LIME.getData()), "Next Page", "");
else
menu.setInvOption(17, new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.LIME.getData()), "No More Pages", "");
j = 2;
}
else if(i == 26)
{
menu.setInvOption(26, new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.SILVER.getData()), " ", "");
j = 3;
}
else if(i == 35)
{
menu.setInvOption(35, new ItemStack(Material.BARRIER), "Exit", "");
j = 4;
}
else if(i == 44)
{
menu.setInvOption(44, new ItemStack(Material.SPRUCE_DOOR_ITEM), "Back", "");
j = 5;
}
else if(banners.getItemStack("Banners.entry_" + (((i+1) - j) + pitemStart)) != null)
menu.setInvOption(i, banners.getItemStack("Banners.entry_" + (((i+1) - j) + pitemStart)), "banner_" + (((i+1) - j) + pitemStart), "");
}
if(menu.pageView.get(player.getUniqueId()) == 0)
{
menu.loadMenu();
player.openInventory(menu.inventory);
}
}