Skip to content
stefvanschie edited this page Jan 14, 2020 · 17 revisions

Languages: Dutch (Nederlands)

As partially explained on the IF page, panes are subsections of a GUI which displays its items in a certain way. There can be any amount of panes inside a GUI.

There are currently four built-in panes:

And five built-in UI elements:

UI elements are also considered panes as far as the framework is concerned.

However, you can create your own custom panes, which is explained on here.

Every pane can be indexed in three categories:

  • Panes that take items
  • Panes that take panes
  • Panes that don't take anything

Panes that take items

A pane that takes items will render these items based on the properties of the pane. This is different for all panes.

Panes that take panes

A pane that takes panes will render each pane relative to its own position. You can nest these panes as far as you want.

Panes that don't take anything

These panes work by themselves and are all UI elements. They use a built-in style for display and don't require any items or other panes for them to function.


Every pane has some properties. An example of this is the start location. The start location has an x and a y value. This is the distance from the top-left corner of the GUI to the pane's location. A location of (1,1) means that the pane is positioned one to the right and one down from the top-left corner. Each pane also has a length and a height. The length is the amount of slots the pane occupies on the horizontal axis. The height is the amount of slots the pane occupies on the vertical axis.

For every pane you can also set it to visible/invisible, where when it is invisible, it will not render. You can also set a click property which will be called whenever someone clicks on the pane.

Panes may overlap (parts) of other panes. With this you can, for example, create backgrounds for you GUIs. To ensure panes are rendered like you want, each pane has a priority assigned to it. Panes with a low priority will render first and panes with a high priority will render last.

There are six priorities, based on the EventPriority from Bukkit's system:

  • Lowest
  • Low
  • Normal
  • High
  • Highest
  • Monitor Monitor should not be used in production and only to test things.

To create a pane, simply call the constructor of the pane with the necessary parameters. As an example we'll be using StaticPane, but you can substitute this for any pane.

StaticPane pane = new StaticPane(0, 0, 9, 6, Pane.Priority.HIGH);

This will create a pane which starts in the top-left corner, has a length of nine and a height of six and a high priority. The priority parameter is optional.

You can set the visibility of the pane, by calling setVisible.

pane.setVisible(false); //sets the pane to invisible

And you can set what should happen when someone clicks

pane.setOnClick(event -> event.getWhoClicked().sendMessage("You clicked!"));

And you can change the priority

pane.setPriority(Pane.Priority.LOW); //sets the priority to low

Any changes done on the pane will only be applied after you call update on the underlying GUI.

To add the pane to the GUI, call addPane on the GUI.

gui.addPane(pane);

Panes can extend beyond the rows provided in the inventory into the bottom-half of the inventory, which is the player's inventory. Simply imagine that the bottom four rows were part of your inventory; they behave exactly like every other row in the GUI. When you move a pane into the bottom-half of the inventory, the inventory of the player will be cached and cleared. Unlike normally, where the player could still see his inventory when the GUI is open, it will now be empty to make space for the panes at the bottom. The inventory of the player will be restored when they close the inventory, or when all panes that (partially) occupy the bottom-half of the GUI are gone and the GUI has been updated. The reason for this design decision is as follows: We still want the players to see their items under normal circumstances. This can be useful for, for example, trading GUIs where you explicitly have to put items from your inventory into the top part. This functionality is now still achievable. The reason all items are cleared when a part of the bottom-half of the GUI is occupied, is because it is too difficult to determine how the other items should behave in regards to other panes, in terms of overriding, resetting, moving, dragging etc. This is a solution which wil satisfy the majority of users. People who want their users to still have their items can still do so, while people who don't find this a necessity can make use of the additional four rows at the bottom.

XML

Again, we'll be using StaticPane as an example, but you can switch these out for any pane. To add a pane, add the pane element to the GUI element.

<staticpane/>

You are required to assign the length and height attributes to the pane in order for it to work, like so

<staticpane length="9" height="6"/>

Optional attributes

x and y attributes

The x and y attributes denote where the pane should be placed. Some panes, such as the masonry pane decide this themselves and will override them. If these attributes are not specified, the pane will take a default of 0 for both coordinates.

<staticpane x="0" y="0" length="9" height="6"/>

field attribute

With field you can specify a field name in your code which should be initialized with the pane once it is loading.

In the XML file:

<staticpane length="9" height="6" field="pane"/>

In the code:

StaticPane pane; //this field will get initialized with the pane

onClick attribute

You can also specify an onClick attribute. Here you can specify the method name of the method that will be called once someone has clicked on the pane.

In the XML file:

<staticpane length="9" height= "6" onClick="paneClick"/>

In the code:

public void paneClick(InventoryClickEvent event) {}

The method specified needs to be public. The InventoryClickEvent parameter is optional. You may set any return type you want, but the result will be ignored in all cases.

populate attribute

You can specify a populate attribute. Here you specify the method name of the method that will take over the population of the pane when loading. Any child elements appended to the pane element will be ignored when this attribute is set.

In the XML file:

<staticpane length="9" height="6" populate="populatePane"/>

In the code:

public void populatePane(StaticPane paane) {}

You may set any return type you want, but the result will be ignored in all cases.

priority attribute

You can set the priority of the pane with the priority attribute. The priority value has to be in all uppercase. By default this is NORMAL.

In the XML file:

<staticpane length="9" height="6" priority="LOW"/>

visible attribute

You can set the pane to visible/invisible by adding this attribute. The default value is true.

In the XML file:

<staticpane length="9" height="6" visible="false"/>
Clone this wiki locally