Merge pull request #22 from r0yzer/Docs

add item builder docs
This commit is contained in:
Jakob K
2021-05-01 21:38:42 +02:00
committed by GitHub
3 changed files with 28 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View File

@@ -0,0 +1,27 @@
## Create an itemStack
The default way of building complex `ItemStack`s using just Spigot is often painful to use and confusing for beginners.
With KSpigot's item builder you have an easy to use builder DSL. Additionally, it provides an easy way to update the `ItemMeta` of an `ItemStack`, which is often needed.
### Example use of the item builder
```kotlin
val sword = itemStack(Material.GOLDEN_SWORD) {
amount = 3
addEnchantment(Enchantment.KNOCKBACK, 2)
meta {
name = "${KColors.GOLD}Magic Sword"
isUnbreakable = true
addLore {
+ "This sword is truly special."
+ "Try it!"
}
customModel = 1001
flag(ItemFlag.HIDE_UNBREAKABLE)
}
}
```
### This creates the following item
![](img/sword.png)

View File

@@ -37,3 +37,4 @@ nav:
- Extensions:
- Event listener: extensions/listener.md
- Tasks: extensions/tasks.md
- Item Builder: extensions/itemBuilder.md