Component Overview - ParzivalExe/guiapi GitHub Wiki
In this chapter I will give an overview of all the components included with the GuiAPI. I will however only give information on how these will work in practise and not how to implement them in code. For this you can either try to create them on your own (most of them are pretty self-explanatory and follow similar implementations) or read the tutorial for the specific Component in which I go over implementation as well as all of the more advanced features of the components.
StaticComponent
StaticComponents are the easiest as they have no features. They are simply a component that, when clicked, doesn't do anything, meaning that it instantly cancels the interaction.
Therefore StaticComponents can be used either for decorations like creating a border around important components with different colored glass or for transferring information to the player by it's Title
and Description
.
There is however also a different use for StaticComponents you first wouldn't think of as you can add a clickAction
with usage of a ClickListener and use a StaticComponent as an easy Button without messing around with Bukkit-Events as using no Bukkit-Events is actually easier in many instances.
FreeSpaceComponent
Again, the name already describes this component pretty well as a FreeSpaceComponent is used to prevent Components from using the place it is used for.
The result will be a place
in the Gui that will not be populated by any Components. Threw a specific Field you can also specify if this position should be filled by the given FillItem
of the Gui or if it should be completely free, even if the Gui should normally would fill empty places with FillItem
s
EventComponent
An EventComponent is basically the equivalent to a Button in any normal Gui you would find for normal programs. When clicked, it will call the EventComponentClickedEvent
and close the gui (except if you specified it should not close the Gui when clicked through a field in which case it will act like a StaticComponent and simply stay at it's given place)
MessageComponent
The MessageComponent simply shows the message
it holds to the player who clicked it inside his Ingame-Chat. After it was clicked it will also close the Gui since many players would otherwise probably miss the message send to them through the Ingame-Chat.
TeleportComponent
The TeleportComponent teleports the Player to a specified Location of type TeleportLocation
which is also given by the GuiAPI. This custom Location-Object supports to not only a static Location but also Locations relative to the player who clicked on the Component and even a mix of both. When clicked, this Component also closes the Gui.
GetItemComponent
As most components GetItemComponent also gives away it's function in it's name. With this Component you can give the player who clicked one or more items into his Inventory. You can specify where exactly this item should be located in his Inventory and if these items should also be added and override if there is already another item present in this slot already.
Folder
A folder is a Component that, when clicked, closes the currently opened Gui
and opens a new one that must be defined inside this Component.
Settings
The Settings
-Component is a bit more complicated. It has different SettingOption
s. Every SettingOption
has it's own ComponentMeta
. If the Settings
-Component is now clicked, it will cycle through this SettingOption
-List. Every click therefore the Look
, Title
and Description
of this Component will change.
It also fires an Event every time the SettingOption
changes giving your plugin an option to respond to this accordingly.
Another way to use this Component is by getting the current SettingOption
when the Gui
is closed and make the necessary changes.
YesNoSetting
As you can see from the word Setting being in this Component as well, YesNoSetting is based on the Settings
-Component. In fact, it actually has the same logic but now only supports two SettingOption
s, the YesSettingOption
and the NoSettingOption
and is therefore used for Settings where only two states are possible (These states must not necessarily be "Yes" and "No" as you can change look
and title
for these two SettingOptions as well).
AdditionalOptionsComponent
This may be the most advanced Component implemented into GuiAPI right now but DON'T WORRY, it is still pretty simple to use.
The AdditionOptionsComponent
contains a List of Component
s that will be displayed when you click this Component in one of two ways: Inside a new Gui
/Inventory
or directly under the AdditionOptionsComponent
inside one or more new Lines that are created.
When the Component
s are inserted in the line under this Component, all the other Component
s that might have been in this line before are pushed down one line. In this case you can then click the AdditionalOptionsComponent
again and the additional Component
s will be removed again and the Gui
should return to it's original state.
YesNoOption
Like the YesNoSetting
, this is also a dumped-down version, this time of the AdditionalOptionsComponent
. Here, there are only two additional options so that you can for example use this as Yes and No or any other two options you might come up with because the ComponentMeta
of these two options is changeable here too, as you might have guessed already.
Of course you can also choose between NewInventory
and UnderInventory
in this Component.
Even more Options...
Now, this is already quite a collection of Components, but it doesn't end there. Of course whenever a new version of GuiAPI is released, there might be new Components waiting for you to use.
If you need a specific function right now you can either use StaticComponent
together with the ClickAction
and create your own actions when a Component is clicked or even create your own Components.
Now, go on and read all about how to use these Components by simply clicking on their Headlines.