ItemBuilder

class ItemBuilder(material: Material, count: Int = 1, dsl: ItemBuilder.() -> Unit = {})(source)

The ItemBuilder class is used for building ItemStack objects with various properties and customizations. It provides methods for modifying the display name, lore, enchantments, flags, and other attributes of an ItemStack.

Parameters

material

The material of the ItemStack.

count

The count (stack size) of the ItemStack. Default is 1.

dsl

The DSL (Domain Specific Language) block that can be used to customize the item. Default is an empty block.

Constructors

Link copied to clipboard
constructor(material: Material, count: Int = 1, dsl: ItemBuilder.() -> Unit = {})

Types

Link copied to clipboard
object Companion

This class represents a companion object for the ItemBuilder class. It provides utility methods for creating ItemBuilder instances from ItemStack objects.

Link copied to clipboard

Functional interface representing a performer that performs an operation on an item.

Properties

Link copied to clipboard
var itemStack: ItemStack

The itemStack to get. This variable represents an ItemStack object that can be created using the material and count parameters.

Functions

Link copied to clipboard
fun addPersistentData(key: NamespacedKey, value: String): ItemBuilder

Adds persistent data to the item.

fun <T : Any> addPersistentData(key: NamespacedKey, persistentDataType: PersistentDataType<T, T>, value: T): ItemBuilder

Adds persistent data to the item stack.

Link copied to clipboard
fun addPersistentDataIf(key: NamespacedKey, value: String, condition: Boolean = false): ItemBuilder

Adds persistent data to the item if the specified condition is true.

Link copied to clipboard
fun build(): ItemStack

Retrieves the built ItemStack from the builder.

Link copied to clipboard

Clears the display name of the item.

Link copied to clipboard
fun clearDisplayIf(condition: Boolean = false): ItemBuilder

Clears the display of the item if the given condition is true.

Link copied to clipboard

Clear all enchantments on the item.

Link copied to clipboard
fun clearEnchantsIf(condition: Boolean = false): ItemBuilder

Clears all enchantments if the specified condition is true.

Link copied to clipboard

Clears all flags of the item.

Link copied to clipboard
fun clearFlagsIf(condition: Boolean = false): ItemBuilder

Clears the flags of the ItemBuilder object if the provided condition is true.

Link copied to clipboard

Clears the lore of the item.

Link copied to clipboard
fun clearLoreIf(condition: Boolean = false): ItemBuilder

Clears the lore of the ItemBuilder if the given condition is true.

Link copied to clipboard

Creates a deep copy of the current ItemBuilder object.

Link copied to clipboard

Checks the given condition and performs the specified operation on the ItemBuilder if the condition is true.

Link copied to clipboard

Sets the custom model data for an item.

Link copied to clipboard
fun display(displayName: String): ItemBuilder

Change the displayname of the item.

Link copied to clipboard
fun displayIf(displayName: String, condition: Boolean = false): ItemBuilder

Change the displayname of the item if a certain condition is true.

Link copied to clipboard
fun enchant(enchants: Map<Enchantment, Int>): ItemBuilder

Adds enchants to the item.

Link copied to clipboard
fun enchantIf(enchants: Map<Enchantment, Int>, condition: Boolean = false): ItemBuilder

Add enchants if condition is true

Link copied to clipboard
fun flag(vararg flags: ItemFlag): ItemBuilder

Add flags to the item.

Link copied to clipboard
fun lore(vararg lores: String): ItemBuilder

Adds lore to an ItemBuilder object.

Link copied to clipboard
fun loreIf(vararg lores: String, condition: Boolean = false): ItemBuilder

Adds lore to the item builder if the given condition is true.

Link copied to clipboard
fun <T : ItemMeta> meta(dsl: T.() -> Unit): ItemBuilder

Updates the item meta by applying the provided DSL (Domain Specific Language) to it.

Link copied to clipboard
fun onClick(onClick: (InventoryClickEvent) -> Unit): ItemBuilder

Sets the click event for the item.

Link copied to clipboard
fun owner(uuid: UUID): ItemBuilder

Sets the owning player of the skull item.

Sets the owner of the skull to the given name.

fun owner(offlinePlayer: OfflinePlayer): ItemBuilder

Sets the owner of the Player Head item.

Link copied to clipboard
fun removePersistantDataIf(key: NamespacedKey, condition: Boolean = false): ItemBuilder

Removes persistent data from the item if the condition is true.

Link copied to clipboard

Sets whether the item should have a glint effect or not.

Link copied to clipboard

Sets the owner of the player skull.

Link copied to clipboard
fun texture(texture: String): ItemBuilder

Sets the texture of the item to the specified texture.

Link copied to clipboard

Retrieves the skin texture of a player from MineSkin API based on the provided MineSkin UUID.

Link copied to clipboard
fun type(material: Material): ItemBuilder

Sets the material of the item stack.

Link copied to clipboard
fun typeIf(material: Material, condition: Boolean = false): ItemBuilder

Sets the type of the material in the ItemBuilder, if the given condition is true.