Resource Paged Inventory API

Discussion in 'Spigot Plugin Development' started by MrIvanPlays, Feb 7, 2020.

  1. I know... there are already existing ones there, but I find them a little bit hard to use. That's why I've made this resource

    [​IMG] | GitHub

    Here we go again.. I have a bunch of entries I need in a inventory, but it has only 54 slots. So I need a paged one. Well, here is your solution!

    It is being installed like a regular dependency



                <version>VERSION</version> <!-- Replace with latest version -->

    Code (Text):
    repositories {
        maven {
            url ""

    dependencies {
        implementation 'com.mrivanplays:PagedInventoryAPI:VERSION' // Replace VERSION with latest version

    This is just an example. You can make the inventories and everything how you want

    Code (Java):
            ItemStack previousPageItem = new ItemStack(Material.ARROW);
            ItemMeta previousPageMeta = previousPageItem.getItemMeta();
            previousPageMeta.setDisplayName("Go to previous page");
            NavigationItem previousPage = NavigationItem.create(previousPageItem, NavigationItem.Action.PREVIOUS_PAGE);

            ItemStack nextPageItem = new ItemStack(Material.ARROW);
            ItemMeta nextPageMeta = nextPageItem.getItemMeta();
            nextPageMeta.setDisplayName("Go to next page");
            NavigationItem nextPage = NavigationItem.create(nextPageItem, NavigationItem.Action.NEXT_PAGE);

            ItemStack closeItem = new ItemStack(Material.BARRIER);
            ItemMeta closeMeta = closeItem.getItemMeta();
            NavigationItem close = NavigationItem.create(closeItem, NavigationItem.Action.CLOSE);

            Inventory page1 = getServer().createInventory(null, 54, "Page #1");
            Inventory page2 = getServer().createInventory(null, 54, "Page #2");
            Inventory page3 = getServer().createInventory(null, 54, "Page #3");
            // adding sum items to the inventories or more inventories

            PagedInventory pagedInventory = PagedInventory.builder(/* plugin instance */ )
                    .page(1, page1)
                    .page(2, page2)
                    .page(3, page3)
                    // OR ELSE ERROR WILL BE THROWN
                    .navigationItem(53, nextPage)
                    .navigationItem(45, previousPage)
                    .navigationItem(49, close)
                    .clickFunction(click -> {
                        Page page = click.getPage();
                        // if the page is clicked on it means it is existing so the page number is present here
                        int pageNumber = pagedInventory.getPageNumber(page).getAsInt();
                        click.getClicker().sendMessage("You have clicked on page #" + pageNumber);
    Found here.

    Minecraft versions
    The tested minecraft version is 1.15.2. It may work on older versions, but if you are using on such and it works, no support is given for issues.
    #1 MrIvanPlays, Feb 7, 2020
    Last edited: Feb 9, 2020
    • Useful Useful x 3
  2. Looks really nice! Thanks!
  3. I think it'd be better if the navigationItem method was split up into three methods, one for next page, one for previous page and another one for closing. That way you can't have any confusion about which item should come first. Other than that, looks good.
  4. Why storing it in 3 object types while you can store it in 1? Also the thing you can name your variables ;)
    Thanks for the good words tho
  5. Oh, sorry, I misread the code, I didn't see that you wrapped the items into a navigation item. In that case, yeah looks good.
  6. I've found a solution for the javadocs generation. Javadocs of the API can be found here.
  7. Forgot to mention, you should relocate the dependency. I totally forgot about that
  8. Version 1.0.2 has been released, featuring a page close listener.
  9. Looks cool but maybe just make this a resource for a general api for inventories? Maybe at this time keep it for paged but may be worth it to expand it out to other stuff.

    Also what's with the inventory UUID? I assume it's for the viewers, but could've likely built a list of UUIDs as a separate viewers list per inventory.
  10. What you want in it, you can PR. I will review and if it's good, I'll merge.
  11. Not really interested it, just wanted to give a few additional stuff you can include (on your own decision) as I am assuming this is it's own inventory system.