public static void open(Player p, int page) { Player p1 = p; Fireworks config = plugin.getFireworks(); GUI gui = buildGui( config.getGuiName(), config.getGuiSize(), config.getHomeItem(), config.getPreviousItem(), config.getNextItem()); for (FireworkStorage firework : config.getFireworks()) { int position = getRealPosition(firework.getPosition(), page, config.getGuiSize()); if (position != -1) { ItemStack item = firework.getItem().clone(); gui.setItem(position, item); if (config.isNoPermissionItemEnabled() && !Methods.hasPermission(p1, firework.getPermission())) { gui.setItem(position, config.getNoPermissionItem(firework)); } } } PlayerOpenGuiEvent event = new PlayerOpenGuiEvent(p1, gui); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) return; gui = event.getGui(); p1 = event.getPlayer(); PAGEMAP.put(p1.getName(), page); gui.open(p1); }
@Override protected void handleClick(GUI gui, Player p, ItemStack item) { Fireworks config = plugin.getFireworks(); if (gui.getName().equals(Placeholders.parse(config.getGuiName(), p))) { CosmeticsAPI api = plugin.getApi(); if (config.getHomeItem().getItem().isSimilar(item)) { if (plugin.getBabies().getGuiClickSound() != null) Sounds.playSound(p, plugin.getBabies().getGuiClickSound()); CosmeticsGuiHandler.open(p); return; } if (Methods.isNoPermissionItem(config.getNoPermissionItem(), item)) { plugin.informPlayerNoPermission(p, config.getNoPermissionMessage()); return; } if (config.getPreviousItem().getItem().isSimilar(item)) { if (plugin.getBabies().getGuiClickSound() != null) Sounds.playSound(p, plugin.getBabies().getGuiClickSound()); int currPage = PAGEMAP.get(p.getName()); if (currPage == 0) open(p, config.getMaxPage()); else open(p, currPage - 1); return; } if (config.getNextItem().getItem().isSimilar(item)) { if (plugin.getBabies().getGuiClickSound() != null) Sounds.playSound(p, plugin.getBabies().getGuiClickSound()); int currPage = PAGEMAP.get(p.getName()); if (currPage == config.getMaxPage()) open(p, 0); else open(p, currPage + 1); return; } FireworkStorage firework = api.getFireworkByItemStack(item); if (!Methods.hasPermission(p, firework.getPermission())) { plugin.informPlayerNoPermission(p, config.getNoPermissionMessage()); return; } new FireworkImpl(p, firework).give(); p.closeInventory(); } }