Skip to content
DumbDergMerciful edited this page Jun 6, 2022 · 4 revisions

Languages: Dutch (Nederlands)

A label can be used for displaying text inside the gui. For each character a head will be placed inside the gui which has the desired character. These heads stem from fonts which you can specify to be used. You can also create your own font if you'd like to.

To create a label you can call it's constructor which also requires a font to be passed in:

Label label = new Label(0, 0, 9, 6, Font.WHITE);

You can then set the text used for display by calling setText:

label.setText("I'm text!")

Keep in mind that there isn't a head for every character and that different fonts may have a different range of usable characters. If a character can't be found the upper/lowercase version of that character will be tried. If that one doesn't exist either, or if there is no upper/lowercase version of the character, a default character will be used.

By default the heads displayed in the inventory don't have any changes made to them. If you want to change the item's appearance, such as changing its name, you can use the setText method with a processor attached, in which you can specify how the item should be transformed.

label.setText("I'm text!", (character, item) -> {
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(Character.toString(character));
    item.setItemMeta(meta);

    return new GuiItem(item);
});

The above code changes the name of each character to be the character it displays.

XML

Everything shown at Panes can be used here as well.

To create a label, you may use the label element name.

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

You will also have to specify the font name which you can do by setting the font attribute:

<label x="0" y="0" length="9" height="6" font="white"/>

Optional attributes

You can specify the text to be shown inside the label by setting the text attribute.

<label x="0" y="0" length="9" height="6" font="white" text="I'm text!"/>
Clone this wiki locally