Skip to content
Daniel V edited this page Dec 23, 2023 · 10 revisions

The New Menu Library

Welcome to the documentation for The New Menu Library! This library provides a powerful and flexible framework for creating graphical user interfaces (GUIs) in Minecraft plugins. Whether you want to create custom menus for Folia, Spigot, Paper or Sponge, this library is for you!

Table of Contents

  1. Overview
  2. Getting Started
  3. Features
  4. Documentation
  5. Contributing
  6. License

Overview

The New Menu Library is designed to simplify the process of creating interactive menus and UIs in Minecraft plugins. It provides a clean and intuitive API for constructing menus, defining icons, and handling player interactions. Whether you're a seasoned developer or new to plugin development, this library aims to enhance the user experience by making menu creation easy and enjoyable.

Getting Started

Installation

To start using The New Menu Library in your project, follow these installation steps:

  1. Add The New Menu Library to your project's dependencies.

    <!-- Replace with the actual version -->
    <dependency>
        <groupId>net.tnemc</groupId>
        <artifactId>menu</artifactId>
        <version>VERSION</version>
        <scope>provided</scope>
    </dependency>
  2. Make sure to include the library in your plugin's dependencies.

Example Usage

Here's a simple example using MenuBuilder to create a basic menu:

import net.tnemc.menu.core.Menu;
import net.tnemc.menu.core.Page;
import net.tnemc.menu.core.icon.Icon;
import net.tnemc.menu.core.builders.MenuBuilder;
import net.tnemc.menu.core.utils.SlotPos;

public class MyPluginMenu {

    public void createMenu() {
        // Creating a simple menu with MenuBuilder
        Menu menu = new MenuBuilder()
                .withName("exampleMenu")
                .withTitle("Example Menu")
                .withRows(3)
                .withPage(
                        new Page(1)
                                .withIcon(
                                        new IconBuilder()
                                                .withItemStack("Item 1", "DIAMOND", 1)
                                                .withSlot(new SlotPos(1, 1))
                                                .build()
                                )
                                .withIcon(
                                        new IconBuilder()
                                                .withItemStack("Item 2", "GOLD_INGOT", 1)
                                                .withSlot(new SlotPos(2, 2))
                                                .build()
                                )
                                .build()
                )
                .build();

        // Register the menu with MenuManager
        MenuManager.instance().addMenu(menu);
    }
}

This example demonstrates creating a simple menu with two pages, each containing icons with different items.

Features

  • Easy menu and icon creation with a builder pattern.
  • Support for various player interactions, such as clicks and chat input.
  • Flexible constraint system for defining conditions and behaviors.
  • Stateful icons for dynamic menu elements.
  • Integration with the MenuManager for easy menu registration and handling.

Documentation

Menu

The Menu class represents a menu in the library. It provides methods for adding pages, handling player interactions, and more.

Icon

The Icon class represents an icon in a menu. Icons can have actions, constraints, and dynamic item providers.

MenuBuilder

The MenuBuilder class is a builder for creating instances of the Menu class. It provides methods for setting menu properties and adding pages.

IconBuilder

The IconBuilder class is a builder for creating instances of the Icon class. It provides methods for setting icon properties, adding actions, and applying constraints.

For detailed documentation and usage examples, refer to the specific class documentation.

Contributing

We welcome contributions from the community! Whether it's bug fixes, feature enhancements, or documentation improvements, feel free to submit pull requests.

  1. Fork the repository.
  2. Create a branch for your changes.
  3. Make your changes and commit them with clear messages.
  4. Push your branch to your fork.
  5. Submit a pull request.

License

This library is licensed under the GNU Affero General Public License (AGPL-3.0). See the LICENSE file for details.

Clone this wiki locally