public class SimpleInventory implements InventoryProvider {
public static final SmartInventory INVENTORY = SmartInventory.builder()
.provider(new SimpleInventory())
.title(ChatColor.BLUE + "My Awesome Inventory!")
private final Random random = new Random();
public void init(Player player, InventoryContents contents) {
contents.fillBorders(ClickableItem.empty(new ItemStack(Material.STAINED_GLASS_PANE)));
contents.set(1, 1, ClickableItem.of(new ItemStack(Material.CARROT_ITEM),
e -> player.sendMessage(ChatColor.GOLD + "You clicked on a potato.")));
contents.set(1, 7, ClickableItem.of(new ItemStack(Material.BARRIER),
e -> player.closeInventory()));
public void update(Player player, InventoryContents contents) {
int state = contents.property("state", 0);
contents.setProperty("state", state + 1);
short durability = (short) random.nextInt(15);
ItemStack glass = new ItemStack(Material.STAINED_GLASS_PANE, 1, durability);
contents.fillBorders(ClickableItem.empty(glass));