Skip to content

Menu API supporting dynamic changes, buttons as well as paginated menus. Forked from NV6's Menu API

Notifications You must be signed in to change notification settings

therealdamt/MenuAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

MenuAPI

A fork of NV6's Menu API

Features

  • Buttons that are easily controlled
  • Updating menus without existing
  • Paginated Menus
  • Different Menu Types
  • Optimized Code

How to use

@Override
public void onEnable() {
    new MenuHandler(this);
}
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
       if (!(sender instanceof Player) {
            sender.sendMessage(ChatColor.RED  + "You must be a player to run this command!"
            return;
        }
        
        Player player = (Player) sender;
        new Menu(player).updateMenu();
}

Example

public class ExampleMenu extends PaginatedMenu {

    public ExampleMenu(Player player, String title, int size) {
        super(player, title, size);
    }

    @Override
    public Map<Integer, Button> getButtons() {
        final Map<Integer, Button> buttonMap = new HashMap<>();

        int i = 0;

        for (AuctionItem auctionItem : AuctionPlugin.getInstance().getAuctionHandler().getAuctionItems()) {
            buttonMap.put(i, new Button(auctionItem.getStack())
                    .setClickAction(action -> {
                        auctionItem.remove();
                        getPlayer().sendMessage(CC.translate("&7Removed a crazy auction item!"));
                    }));
        }

        return buttonMap;
    }

}

As you guys can see, I don't need to get the AuctionItem by stack or anything, the event will already be bound to it, and it would completely work as needed 🙂

Credits

This is a menu api of which was forked from the menu api created by NV6. This version of the API adds a lot of features, including updating the menu without existing the player out of it [i.e the contents of the menu will change without actaully the player leaving or closing the gui at all], closing event. As well as more features.

Original Creator - NV6

Contacts

  • Discrord - bingbongwaseem

About

Menu API supporting dynamic changes, buttons as well as paginated menus. Forked from NV6's Menu API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages