Repository navigation
First steps
Menu represents unique for every player, therefore instance of own menu has type Player=>Menu(or MenuFactory, if you use java).
It function will be create new mene or take existing menu from buffer.
val menu:Player=>Menu = Menu.applyOrCreate(
new Menu(_,_, name = "First steps", height = 3)
)In next we try open menu.
menu(player).open()
Now own menu look empty. Just add some items!
Elements that represent item in inventory of menu are called menu-items. Simplest case of menu-item is a Decoration.
import hohserg.inventorymenu.menu.menuitems.ImplicitUtils._
val menu:Player=>Menu = Menu.applyOrCreate(
new Menu(_,_, name = "First steps", height = 3)
+=Decoration(x=4, y=1, new ItemStack(Material.APPLE))
)In fact, третий argument of Decoration is a DataSource. It is common trait, which allow to make any item behavior. But we do import content of ImplicitUtils for have simple way to add static apple item to menu: use ConstSource through implicits. You'll become familiar with DataSource closer in the next articles.
Menu represents unique for every player, therefore instance of own menu has type MenuFactory or Function<Player,Menu>
MenuFactory menu = Menu.applyOrCreate(Menu.apply( "First steps", 3);
// name= height= In next we try open menu
menu.apply(player).open();