use of com.github.stefvanschie.inventoryframework.pane.PaginatedPane in project oraxen by oraxen.
the class ItemsView method createSubGUI.
private ChestGui createSubGUI(final String fileName, final List<ItemBuilder> items) {
final int rows = Math.min((items.size() - 1) / 9 + 2, 6);
final ChestGui gui = new ChestGui(6, getMenuTexture(settings.getString(String.format("gui_inventory.%s.color", Utils.removeExtension(fileName)))));
final PaginatedPane pane = new PaginatedPane(9, rows);
for (int i = 0; i < (items.size() - 1) / 45 + 1; i++) {
final List<ItemStack> itemStackList = extractPageItems(items, i);
final StaticPane staticPane = new StaticPane(9, Math.min((itemStackList.size() - 1) / 9 + 1, 5));
for (int itemIndex = 0; itemIndex < itemStackList.size(); itemIndex++) {
final ItemStack oraxenItem = itemStackList.get(itemIndex);
staticPane.addItem(new GuiItem(oraxenItem, event -> event.getWhoClicked().getInventory().addItem(oraxenItem)), itemIndex % 9, itemIndex / 9);
}
pane.addPane(i, staticPane);
}
// page selection
final StaticPane back = new StaticPane(2, 5, 1, 1);
final StaticPane forward = new StaticPane(6, 5, 1, 1);
final StaticPane exit = new StaticPane(4, 5, 9, 1);
back.addItem(new GuiItem((OraxenItems.getItemById("arrow_previous_icon") == null ? new ItemBuilder(Material.ARROW) : OraxenItems.getItemById("arrow_previous_icon")).build(), event -> {
pane.setPage(pane.getPage() - 1);
if (pane.getPage() == 0)
back.setVisible(false);
forward.setVisible(true);
gui.update();
}), 0, 0);
back.setVisible(false);
forward.addItem(new GuiItem((OraxenItems.getItemById("arrow_next_icon") == null ? new ItemBuilder(Material.ARROW) : OraxenItems.getItemById("arrow_next_icon")).build(), event -> {
pane.setPage(pane.getPage() + 1);
if (pane.getPage() == pane.getPages() - 1)
forward.setVisible(false);
back.setVisible(true);
gui.update();
}), 0, 0);
if (pane.getPages() <= 1)
forward.setVisible(false);
exit.addItem(new GuiItem((OraxenItems.getItemById("exit_icon") == null ? new ItemBuilder(Material.BARRIER) : OraxenItems.getItemById("exit_icon")).build(), event -> mainGui.show(event.getWhoClicked())), 0, 0);
gui.addPane(back);
gui.addPane(forward);
gui.addPane(exit);
gui.addPane(pane);
gui.setOnGlobalClick(event -> event.setCancelled(true));
return gui;
}
use of com.github.stefvanschie.inventoryframework.pane.PaginatedPane in project CommandPrompter by CyR1en.
the class PlayerUIPrompt method sendPrompt.
@Override
public void sendPrompt() {
gui.setOnClose(e -> getPromptManager().cancel(getContext().getSender()));
var p = (Player) getContext().getSender();
var skullPane = new PaginatedPane(0, 0, 9, size - 1);
var isSorted = getPlugin().getPromptConfig().sorted();
var isPerWorld = getPlugin().getPromptConfig().isPerWorld();
var skulls = isPerWorld ? (isSorted ? SkullCache.getSkullsSortedFor(p.getWorld().getPlayers()) : SkullCache.getSkullsFor(p.getWorld().getPlayers())) : (isSorted ? SkullCache.getSkullsSorted() : SkullCache.getSkulls());
skullPane.populateWithItemStacks(skulls);
skullPane.setOnClick(this::processClick);
gui.addPane(skullPane);
gui.addPane(new ControlPane(getPlugin(), skullPane, gui, getContext(), size));
gui.show((HumanEntity) getContext().getSender());
}
use of com.github.stefvanschie.inventoryframework.pane.PaginatedPane in project Nodewar by Rosstail.
the class PlayerAdminEmpireGUIs method initPane.
private static StaticPane initPane(Player player, fr.rosstail.nodewar.Nodewar plugin, ChestGui gui, ChestGui previousGui, PaginatedPane paginatedPane, Player target, int page) {
StaticPane staticPane = new StaticPane(0, 0, 9, 6);
ArrayList<Empire> empires = new ArrayList<>(EmpireManager.getEmpireManager().getEmpires().values());
int index = 45 * page;
int posY = 0;
int posX = 0;
staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.BARRIER, "&9Previous Menu", null, GUIs.adaptLore(player, null)), event -> {
previousGui.show(player);
}), 4, 5);
if (page > 0) {
staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.ARROW, "&9Previous page", null, GUIs.adaptLore(player, null)), event -> {
paginatedPane.setPage(page - 1);
gui.setTitle(AdaptMessage.playerMessage(target, target.getName() + "'s Empire - Page " + (page)));
gui.update();
}), 0, 5);
}
while (posY != 5) {
while (posX != 9) {
if (empires.size() - 1 < index) {
return staticPane;
}
Empire empire = empires.get(index);
staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.RED_BANNER, empire.getDisplay(), null, GUIs.adaptLore(player, null)), event -> {
PlayerInfo targetInfo = PlayerInfoManager.getPlayerInfoManager().getPlayerInfoMap().get(target);
targetInfo.leaveEmpire();
targetInfo.setEmpire(empire);
player.sendMessage(AdaptMessage.playerMessage(target, LangManager.getMessage(LangMessage.EMPIRE_PLAYER_SET)));
previousGui.show(player);
}), posX, posY);
posX++;
index++;
}
posX = 0;
posY++;
}
if (empires.size() > index) {
staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.SPECTRAL_ARROW, "&Next page", null, GUIs.adaptLore(player, null)), event -> {
paginatedPane.setPage(page + 1);
gui.setTitle(AdaptMessage.playerMessage(player, target.getName() + "'s Empire - Page " + (page + 1)));
gui.update();
}), 8, 5);
}
return staticPane;
}
use of com.github.stefvanschie.inventoryframework.pane.PaginatedPane in project Nodewar by Rosstail.
the class TerritoryPointsGUIs method initPane.
private static StaticPane initPane(Player player, Nodewar plugin, ChestGui gui, ChestGui previousGui, PaginatedPane paginatedPane, Territory territory, int page) {
StaticPane staticPane = new StaticPane(0, 0, 9, 6);
ArrayList<Territory> subTerritories = new ArrayList<>(territory.getSubTerritories().values());
int index = 45 * page;
int posY = 0;
int posX = 0;
staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.BARRIER, "&9Previous Menu", null, GUIs.adaptLore(player, null)), event -> {
previousGui.show(player);
}), 4, 5);
if (page > 0) {
staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.ARROW, "&9Previous page", null, GUIs.adaptLore(player, null)), event -> {
paginatedPane.setPage(page - 1);
gui.setTitle(AdaptMessage.playerMessage(player, territory.getDisplay() + "'s points - Page " + (page)));
gui.update();
}), 0, 5);
}
while (posY != 5) {
while (posX != 9) {
if (subTerritories.size() - 1 < index) {
return staticPane;
}
Territory subTerritory = subTerritories.get(index);
staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.BEACON, subTerritory.getDisplay(), null, GUIs.adaptLore(player, null)), event -> {
TerritoryPointsGUIs.initGUI(player, plugin, subTerritory, gui);
}), posX, posY);
posX++;
index++;
}
posX = 0;
posY++;
}
if (subTerritories.size() > index) {
staticPane.addItem(new GuiItem(GUIs.createGuiItem(player, plugin, null, Material.SPECTRAL_ARROW, "&Next page", null, GUIs.adaptLore(player, null)), event -> {
paginatedPane.setPage(page + 1);
gui.setTitle(AdaptMessage.playerMessage(player, territory.getDisplay() + "'s points - Page " + (page + 1)));
gui.update();
}), 8, 5);
}
return staticPane;
}
use of com.github.stefvanschie.inventoryframework.pane.PaginatedPane in project Nodewar by Rosstail.
the class WorldsGUIs method initGUI.
public static void initGUI(Player player, Nodewar plugin) {
int invSize = 6;
String display = "Worlds - Page 1";
ChestGui gui = new ChestGui(invSize, AdaptMessage.playerMessage(player, display));
PaginatedPane paginatedPane = new PaginatedPane(0, 0, 9, invSize);
OutlinePane background = new OutlinePane(0, 0, 9, gui.getRows(), Pane.Priority.LOWEST);
background.addItem(new GuiItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE)));
background.setRepeat(true);
gui.addPane(background);
int page = 0;
while (true) {
StaticPane staticPane = initPane(player, plugin, gui, paginatedPane, page);
paginatedPane.addPane(page, staticPane);
if (staticPane.getItems().size() < 47) {
// 9 * 5 lines + 2 buttons
break;
}
page++;
}
gui.setOnGlobalClick(event -> {
event.setCancelled(true);
});
gui.addPane(paginatedPane);
gui.show(player);
}
Aggregations