InventoryBuilder

Since 1.0.0

Just like you can create items with the ItemBuilder, you can also create full inventories with the InventoryBuilder. This class is designed to create inventories way faster than you would be able to create them normally, here is how.

import net.codersky.mcutils.builders.InventoryBuilder;

// Creates a 2 row inventory full of emeralds and diamonds.
Inventory inv = new InventoryBuilder("&6Title", 2)
    // Fills first row with emeralds.
    .set(new ItemStack(Material.EMERALD), MCNumbers.range(0, 8))
    // Replaces the remaining empty slots with diamonds.
    .replaceAll(Material.AIR, new ItemStack(Material.DIAMOND))
    .build();

This is just a very basic usage of this class. You can also use custom conditions to replace items with replaceAllIf or setIf, this can be powerful if you combine it with MCNumbers#range. You can also iterate over all slots with forEach or forEachIf. We encourage you to check all available methods as they are very flexible.

Last updated