InvMenuAPI Reloaded

Inventory Menu API Reloaded

An API making an easier task of creating inventory menus. The task of having to hard-code a menu is no longer an obstacle. This API is remastered version of InvMenuAPI it may have some bugs if you get that don't forget to pm me or say it on Comment :) 

For Servers Owners

Simply place it in like a normal plugin. Note that it will not do anything on it's own. No configurations are required to be modified, there are any permissions, simply drop and start.

For Developers

Be sure to add the plugin to your plugin.yml!

A quick tutorial:

//Create a new menu object. This will hold all the buttons and their functions that you set to the menu.
//The first parameter is the menu name. Optionally, you can have a second parameter in that constructor. By default, the size is 1. (This results to size * 9.)
Menu menu = new Menu("Name");

//Now, create a new MenuButton object. I'll be using a Function button, which does nothing but do what it's told to when clicked on.
//You'll notice there's a constructor parameter there requesting an Option object. An Option is what the buttons use as display data. First parameter, an ItemStack, is what the player sees. Note that the amount will always be 1 unless it's a Scroll button. Second parameter, is the name of the item displayed. You can use color codes as well. And the last parameter, is the lore. You can use \\n here to skip to a new line. You do not require a lore, and you can just set this to null.
FunctionMenuButton fb = new FunctionMenuButton(new Option(new ItemStack(Material.DIAMOND, 1), "name", "lore");

/*Now, it's like setting a runnable object and giving it to the scheduler. Simply put what you want the button to execute in a new MenuTask class's run method, and set it to the button. You can utilize 4 parameters that are given to you here.
inst - The instance where it activated.
button - The activated button's object.
who - Who activated the button?
isDenied - Was the button denied activation?*/
fb.setMenuTask(new MenuTask() {
    public void run(MenuInstance inst, MenuButton button, Player who, boolean isDenied) {
        //What to do when you click this button?
    }
});

//And then finally, you set the button to a slot in the menu. As of now, we have a menu of size 1. Meaning we have to pick a slot between 0, and ((size * 9) - 1). In this case, that's 8. I chose to put it at the very first slot.
menu.setButton(0, fb);

//To show the menu, tell the instance manager to create a new instance targetting your menu and the player who should see it.
Player player = Bukkit.getServer().getPlayer("LingerMC");
MenuInstanceManager.newInstance(menu, player);

Donation


Comments

  • To post a comment, please or register a new account.
Posts Quoted:
Reply
Clear All Quotes

About This Project

Categories

Members

Recent Files