Create furnace menu

Methods

onOpenMenu [OVERRIDE]

This event is called when player open the menu

protected abstract void onOpenMenu(Player player);
onCloseMenu [OVERRIDE]

This event is called when player close the menu

protected abstract void onCloseMenu(Player player);
refreshPage

I'm inviting you to see the same doc on refreshPage in this part.

Create your first menu

public class MySimpleMenu extends FurnaceMenu {
    public MySimpleMenu(JavaPlugin plugin) {
        super(plugin, "My Menu Title");
    }
    
    @Override
    protected void onCloseMenu(Player player) {
        //event when user open your menu
    }
    
    @Override
    protected void onOpenMenu(Player player) {
        //event when user close your menu
    }
}

Now you have your menu, let's add it to menu system.

public MyPlugin extends JavaPlugin {
    GuiManager guiManager;
    
    public MyPlugin() {
    
    }
    
    private void initMyMenus() {
        MySimpleMenu simpleMenu = new MySimpleMenu(this);
        guiManager.registerMenus(simpleMenu, "MySimpleMenu");
    }
}

To init GuiManager, please refer to this documentation :

Init your plugin

Add items in menu

Type of item place in furnace :

  • SMELTING

  • FUEL

  • RESULT

public class MySimpleMenu extends ChestMenu {
    public MySimpleMenu(JavaPlugin plugin) {
        ...
        GuiItem item = new GuiItem(...);
        // add item in smelting pace
        addItem(item, FurnacePlace.SMELTING);
    }
    
    @Override
    protected void onOpenMenu(Player player) {
        GuiItem otherItem = new GuiItem(...);
        // place only for the player otherItem in fuel
        addItem(player, otherItem, FurnacePlace.FUEL);
    }
}

Last updated