[For Devs] GUI API. Easily create GUIs (MMenu) icon

[For Devs] GUI API. Easily create GUIs (MMenu) -----

This API helps developers to create graphical user interfaces.



MMenu
With this API developers can easily create Graphical User Interfaces (GUIs). This resource is open source: mplugins.org/code/MMenu


Get Started

  1. Register API with MMenu.register(this); in your onEnable-Method.
  2. Create a class for your GUI and let it extend from org.mplugins.mmenu.MMenu. You can set the GUI title and amount of rows inside the constructor.
  3. Inside setContents() you can place items into the GUI. The inventory is accessable via inventory.
  4. Inside handleClickAction() you can control what certain clicks should do.
  5. You can open the GUI with the following code:
    Code (Java):
    TestMenu gui = new TestMenu ( ) ;

    gui. open (player ) ;

Example Code

Code (Java):
import org.bukkit.Material ;
import org.bukkit.entity.Player ;
import org.bukkit.event.inventory.InventoryClickEvent ;
import org.bukkit.inventory.ItemStack ;
import org.bukkit.inventory.meta.ItemMeta ;
import org.mplugins.mmenu.menu.Menu ;

import java.util.Collections ;

public class TestMenu extends Menu
{
    public TestMenu ( )
    {
        super ( "Title", 3 ) ; // Set title and amount of rows
    }

    @Override
    public void setContents ( )
    {
        ItemStack item = new ItemStack (Material. PAPER ) ;
        ItemMeta meta = item. getItemMeta ( ) ;
        meta. setDisplayName ( "§9§lDemo Item" ) ;
        meta. setLore ( Collections. singletonList ( "§fClick for demo action! :)" ) ) ;
        item. setItemMeta (meta ) ;

        // Place items in the GUI
        inventory. setItem ( 13, item ) ;
    }

    @Override
    public void handleClickAction (InventoryClickEvent inventoryClickEvent )
    {
        // This method gets called whenever a player clicks on an item inside the gui
        ItemStack item = inventoryClickEvent. getCurrentItem ( ) ;
        Player player = (Player ) inventoryClickEvent. getWhoClicked ( ) ;

        if (item. getType ( ) == Material. PAPER )
            player. sendMessage ( "§7[§cRESPONSE§7] §fGUI works!! Demo text." ) ;
    }
}
 

Speedcoding

Resource Information
Author:
----------
Total Downloads: 98
First Release: Aug 8, 2021
Last Update: Aug 8, 2021
Category: ---------------
All-Time Rating:
1 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings