Package space.maxus.flare.item
Class ItemStackBuilder
java.lang.Object
space.maxus.flare.item.ItemStackBuilder
- All Implemented Interfaces:
ItemProvider
An ItemStack Builder, which is a wrapper around an ItemStack that contains multiple convenience methods
for constructing ItemStacks.
-
Constructor Summary
ConstructorsConstructorDescriptionItemStackBuilder(org.bukkit.Material material, @Nullable org.bukkit.entity.Player player) Constructs a new ItemStackBuilder for the given Material. -
Method Summary
Modifier and TypeMethodDescriptionAdds provided lore to this item's lore viaFlareUtil.partitionString(String)Adds all components to this item loreaddLoreLine(@NotNull String line) Adds a single lore line to this item loreaddLoreLine(@NotNull net.kyori.adventure.text.Component line) Adds a single lore line to this item lorebranch(boolean condition, Consumer<ItemStackBuilder> ifTrue) A utility method that branches configuration of this builder based on condition.branch(boolean condition, Consumer<ItemStackBuilder> ifTrue, Consumer<ItemStackBuilder> ifFalse) A utility method that branches configuration of this builder based on condition.org.bukkit.inventory.ItemStackbuild()Finishes this builder and returns clone of inner stackcount(@org.checkerframework.common.value.qual.IntRange(from=0L, to=128L) int count) Sets the amount of items in this stackEdits meta of this item<M extends org.bukkit.inventory.meta.ItemMeta>
ItemStackBuildereditTypedMeta(Consumer<M> meta) Edits meta of this item, using a generic typeItemStackBuilderglint()Adds enchantment glint to this item.Sets this item's head skin to the provided skin.Adds allItemFlags to this item, essentially hiding all extra data from lore.hideFlags(org.bukkit.inventory.ItemFlag... flags) Adds certain provided item flags to this itemSets lore of the item to the provided lore viaItems.loreMeta(java.lang.String)Sets this item's lore to provided component listSets this item name to provided namepadLore()Adds an empty line to this loreorg.bukkit.inventory.ItemStackprovide()Provides an item stack.type(org.bukkit.Material type) Changes item type without fully wiping its meta
-
Constructor Details
-
ItemStackBuilder
public ItemStackBuilder(org.bukkit.Material material, @Nullable @Nullable org.bukkit.entity.Player player) Constructs a new ItemStackBuilder for the given Material.- Parameters:
material- Material of the Itemplayer- Used for PlaceholderAPI resolution. May be null.
-
-
Method Details
-
type
Changes item type without fully wiping its meta- Parameters:
type- New item type- Returns:
- This builder
-
count
public ItemStackBuilder count(@org.checkerframework.common.value.qual.IntRange(from=0L, to=128L) int count) Sets the amount of items in this stack- Parameters:
count- New item count. Must be within 0 to 128, otherwise Bukkit errors may arise- Returns:
- This builder
-
editMeta
Edits meta of this item- Parameters:
meta- Consumer that edits meta of the item- Returns:
- This builder
-
editTypedMeta
public <M extends org.bukkit.inventory.meta.ItemMeta> ItemStackBuilder editTypedMeta(Consumer<M> meta) Edits meta of this item, using a generic typeItemStackBuilder- Type Parameters:
M- The type of meta.- Parameters:
meta- Consumer that edits meta of the item- Returns:
- This builder
-
hideAllFlags
Adds allItemFlags to this item, essentially hiding all extra data from lore.- Returns:
- This builder
-
hideFlags
Adds certain provided item flags to this item- Parameters:
flags- Flags to be added- Returns:
- This builder
-
lore
Sets lore of the item to the provided lore viaItems.loreMeta(java.lang.String)- Parameters:
lore- Lore to be set- Returns:
- This builder
-
lore
Sets this item's lore to provided component list- Parameters:
lore- Lore to be set- Returns:
- This builder
-
addLore
Adds provided lore to this item's lore viaFlareUtil.partitionString(String)- Parameters:
lore- Lore to be added to this item- Returns:
- This builder
-
addLore
Adds all components to this item lore- Parameters:
lore- Lore to be added to this item- Returns:
- This builder
-
addLoreLine
Adds a single lore line to this item lore- Parameters:
line- Lore line to be added- Returns:
- This builder
-
addLoreLine
Adds a single lore line to this item lore- Parameters:
line- Lore line to be added- Returns:
- This builder
-
padLore
Adds an empty line to this lore- Returns:
- This builder
-
name
Sets this item name to provided name- Parameters:
name- Name to be set- Returns:
- This builder
-
glint
Adds enchantment glint to this item.
You might want to callhideAllFlags()orhideFlags(ItemFlag...)after this to hide enchantment info- Returns:
- This builder
-
headSkin
Sets this item's head skin to the provided skin. Will fail if the item is not of typeMaterial.PLAYER_HEAD- Parameters:
skin- Base64 data of head skin. SeeItems.head(String)for more info- Returns:
- This builder
-
branch
public ItemStackBuilder branch(boolean condition, Consumer<ItemStackBuilder> ifTrue, Consumer<ItemStackBuilder> ifFalse) A utility method that branches configuration of this builder based on condition.- Parameters:
condition- Condition to be checkedifTrue- Executed if condition is trueifFalse- Executed if condition is false- Returns:
- This builder
-
branch
A utility method that branches configuration of this builder based on condition.- Parameters:
condition- Condition to be checkedifTrue- Executed if condition is true- Returns:
- This builder
-
build
public org.bukkit.inventory.ItemStack build()Finishes this builder and returns clone of inner stack- Returns:
- Clone of inner stack
-
provide
public org.bukkit.inventory.ItemStack provide()Description copied from interface:ItemProviderProvides an item stack.- Specified by:
providein interfaceItemProvider- Returns:
- an ItemStack. May be null
-