-
Notifications
You must be signed in to change notification settings - Fork 0
ItemBuilder
Larrox edited this page Aug 29, 2025
·
2 revisions
# 📘 ItemBuilder Wiki
The `ItemBuilder` is a utility in **LarroxUtilsAPI** that simplifies the creation of custom **ItemStacks** in Bukkit/Spigot.
It provides a fluent API to set names, lores, enchantments, flags, and even skull owners, making item creation **cleaner and more readable**.
---
> [!NOTE]
> Don’t forget to import:
> ```java
> import dev.larrox.ItemBuilder;
> ```
---
## 🚀 Features
- Create items with **custom names** (supports `&` color codes).
- Add **lores** (multi-line descriptions) with automatic color conversion.
- Apply **enchantments** with levels.
- Add **item flags** (e.g., hide enchantments).
- Set **player skull owners** (works only for `PLAYER_HEAD`).
- Build the final `ItemStack` in one line.
---
## 🛠️ Examples
### **Create a custom sword**
```java
ItemStack sword = new ItemBuilder(Material.DIAMOND_SWORD)
.setName("&bEpic Sword")
.setLore("&7This sword was forged by Larrox", "&cHandle with care!")
.addEnchant(Enchantment.DAMAGE_ALL, 5)
.addFlags(ItemFlag.HIDE_ENCHANTS)
.build();OfflinePlayer player = Bukkit.getOfflinePlayer("Larrox");
ItemStack skull = new ItemBuilder(Material.PLAYER_HEAD)
.setName("&aLarrox's Head")
.setOwner(player)
.build();ItemStack apple = new ItemBuilder(Material.APPLE)
.setName("&cMagic Apple")
.setLore("&7Restores health", "&7Tastes delicious")
.build();- Always call
.build()at the end to get the finishedItemStack. - Use
&color codes in names and lores — they are automatically converted to§. - Use
.addFlags(ItemFlag.HIDE_ENCHANTS)if you want to hide enchantment glow while still applying effects. - Only call
.setOwner()if the item is aPLAYER_HEAD, otherwise it has no effect.