GUIs

Creating a GUI

You can create a Gui using the builder:

Gui gui = Gui.chest()
        .title(Component.text("A GUI"))
        .rows(3)
        .build();

A dropper or hopper can be created using their builders:

Gui gui = Gui.dropper()
        .title(Component.text("A GUI"))
        .build();        
Gui gui = Gui.hopper()
        .title(Component.text("A GUI"))
        .build();

Adding Buttons

A Button can be added by chaining a button(Slot, Button) call:

Air is always represented by a null Button.

Gui gui = Gui.chest()
        .button(Slot.of(1, 4), Button.of(ItemType.STONE))
        .build();

The method may also be called on a built Gui:

gui.button(Slot.of(1, 4), Button.of(ItemType.STONE));

For more information relating to buttons, see Buttons.

Borders and Filling

border(Button) can be used to fill a border:

Gui gui = Gui.chest()
        .border(Button.of(ItemType.GRAY_STAINED_GLASS_PANE)) // all sides
        .build();

Gui gui = Gui.chest()
        .border(Button.of(ItemType.GRAY_STAINED_GLASS_PANE), Border.BOTTOM)
        .build();

To fill the entire GUI, fill(Button) can be used:

Gui gui = Gui.chest()
        .fill(Button.of(ItemType.GRAY_STAINED_GLASS_PANE))
        .build();

Opening The GUI

To open a Gui, you need to first create a PaperVision:

PaperVision vision = PaperVision.create(plugin);

Then you can open it:

Player player = ...;
vision.open(player, gui);

Last updated