use of be.pyrrh4.core.gui.GUI.InventoryClickType in project PyrCore by PYRRH4.
the class MultipleGUI method createNewPage.
// Create new page
public GUI createNewPage() {
final int pageNumber = pages.size() + 1;
final GUI page = new GUI(plugin, name + (pageNumber == 1 ? "" : " - p" + pageNumber), size, addItemMaxSlot, allowBottomInventoryClick, false, duplicateTolerance) {
@Override
public void preload() {
}
@Override
public void onClick(InventoryClickEvent event, Player player, InventoryClickType clickType, ItemStack clickedStack, ItemData clickedData, ItemStack cursorStack, ItemData cursorData) {
// Page selectors
if (clickedData != null && clickedData.getId().equals(MultipleGUI.this.itemPreviousPage.getId())) {
GUI page = getPage(pageNumber - 1);
if (page != null) {
page.open(player, isWatcher(player));
}
} else if (clickedData != null && clickedData.getId().equals(MultipleGUI.this.itemNextPage.getId())) {
GUI page = getPage(pageNumber + 1);
if (page != null) {
page.open(player, isWatcher(player));
}
} else // Other
{
MultipleGUI.this.onClick(event, this, pageNumber, player, clickType, clickedStack, clickedData, cursorStack, cursorData);
}
}
@Override
protected void onClose(InventoryCloseEvent event, final Player player) {
MultipleGUI.this.onClose(event, this, pageNumber, player);
// unregister
if (unregisterOnClose) {
new BukkitRunnable() {
@Override
public void run() {
for (GUI page : getPages()) {
if (!page.getTotalViewers().isEmpty()) {
return;
}
}
MultipleGUI.this.unregister(false);
}
}.runTaskLater(plugin, 20L);
}
}
@Override
protected void onCloseDisable(Inventory inventory, Player player) {
MultipleGUI.this.onCloseDisable(inventory, this, pageNumber, player);
}
};
pages.add(page);
preload(page, pageNumber);
updatePageSelectors();
return page;
}
Aggregations