Inventory configuration

This page describes how to configure an inventory in YAML.

CraftVentory enables developers to create fully customizable inventories from configuration files. YAML is the default file format supported by the library for this purpose.

How to configure an inventory?

Each inventory must be defined in a separate configuration file. It is represented by a set of properties which are listed below:

Id

# An id that uniquely identify the inventory.
id: "inventory-id"

Type

# The type of view that will be used for the inventory.
# Available types:
# - CHEST_9x1 (1 row)
# - CHEST_9x2 (2 rows)
# - CHEST_9x3 (3 rows)
# - CHEST_9x4 (4 rows)
# - CHEST_9x5 (5 rows)
# - CHEST_9x6 (6 rows)
# - DROPPER
# - HOPPER
type: "CHEST_9x6"

Title

# The title of the inventory.
# The following placeholders are available by default:
# - %player_name% : The name of the player who is viewing the inventory.
# - %inventory_type% : The name of the inventory type.
# - %inventory_size% : The number of slots of the inventory.
title: "title"

Pattern

# The pattern of the inventory used to set items.
# A pattern must have the exact same number of rows and columns than the inventory.
# Items are represented by their associated symbol in the pattern.
# The symbol '&' must be used to represent an empty slot.
pattern:
  - "&&&&&&&&&"
  - "&1111111&"
  - "&1111111&"
  - "&1111111&"
  - "&P&&&&&N&"
  - "&&&&&&&&C"

Content

# The content of the inventory.
# You can add as many items as you want.
content:
  # Each item is described by a section.
  close:
    # The item to display.
    # You can use the default YAML representation supported by Bukkit to define an ItemStack
    # or the custom one provided by the library.
    item:
      type: BARRIER
    # Symbol used in the pattern to place the item in the inventory.
    # You must ensure that two items do not have the same symbol.
    symbol: "C"
    # Actions executed when a player clicks on the item.
    actions:
      # Each action is described by a section.
      close:
        # The type of the action.
        type: "CLOSE"

Paginations

# Paginations used in the inventory.
# An inventory can contain several paginations.
paginations:
  # Each pagination is described by a section.
  pagination-1:
    # The internal id of the pagination.
    # It must be unique for the inventory, as an inventory can contain several paginations.
    id: "pagination-1"
    # The symbol used in the pattern to place the pagination items in the inventory.
    symbol: "1"
    # The item used to represent each value of the pagination.
    # The Bukkit ItemStack representation must be used.
    pagination-item:
      item:
        type: DIAMOND
    # Item to open the previous page.
    # It is configured like items in the 'content' section.
    previous-page-item:
      item:
        type: ARROW
        # The following placeholders are available by default and can be used in name and lore:
        # %previous_page%: Previous page number.
        # %current_page%: Current page number.
        # %total_pages%: Total number of pages.
        name: "Page %previous_page%"
      symbol: "P"
    # Item to open the next page.
    # It is configured like items in the 'content' section.
    next-page-item:
      item:
        type: ARROW
        # The following placeholders are available by default and can be used in name and lore:
        # %next_page%: Next page number.
        # %current_page%: Current page number.
        # %total_pages%: Total number of pages.
        name: "Page %next_page%"
      symbol: "N"

Item configuration

An inventory is composed of a set of items. CraftVentory supports two ways to configure items in configuration files:

  • Using the default Bukkit YAML representation that supports complex ItemStack configurations

  • Using the custom representation that only supports simple item configurations

Custom item configuration

An item is represented by a set of required properties. All these properties are listed below, with comments on what is configurable and supported.

# Item configuration section.
item:
  # Type of the item. All the types can be found in the following link:
  # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html
  type: DIAMOND
  # Display name of the item.
  # Color codes using the character '&' and hexadecimal colors prefixed by '#' are supported
  name: ""
  # Lore of the item.
  # Color codes using the character '&' and hexadecimal colors prefixed by '#' are supported
  lore:
  - "line 1"
  - "line 2"
  - "line 3"
  # Set true if you want a glow effect on the item or else set false.
  enchant: true

Last updated