Skip to content
forked from pixeldev/gui

A very simple library to facilitate the creation of menus in the SpigotAPI.

License

Notifications You must be signed in to change notification settings

SweetRealms/gui

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnnamedGUI - Menu Creator

Codacy Badge

A small, and very easy to use, library for creating menus at Spigot API!

Maven Dependency

You only need to copy and paste this at your pom.xml, and that will be done!

<repository>
    <id>unnamed-releases</id>
    <url>https://repo.unnamed.team/repository/unnamed-releases/</url>
</repository>
<dependency>
    <groupId>team.unnamed.gui</groupId>
    <artifactId>gui-core</artifactId>
    <version>2.0.0-SNAPSHOT</version>
</dependency>

If you see that the version contains "SNAPSHOT", just use the following repository:

<repository>
    <id>unnamed-snapshots</id>
    <url>https://repo.unnamed.team/repository/unnamed-snapshots/</url>
</repository>

How to use

Remember that you can also visit the example module.

First we need register one listener for all menus. Example:

Bukkit.getPluginManager().registerEvents(new GUIListeners(), plugin);

MenuAPI

Creating menus with our api is too simple, we are going to explain everything a little, so that you can get an idea of the new functionalities and systems that were re-made.

GUIBuilder guiBuilder = GUIBuilder.newBuilder("MenuTest", 3);

This is the basic structure to create a GUIBuilder, which will be used to place all the attributes it can have.

Now let's see how we can add an item to the menu, it's quite simple, let's do it.

guiBuilder
    .addItem(
        ItemClickable.builder(13)
            .setItemStack(new ItemStack(Material.ENDER_PEARL))
            .setAction(event -> {
                System.out.print("Just testing...")

                return true;
            })
            .build()
    );

Other events

There are also 2 more methods to execute an action when opening the inventory, and another to execute an action when closing the inventory, which are:

guiBuilder
    .openEvent(
            event -> {
                Player player = (Player) event.getPlayer();

                player.sendMessage("Opening...!");
                
                return false;
            }
    )
    .closeEvent(
            event -> {
                Player player = (Player) event.getPlayer();

                player.sendMessage("Closing...!");
            }
    );

Finally

With this simple way you can create your menus easily and quickly. Now you will ask yourself, how can I get the inventory I create, it is easy, simply with the build() method that the MenuBuilder has.

Inventory inventory = guiBuilder.build();

About

A very simple library to facilitate the creation of menus in the SpigotAPI.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%