-
Notifications
You must be signed in to change notification settings - Fork 2
Filling & Decoration
FlameyosFlow edited this page Sep 16, 2023
·
2 revisions
Filling menus is like eating hard boiled eggs, it's so easy:
// normal Material
exampleMenu.getFiller().fillBorders(Material.WHITE_STAINED_GLASS_PANE);
// legacy
exampleMenu.getFiller().fillBorders(new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7));
// MenuItem legacy
exampleMenu.getFiller().fillBorders(ItemBuilder.of(new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7)).buildItem());
looks familiar? yeah filling in woody has similar syntax to triumph-gui; our base. but there are more methods like the normal Material and normal ItemStack
this is the recommended way to fill menus.
if you want to use your own filler extending MenuFiller, do not fear because since 1.4.6 you can now do it yourself:
exampleMenu.setFiller(new CustomFiller(exampleMenu));
CustomFiller filler = exampleMenu.getFiller(); // error; compilation (explicit type annotation) and runtime (default casting to Filler), if you set the Filler you must use the alternative:
CustomFiller fillerTwo = exampleMenu.getFiller(CustomFiller.class);
// this is still a fast solution because all it does is Class#cast which is a fancy way to just cast normally like in java without the need of class generics
Using PaginatedMenu/SeparatedPagedMenu, #getFiller works but only for the current page.
Instead we use #getPageDecorator as the following example:
exampleMenu.getPageDecorator().fillPageBorders(Material.WHITE_STAINED_GLASS_PANE);
exampleMenu.getPageDecorator().fillPageBorders(new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7));
exampleMenu.getPageDecorator().fillPageBorders(ItemBuilder.of(new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7)).buildItem());
This fills the borders of EVERY page.
Wanna use your custom decorator? no problem! just use:
exampleMenu.setPageDecorator(new CustomDecorator());
CustomDecorator decorator = exampleMenu.getPageDecorator(CustomDecorator.class); // same logic.
That's it for filling and decorating!