Configuration Guide - devnatan/inventory-framework GitHub Wiki

This guide covers all configuration options available. Use these options inside onInit(...) to define how a view behaves, looks, and interacts with players.

Per-Player Configuration

If you need to adjust the configuration per player—for example, changing the title only for a specific player—you can use modifyConfig inside onOpen. All configuration options available in onInit are also supported on a per-player basis within onOpen.

@Override
public void onOpen(OpenContext open) {
    open.modifyConfig().title(String.format(
        "Hi, %s", open.getPlayer().getName()
    ));
}

Inventory Appearance & Structure

Options that define how the inventory container itself is created.

title(String label)

Sets the initial title of the inventory.

Preview
@Override
public void onInit(ViewConfigBuilder config) {
    config.title("Write something");
}

title(Component label)

Sets the initial title using an Adventure Text Component.

Note

To use Adventure components as titles, make sure the inventory-framework-platform-paper module is on your classpath. See the Installation guide for details.

Preview
@Override
public void onInit(ViewConfigBuilder config) {
    config.title(Component.text("Write something")
                    .color(NamedTextColor.BLUE));
}

size(int slots) / size(int lines)

Sets the inventory size.

You may specify:

  • Number of lines → size(4)
  • Absolute number of slots → size(45)
Preview
@Override
public void onInit(ViewConfigBuilder config) {
    config.size(4);   // 4 lines (36 slots)
    config.size(45);  // explicit number of slots
}

maxSize()

Automatically sets the inventory to the largest size allowed by its type.

Preview
@Override
public void onInit(ViewConfigBuilder config) {
    config.maxSize();
}




type(me.devnatan.inventoryframework.ViewType type)

Defines the underlying container type (e.g. ANVIL, HOPPER, DISPENSER…).

Preview
@Override
public void onInit(ViewConfigBuilder config) {
    config.type(ViewType.SHULKER_BOX);
}

layout(String... pattern)

Defines the structural layout of the inventory.
Each character in the array represents a slot, and each string corresponds to a row in the layout.

See Layouts for more details.

Player Interaction Rules

Controls how players are allowed to interact with the inventory.

cancelAllInteractions()

Shortcut to cancel all interactions.

cancelOnClick()

Cancels all click interactions. Prevents items from being moved.

Preview
@Override
public void onInit(ViewConfigBuilder config) {
    config.cancelOnClick();
}

cancelOnDrag()

Cancels dragging items across slots.

Preview
@Override
public void onInit(ViewConfigBuilder config) {
    config.cancelOnDrag();
}

cancelOnDrop()

Cancels item drops while the inventory is open. To cancel pickups see cancelOnPickup.

@Override
public void onInit(ViewConfigBuilder config) {
    config.cancelOnDrop();
}

cancelOnPickup()

Cancels item pickup while the inventory is open. To cancel drops see cancelOnDrop.

@Override
public void onInit(ViewConfigBuilder config) {
    config.cancelOnPickup();
}

interactionDelay(Duration delay) (experimental)

Adds a delay before any interaction becomes valid. Actions performed before the delay ends are cancelled.

Preview
@Override
public void onInit(ViewConfigBuilder config) {
    config.interactionDelay(Duration.ofSeconds(3));
}

In the example video, the player clicks multiple times, but all interactions are delayed by 3 seconds.

Update & Lifecycle Behavior

scheduleUpdate(long intervalInTicks) / scheduleUpdate(Duration interval)

Schedules periodic updates for the inventory. Triggers onUpdate(Context) automatically.

@Override
public void onInit(ViewConfigBuilder config) {
    config.scheduleUpdate(20L); // every 1 second
    config.scheduleUpdate(Duration.ofSeconds(5)); // every 5 seconds
}

See Scheduled Updates for more details.

Advanced Configuration

with(...) / use(...)

Adds configuration modifiers — internal advanced options.

transitiveInitialData(boolean isTransitive)

Controls whether initial data is passed when navigating between inventory.

  • false (default): data from View A does not transfer to View B
  • true: data from A is carried over to B
@Override
public void onInit(ViewConfigBuilder config) {
    config.transitiveInitialData(true);
}

See Navigating Between Views for more details.

⚠️ **GitHub.com Fallback** ⚠️