Skip to content

Create custom items

This example shows how to create custom items using the ItemBuilder.

Items can be customized with name, lore, enchantments, persistent data and more.

Deep dive: [[ItemBuilder|Core-API/Items/ItemBuilder]]


Steps

  1. Create an ItemBuilder
  2. Set basic properties (name, lore)
  3. Add optional features (glowing, data, etc.)
  4. Build the item

Basic example

// create a key to identify the item later


NamespacedKey key = new NamespacedKey(plugin, "egg-uses");

ItemStack easterEgg = ItemBuilder.material(Material.EGG)
        .name("<rainbow>Easteregg</rainbow>")
        .lore(
                "<rainbow>A rare drop of the easter</rainbow>",
                "<rainbow>rabbit pet!</rainbow>"
        )
        .glowing()
        .unbreakable(true)
        // store custom data inside the item
        .persistentData(key, PersistentDataType.INTEGER, 5)
        // limit stack size
        .maximumAmount(1)
        .build();

Special cases

Skull

// using pixel player


ItemStack playerHead = ItemBuilder.skull(player)
        .name(player.getName() + "'s head")
        .build();

// advanced: loading skull data asynchronously


BukkitExecutor.runAsync(plugin, () -> {
    SkullUtil.SkullData skullData;

    try {
        skullData = SkullUtil.getSkullData(playerName);
    } catch (Exception e) {
        return;
    }

    BukkitExecutor.runSync(plugin, () -> {
        ItemStack customHead = ItemBuilder.material(Material.PLAYER_HEAD)
                .anvilName(playerName + "'s head")
                .skullTexture(skullData)
                .build();
    });
});

Enchanted book

// enchanted book (uses enchantment storage)


ItemStack protectionBook = ItemBuilder.enchantedBook(
        Enchantment.PROTECTION
).build();

// multiple enchantments on normal items


ItemStack enchantedItem = ItemBuilder.material(Material.DIAMOND)
        .enchantment(
                Map.of(
                        Enchantment.FORTUNE, 10,
                        CoreEnchantment.SOUL_BOUND, 1
                )
        )
        .build();

name vs anvilName

// styled name (default formatting applied)


ItemStack normalName = ItemBuilder.material(Material.DIAMOND)
        .name("<aqua>Styled name</aqua>")
        .build();

// raw name (like renamed in an anvil)


ItemStack anvilName = ItemBuilder.material(Material.DIAMOND)
        .anvilName("<aqua>Styled name</aqua>")
        .build();
  • name(...) applies default formatting (color + no italic)
  • anvilName(...) keeps the raw formatting (like player input)

Notes

  • Use persistentData(...) to store custom values inside items
  • maximumAmount(...) limits stacking
  • Use helper methods like skull(...) or enchantedBook(...) for special items
  • Keep item creation clean and reusable

Next step

[[Create a specialitem|Core-API/Build-your-first-feature/Items/Create-a-specialitem]]