Advanced Gui - ParzivalExe/guiapi GitHub Wiki

Now, you already created our first Gui and this process actually doesn't change in this chapter. What this Chapter is all about is bring your understanding about Guis onto the same level as your Understanding of Components. So, I will cover all the different Settings you have available to customize your Guis. Let's go!

Implementation

Just as a quick reminder, this is the general Implementation of Guis:

Gui gui = new Gui("Test-Gui");
//manipulate gui here

//add components to gui
gui.addComponent(testComponent);

//open gui
gui.openGui(player);

Now, let's see what we can all manipulate when it comes to Guis.

First you can determine weather the Gui should automatically fill empty places (where there are no Components) with a FillItem (normally glass-panes). You can set this by calling gui.setFillEmptyPlaces(Boolean). As a default, this will fill these empty places with Gray-Glass-Panes but you can also customize the FillItem by calling gui.setFillItem(ItemStack). Fill-Items are by the way implemented so that you can't take other Items and put them into a Gui and while this shouldn't interfere with the functionality of Guis, it is not the intended use of Guis (unless you want a specific location in which to put a Item. Then you should use FreeSpaceComponent with setForceFill(true);).

Next, you can force the Gui to remain at a specific size. You would do this, if you want the Gui to be bigger than the Components actually need it to be because by default forcedSize = Gui.NO_FORCE_SIZE but by calling gui.setForceSize(Integer), you can change that.

To add a Component you can not only use gui.addComponent(Component) but also gui.setComponent(Component, Integer). This is basically the same method, just that with setComponent(...) you can also give the place the Component should be located inside the Gui. This is basically equivalent to component.setPlace(Integer) and then gui.addComponent(component), just compressed.

Events

GuiOpenEvent = called, when a Gui is opened (either by your plugin or by any Component inside the GuiAPI)

GuiCloseEvent = called, when a Gui is closed (either by the Player closing the Gui or the Gui or any Component inside it forcing it closed)

GuiRefreshEvent = called, when the Gui is refreshed, meaning, when the Inventory for the player is refreshed because something has changed (for example: a new component has been added). This Event is also fired when the Component is first build, together with GuiOpenEvent ;)

XML-Attributes

title="{title}" = sets the Title of the Gui (example: title="Test-Gui")

fillEmptyPlaces="true | false" = sets weather empty-places should be filled by the FillItem or not (example: fillEmptyPlaces="true")

fillItem="{FillItem}" = sets the FillItem used when fillEmptyPlaces == true (example: fillItem="160:7")

forcedSize="{Size}" = sets which size the Gui should be. If you want it to automatically resize according to the amount of Components it currently has, then don't use this attribute at all (example: forcedSize="9")

XML-Content

Inside the <Gui></Gui>-Tag there should obviously be all the Components that this Gui contains 😉

Resources

Gui-Code: io.github.parzivalExe.guiApi.Gui
GuiManager-Code: io.github.parzivalExe.guiApi.GuiManager


Now you are pretty good equipped to create amazing Guis with great Components. If you still want to learn more, you could now take a look at how to create Guis from XML or how to create your own Components

⚠️ **GitHub.com Fallback** ⚠️