-
Notifications
You must be signed in to change notification settings - Fork 32
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Hey, I need to create a paginated view that would look like this:
---------
<OOOOOOO>
<OOOOOOO>
<OOOOOOO>
---------
Where - is the filler, < and > are previous/next page buttons are O is where items would go, but I can't figure out how to that.
This is the code used in the plugin that I try to update
@Override
protected void onOpen(@NotNull OpenViewContext context) {
final var config = ViewModule.getMenuConfigManager().getConfig(WarpPaginatedMenuConfig.class);
context.setInventorySize(config.getLayout().length); // 6
context.setInventoryTitle(config.getTitle());
context.setLayout(config.getLayout()); // XXXXXXXXX, <OOOOOOO>, <OOOOOOO>, <OOOOOOO>, XXXXXXXXX, XXXXXXXXX
}
@Override
protected void onRender(ViewContext context) {
final var config = ViewModule.getMenuConfigManager().getConfig(WarpPaginatedMenuConfig.class);
LandUser landUser = context.get("landUser");
ViewHelper.setFillerAndDecorations(context, config);
setSource(landUser.getWarps());
if (landUser.getWarps().isEmpty()) {
config.noValuesItem().forEachSlot((slot, item) -> context.slot(slot, item.getItemStack()));
}
}
@Override
protected void onItemRender(PaginatedViewSlotContext<LandWarp> context, ViewItem viewItem, LandWarp value) {
final var config = ViewModule.getMenuConfigManager().getConfig(WarpPaginatedMenuConfig.class);
Player player = context.getPlayer();
viewItem.withItem(config.warpItem().createItem(value.createPlaceholders())).onClick(handler -> {
if (handler.getClickOrigin().isRightClick()) {
player.closeInventory();
player.performCommand("land delwarp " + value.getName());
} else if (handler.getClickOrigin().isLeftClick()) {
player.closeInventory();
player.performCommand("land warp " + value.getName());
} else if (handler.getClickOrigin().getClick() == ClickType.MIDDLE) {
value.setPublicWarp(!value.isPublicWarp());
player.sendMessage("§aYou make this warp §f" + (value.isPublicWarp() ? "public" : "private") + "§a successfully.");
if (value.isPublicWarp()) {
viewFrame.open(ChangeWarpCategoryView.class, player, ImmutableMap.of("landWarp", value));
} else {
value.setCategory(LandWarpCategory.NONE);
player.closeInventory();
}
}
});
}If the user doesn't have any warps, it looks good:

Also, I have this error when the layout doesn't have 6 rows: https://paste.helpch.at/zucofebeso.sql
