SmartInvs icon indicating copy to clipboard operation
SmartInvs copied to clipboard

Add arguments while opening inventory

Open Speedy11CZ opened this issue 4 years ago • 1 comments

Hi. Is possible to add args while opening inventory? If not, can be this feature added? Thanks.

Speedy11CZ avatar Feb 24 '21 13:02 Speedy11CZ

Hi, you can achieve this by adding fields to your InventoryProvider and passing them in the constructor, for example:

public static SmartInventory getInventory(Player player) {
        return SmartInventory.builder()
                .provider(new MyProvider(player)) // Here MyProvider will store the Player as a field, so you can use it inside the init/update methods.
                .size(3, 9)
                .title("Inventory of " + player.getName())
                .build();
}

MinusKube avatar Feb 26 '21 19:02 MinusKube