Giter VIP home page Giter VIP logo

menuapi's Introduction

Menu API

This is a simplistic Menu API made for the Spigot API, with built-in pagination, actions, and more.

Note

  • Menu fillers are currently in development, and issues may occur.

Usage

Registering the menu handler:

You have to register the MenuHandler object somewhere, preferably inside of the main class, for example:

@Override
public void onEnable() {
    new MenuHandler(this);
    // your code
}

Creating a new menu

You have to make a class extending the Menu class (or PaginatedMenu), or make a new anonymous class, for example:

Anonymous Class

import io.github.nosequel.menu.buttons.Button;
import io.github.nosequel.menu.pagination.PaginatedMenu;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import java.util.List;

class ExampleClass {

    public ExampleClass(Player player) {
        final PaginatedMenu menu = new PaginatedMenu(player, "example", 18) {
            @Override
            public void tick() {
                for (int i = 0; i < 27; i++) {
                    this.buttons[i] = new Button(Material.ENDER_PEARL)
                            .setDisplayName("&aSlot: " + i)
                            .setClickAction(event -> event.setCancelled(true));
                }
            }
        };

        menu.updateMenu();
    }
}

Extending Menu

import io.github.nosequel.menu.buttons.Button;
import io.github.nosequel.menu.pagination.PaginatedMenu;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import java.util.List;

public class ExampleMenu extends PaginatedMenu {

    public ExampleMenu(Player player) {
        super(player, "example", 18, 4);
    }

    @Override
    public void tick() {
        for(int i = 0; i < 27; i++) {
            this.buttons[i] = new Button(Material.ENDER_PEARL)
                    .setDisplayName("&aSlot: " + i)
                    .setClickAction(event -> event.setCancelled(true));
        }
    }
}
new ExampleMenu(player).updateMenu();

Configuring Menu Pagination

PaginatedMenu#setNavigationPosition(NavigationPosition)
PaginatedMenu#setNextPageButton(Button)
PaginatedMenu#setPreviousPageButton(Button)

Configuring Menu Filling

Menu#addFiller(FillingType)

menuapi's People

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.