Folder - ParzivalExe/guiapi GitHub Wiki
From Overview
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.
To create a Folder is a bit more complicated than other Components because you need to create the Gui that should be opened after the Folder is clicked before creating the Folder itself:
//Create InnerGui
Gui innerGui = new Gui("Treasure-Chest");
//Create Component for InnerGui
ComponentMeta treasureMeta = new ComponentMeta("Treasure", new ItemStack(Material.GOLD_INGOT, 64));
ArrayList<InvItemStack> items = new ArrayList<InvItemStack>();
items.add(new InvItemStack(Material.GOLD_INGOT, 64, 4));
GetItemComponent treasureComponent = new GetItemComponent(treasureMeta, items);
innerGui.addComponent(treasureComponent);
//create folder
ComponentMeta folderMeta = new ComponentMeta("Treasure-Chest", new ItemStack(Material.CHEST));
//manipulate folderMeta here
Folder folder = new Folder(folderMeta, innerGui);
gui.addComponent(folder);
As you can see, we first need to create the Gui that will later be "inside" the Folder
. From there it is actually not that complicated.
You can create as many Folders in one Gui as you want. You can also create as many Folders inside the Guis of Folders as you want, pretty much like dreams within a dream in Inception 😂
ComponentClickedEvent
= fired, when the Folder (or any other Component) is clicked
FolderOpenedEvent
= fired, when the Folder is clicked and the new Gui is opened
GuiCloseEvent
= is of course fired for the Gui the Folder was inside when it is clicked (because the old Gui is closed and the new one is opened
GuiOpenEvent
= is of course fired for the Gui inside the Folder as it is opened after the player clicked on the Folder
title="{Component-Title}"
= sets the Title of this Component (example: title="Hello World"
)
look="{AMOUNT}xID:{DATA}{[DURABILITY]}"
= sets the Look of this Component (example: look="3x322:1"
or look="3xGOLDEN_APPLE"
)
description="[{line1}, {line2}...]"
= sets the description of this Component (example: description="[This is a Description, with a \,]"
)
place="{PLACE}"
= sets the place this Component should be placed at in the Gui (example: place="4"
)
Inside the Tag <Folder>{Content}</Folder>
the new Gui must be created. Don't forget, that you also have to either use the full ClassName
of Gui
(with package) or create an Include
-Tag in the Library
-Tag even though this wasn't necessary for the outer Gui. Example:
<io.github.parzivalExe.guiApi.components.Folder title="Treasure-Chest" look="54">
<io.github.parzivalExe.guiApi.Gui title="Treasure-Chest">
<io.github.parzivalExe.guiApi.components.GetItemComponent
title="Treasure" look="64x266" items="[4=64x266]"/>
</io.github.parzivalExe.guiApi.Gui>
</io.github.parzivalExe.guiApi.components.Folder>
But, of course there is a second option. You can also open an Gui which is defined in a completely different XML-File with the Class ExternalGui. This class excepts 3 attributes:
-
path="{path}"
with which you define where the GuiFile is stored (for examplepath="exampleGui/InnerGui"
for a fileInnerGui.mgui
inside the Folder exampleGui -
fileType="{file_suffix}"
which describes the File-Ending this Gui-File uses (default is mgui) (for examplefileType="xml"
for a file which ends with.xml
) -
pathOrigin="PROJECT_ORIGIN | SERVER_ORIGIN | PC_ORIGIN"
which describes where the origins of your path lie.ProjectOrigin
means, that they lie at the same point where your project itself lies (meaning inside your .jar-file),ServerOrigin
at the point your Server the plugin is used from lies andPcOrigin
the point your PCs Origin (in Java described by a"/"
).
So, if we wanted to open your TestGui as created in Guis from XML, we would have to create the following Code
<io.github.parzivalExe.guiApi.components.Folder title="Folder" look="54">
<io.github.parzivalExe.guiApi.ExternalGui path="InProjectGui" pathOrigin="PROJECT_ORIGIN"/>
</io.github.parzivalExe.guiApi.components.Folder>
Component-Code: io.github.parzivalExe.guiApi.components.Folder
ExternalGui-Code: io.github.parzivalExe.guiApi.ExternalGui
Great, now you know how to implement a Folder with a few lines. Next Component on the List is Settings