IPVP-MC / canvas

Canvas is a java library built for Bukkit to manage custom inventory based menus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'org.ipvp.canvas.mask.Mask2D' is deprecated

MrClean1337 opened this issue · comments

So how should I use this example the right or new way?
https://github.com/IPVP-MC/canvas#pagination

Other question?
Is this project still maintained? Should I use this for production?

As I compiled the sources with it, I saw in my IDE, that I should use BinaryMask.

But I have a other problem with PaginatedMenuBuilder...
With this code: https://pastebin.com/6hthptyt

It ends up like this ...
image

It opens at the last page! (Yes I just could open the first page in reverse order)
And the items are not exactly sorted like my LinkedList!
Aaaannd the GRAY_STAINED_GLASS_PANE at the bottom are missing.
Help?

This project isn't maintained anymore

Hey @MrClean1337, although the project isn't as actively maintained as before it is considered stable and can definitely be used for plugins in production environments.

There are a few issues that I can see with the code you've provided, but I'm not really sure why the items aren't inserting in the correct order for you - I tested this and wasn't able to recreate (my items went in correctly).

For the last menu always being the one opened, this is happening because of the scheduled task you have at the bottom of your code. When you run paginatedMenuBuilder.build(), it returns a list of all the pages that have been built. You are iterating through that list and opening each page - so the last item you iterate and open will be the last page of the pagination. You should only have to open the first page like this:

List<Menu> pages = paginatedMenuBuilder.build();
Menu firstPage = pages.get(0);
firstPage.open(player);

For the title of your menu, the library currently doesn't support dynamic titles so you'll probably want to remove the 1/3 text from it and keep it to something like:

ChestMenu.Builder pageTemplate = ChestMenu.builder(6).title("Sign-Galerie | Neuste zuerst").redraw(true);

For your glass panes not showing up, the item mask you applied is only specific to the slot positions of items in the pagination. If you want, the best way to add glass panes to the bottom row would be using the newMenuModifier method of the paginated menu builder, something like this:

PaginatedMenuBuilder paginatedMenuBuilder = PaginatedMenuBuilder.builder(pageTemplate)
        // ...
        .newMenuModifier(menu -> {
            Mask fillBottomRowMask = RecipeMask.builder(menu)
                    .item('B', new ItemStack(Material.BOOK, 1))
                    .item('p', new ItemStack(Material.STAINED_GLASS_PANE))
                    .row(6).pattern("0pppBppp0")
                    .build();
            fillBottomRowMask.apply(menu);
        });

One other issue I noticed is that I think your next/previous page buttons are mixed up. Your next button should be in slot 53 and your previous in slot 45.

I don't have your items list, but here is some sample code of your menu in a quick test plugin: https://gist.github.com/sainttx/e51744b167eec2d18c6b4f9e4897576c

The final product of this code looks like this (this was using Spigot 1.19.2 and a Minecraft 1.19.2 client to show that it works on the latest version):
javaw_09-06-22_17-06-04

I forgot to mention, I've updated the README's outdated reference to Mask2D as well.