DSMAPI - Simple Menu API 1.3

A simple lightweight Menu API for all minecraft versions.

  1. Deleranax
    Native Minecraft Version:
    1.16
    Tested Minecraft Versions:
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    • 1.13
    • 1.14
    • 1.15
    • 1.16
    Source Code:
    https://github.com/Dwight-Studio/DSMAPI
    You don't want to bother making an API that manages the menus of your plugins? Other menu APIs are too complex, with too many useless features? Try DSMAPI.

    FEATURES

    • Easy content & action insertion
    • Multi interface compatibility
    • Infinite customization with the modification of the inventory view
    • 2D array management tools to simplify the addition of content
    • Prebuilt menu (player selection...) (WIP)
    • Wide spigot & minecraft version compatibility

    GETTING STARTED

    First of all you need to download the API and add it to the libraries of your project. (The procedure depends on your IDE or on the tools you use).

    To import it with maven, visit https://jitpack.io/#Dwight-Studio/DSMAPI/1.2

    To create a menu, you can follow this example :
    Code (Java):

    // The class must extend Menu or SimpleMenu (if you just need a single page)
    public class TestMenu extends Menu {

        // Give the name of the menu (can be used if a page hasn't name)
        @Override
        public String getName() {
            return ChatColor.LIGHT_PURPLE + "" + ChatColor.ITALIC + "DSMAPI testing menu";
        }

        // Supply the pages to the menu. Not required for SimpleMenu as the object itself is a page.
        @Override
        public Page[] getPages() {
            Page[] pages = new Page[getPageCount()];

            // For each page of the menu, define its property
            pages[0] = new Page() {
                // Give the name displayed at the top of the inventory
                @Override
                public String getName() {
                    return ChatColor.LIGHT_PURPLE + "" + ChatColor.ITALIC + "DSMAPI testing menu page 1";
                }

                // Supply the content of the inventory
                @Override
                public ItemStack[] getContent() {

                    // Methode to generate a 2D array of the shape of the inventory
                    ItemStack[][] content = getPageType().getBlank2DArray();

                    // Add the items
                    content[1][4] = new ItemCreator(Material.APPLE).setName("Give Apple").getItem();
                    content[2][8] = new ItemCreator(Material.ARROW).setName("Next Page").getItem();

                    // Flatten the 2D Array (the methods return a 1D Array)
                    return getPageType().flatten(content);
                }

                // Give the page type (see PageType https://github.com/Dwight-Studio/DSMAPI/blob/1.16/src/main/java/fr/dwightstudio/dsmapi/pages/PageType.java)
                @Override
                public PageType getPageType() {
                    return PageType.CHEST;
                }

                // Event fired when the player click
                @Override
                public void onClick(MenuView view, ClickType clickType, int slot, ItemStack itemStack) {
                    if (itemStack == null) return;

                    switch (itemStack.getType()) {
                        case APPLE:
                            // Add a item to the player inventory
                            view.getPlayer().getInventory().addItem(new ItemStack(Material.APPLE));
                            break;
                        case ARROW:
                            // Display the next page
                            view.nextPage();
                            break;
                    }
                }
            };

            // Do the same for the other pages

           ...

           // Return the array
           return pages;
       }

        // Give the number of pages
        @Override
        public int getPageCount() {
            return 3;
        }
    }
     
    You can then open the menu by instantiating the class.
    Code (Java):
    // The returned object can be used to modify the inventory view. The int is the index of the page to be show
    MenuView view = new TestMenu().open(player, 0);
    Need help or more information? Visit our Discord server (https://discord.gg/Eqake7q)
    JoshiZockt_ likes this.

Recent Updates

  1. DSMAPI v1.3
  2. DSMAPI v1.2

Recent Reviews

  1. mantra
    mantra
    5/5,
    Version: 1.1
    nice ....