Skip to content

Json GUI Format

Neo8 edited this page Apr 11, 2022 · 4 revisions

Json GUI Format

The Json GUI format can be used to create a GUI from a json file. It can also be used together with template Items.

First I will explain a simple json file in detail:

{
  "name": "My GUI",
  "size": 9,
  "items": [
    {
      "id": "first_item",
      "slot": 0,
      "material": "DIRT",
      "name": "First Item",
      "amount": 1,
      "lore": [
        "This is the first item"
      ],
      "enchantments": [
        {
          "name": "ARROW_DAMAGE",
          "level": 1
        }
      ]
    },
    {
      "id": "",
      "slot": 1,
      "material": "STONE",
      "name": "An Item",
      "amount": 1,
      "lore": [
        "This is an item"
      ],
      "enchantments": [],
      "fillTo": 6
    },
    {
      "slot": 7,
      "material": "PLAYER_HEAD",
      "base64": "<base64 head data>"
    },
    {
      "slot": 8,
      "material": "BRICK",
      "modelData": 1002
    }
  ]
}

Let's start with the top-level object:

It contains three fields:

  • name: The name of the GUI.
  • size: The number of slots in the GUI. (needs to be a multiple of 9)
  • items: A list of item objects. The items have not to be sorted by slot, but it is recommended to do so in terms of readability.

All of these fields are required.

Item

An Item object has to contain the following fields:

  • slot: The slot number of the item. This number needs to be between 0 and size - 1.
  • material: The material of the item. It has to be a value of the org.bukkit.Material enum.

All of these fields are required.

Additionally, it can contain the following fields:

  • id: The id of the item. This is used to identify the item in the GUI.
  • name: The display name of the item.
  • amount: The amount of the items in the stack.
  • lore: A list of strings that will be displayed as lore.
  • enchantments: A list of enchantment objects.
  • fillTo: An integer that defines the last slot in a range of slots that will be filled with the item.
  • fill: A array that contains fill objects and/or json ints (the slot ids).
  • base64: A base64 encoded string that will be used as the head of the player head item.
  • modelData: An integer that defines the custom model data of the block state.

All of these fields are optional.

Enchantment

An enchantment object has to contain the following fields:

  • name: The id of the enchantment. This has to be a value of the org.bukkit.enchantments.Enchantment enum.
  • level: The level of the enchantment. (usually between 1 and 255)

All of these fields are required.

Fill

A fill object has to contain the following fields:

  • from: the starting slot.
  • to: the end slot.

All of these fields are required.

Visit the docs

Clone this wiki locally