1. Getting Started

We will see here how to create your first inventory using the SmartInvs API.

SmartInventory Builder

First, get your SmartInventory.Builder item using the method SmartInventory.builder(), then build your inventory with the different parameters:

When all of your parameters are defined, use the method build() to create your SmartInventory. We recommend to put the inventory in a constant in order to load it only once.

Example

public static final SmartInventory INVENTORY = SmartInventory.builder()
        .id("customInventory")
        .provider(new MyProvider())
        .size(4, 9)
        .title(ChatColor.RED + "Unclosable inventory!")
        .closeable(false)
        .build();

Then, to open the inventory:

MyInventory.INVENTORY.open(player);

Context-dependent Example

public static SmartInventory getInventory(Player player) {
        return SmartInventory.builder()
                .provider(new MyProvider(player))
                .size(3, 9)
                .title("Inventory of " + player.getName())
                .build();
}

Then:

MyInventory.getInventory(targetPlayer).open(player);

Last updated