WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Dynamic pagination cannot be accessed on user-defined layout pattern #245

@iGabyTM

Description

@iGabyTM

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();
                }
            }
        });
    }

But the menu looks like this:
image

If the user doesn't have any warps, it looks good:
image

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions