Skip to content

A simplistic Bukkit GUI / Menu API using the InventoryHolder interface.

License

Notifications You must be signed in to change notification settings

marvintheskid/menu

Repository files navigation

menu

A simple Bukkit GUI / Menu API using the InventoryHolder interface. TODO: rewrite / cleanup the readme

Usage

Basics

Registering the ButtonInteractionListener is required, otherwise the API will malfunction.

Bukkit.getPluginManager().registerEvents(new ButtonInteractionListener(), instance);

Creating your first menu

You need to create an object which extends Menu first:

public class DummyMenu extends Menu {
    @Override
    @NotNull 
    public Map<Integer, Button> getButtons(@NotNull Player player) {
        ...
    }

    @Override
    @NotNull
    public String getMenuTitle(@NotNull Player player) {
        ...
    }

    @Override
    public int getSize(@NotNull Player player) {
        ...
    }
}

You should create a new instance of the desired menu every time, because most of the time we only want 1 viewer / menu. After creating the menu, calling the Menu#openMenu(Player) method will show the menu for the given player.

    ...
    Player player = ...;
    new DummyMenu().openMenu(player);
    ...

Creating buttons

Creating a Button is simple:

public class DummyButton implements Button {
    @Override
    @NotNull
    public ItemStack getItem() {
        ...
    }

    @Override
    @NotNull
    public ButtonEvent getEvent() {
        ...
    }

    @Override
    public boolean isStrict() {
        ...
    }

The Button#getEvent() and the Button#isStrict() method have a default value, therefore you can use the Button interface as a functional interface:

Button btn = () -> ...;

About

A simplistic Bukkit GUI / Menu API using the InventoryHolder interface.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages