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.
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()
));
}Options that define how the inventory container itself is created.
Sets the initial title of the inventory.
@Override
public void onInit(ViewConfigBuilder config) {
config.title("Write something");
}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.
@Override
public void onInit(ViewConfigBuilder config) {
config.title(Component.text("Write something")
.color(NamedTextColor.BLUE));
}Sets the inventory size.
You may specify:
- Number of lines →
size(4) - Absolute number of slots →
size(45)
@Override
public void onInit(ViewConfigBuilder config) {
config.size(4); // 4 lines (36 slots)
config.size(45); // explicit number of slots
}Automatically sets the inventory to the largest size allowed by its type.
@Override
public void onInit(ViewConfigBuilder config) {
config.maxSize();
}Defines the underlying container type (e.g. ANVIL, HOPPER, DISPENSER…).
@Override
public void onInit(ViewConfigBuilder config) {
config.type(ViewType.SHULKER_BOX);
}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.
Controls how players are allowed to interact with the inventory.
Shortcut to cancel all interactions.
Cancels all click interactions. Prevents items from being moved.
@Override
public void onInit(ViewConfigBuilder config) {
config.cancelOnClick();
}Cancels dragging items across slots.
@Override
public void onInit(ViewConfigBuilder config) {
config.cancelOnDrag();
}Cancels item drops while the inventory is open. To cancel pickups see cancelOnPickup.
@Override
public void onInit(ViewConfigBuilder config) {
config.cancelOnDrop();
}Cancels item pickup while the inventory is open. To cancel drops see cancelOnDrop.
@Override
public void onInit(ViewConfigBuilder config) {
config.cancelOnPickup();
}Adds a delay before any interaction becomes valid. Actions performed before the delay ends are cancelled.
@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.
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.
Adds configuration modifiers — internal advanced options.
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.