Package xyz.xenondevs.invui.item.builder
Class AbstractItemBuilder<S>
java.lang.Object
xyz.xenondevs.invui.item.builder.AbstractItemBuilder<S>
- Type Parameters:
S
- Self reference, used for chaining.
- All Implemented Interfaces:
Cloneable
,Supplier<@NotNull org.bukkit.inventory.ItemStack>
,ItemProvider
- Direct Known Subclasses:
BannerBuilder
,FireworkBuilder
,ItemBuilder
,PotionBuilder
,SkullBuilder
Abstract base class for item builders.
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
The amount of theItemStack
.protected org.bukkit.inventory.ItemStack
TheItemStack
to use as a base.protected int
The custom model data value of theItemStack
.protected int
The damage value of theItemStack
protected xyz.xenondevs.inventoryaccess.component.ComponentWrapper
The display name of theItemStack
.The enchantments of theItemStack
.protected List
<org.bukkit.inventory.ItemFlag> The selectedItemFlags
of theItemStack
.protected List
<xyz.xenondevs.inventoryaccess.component.ComponentWrapper> The lore of theItemStack
.protected org.bukkit.Material
TheMaterial
of theItemStack
.Additional modifier functions to be run after building theItemStack
.protected Boolean
The unbreakable state of theItemStack
.Fields inherited from interface xyz.xenondevs.invui.item.ItemProvider
EMPTY
-
Constructor Summary
ConstructorDescriptionAbstractItemBuilder
(@NotNull org.bukkit.Material material) Constructs a newAbstractItemBuilder
based on the givenMaterial
.AbstractItemBuilder
(@NotNull org.bukkit.Material material, int amount) Constructs a newAbstractItemBuilder
based on the givenMaterial
and amount.AbstractItemBuilder
(@NotNull org.bukkit.inventory.ItemStack base) Constructs a newAbstractItemBuilder
based on the giveItemStack
. -
Method Summary
Modifier and TypeMethodDescriptionAdds all existingItemFlags
.addEnchantment
(org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction) Adds an enchantment.addItemFlags
(@NotNull org.bukkit.inventory.ItemFlag... itemFlags) AddsItemFlags
.addLegacyLoreLines
(@NotNull List<@NotNull String> lines) Adds lore lines using the legacy text format.addLoreLines
(@NotNull String... lines) Adds lore lindes using the legacy text format.addLoreLines
(@NotNull List<@NotNull xyz.xenondevs.inventoryaccess.component.ComponentWrapper> lines) Adds lore lines.addLoreLines
(@NotNull net.md_5.bungee.api.chat.BaseComponent[]... lines) Adds lore lines.addLoreLines
(@NotNull xyz.xenondevs.inventoryaccess.component.ComponentWrapper... lines) Adds lore lines.addModifier
(Function<org.bukkit.inventory.ItemStack, org.bukkit.inventory.ItemStack> modifier) Adds a modifier function, which will be run after building theItemStack
.Removes all enchantments.Removes allItemFlags
.Clears the lore.Removes all modifier functions.clone()
Clones this builder.@NotNull org.bukkit.inventory.ItemStack
Builds theItemStack
int
Gets the amount.@Nullable org.bukkit.inventory.ItemStack
getBase()
Gets the baseItemStack
of this builder.int
Gets the custom model data value.int
Gets the damage value.@Nullable xyz.xenondevs.inventoryaccess.component.ComponentWrapper
Gets the display name.Gets the enchantments.@Nullable List
<org.bukkit.inventory.ItemFlag> Gets the configuredItemFlags
.@Nullable List
<xyz.xenondevs.inventoryaccess.component.ComponentWrapper> getLore()
Gets the lore.@Nullable org.bukkit.Material
Gets theMaterial
of this builder.Gets the configured modifier functions.@Nullable Boolean
Gets the unbreakable state, null for default.removeEnchantment
(org.bukkit.enchantments.Enchantment enchantment) Adds an enchantment.removeItemFlags
(@NotNull org.bukkit.inventory.ItemFlag... itemFlags) Removes the specifiedItemFlags
.removeLoreLine
(int index) Removes a lore line at the given index.setAmount
(int amount) Sets the amount.setCustomModelData
(int customModelData) Sets the custom model data value.setDamage
(int damage) Sets the damage value.setDisplayName
(String displayName) Sets the display name.setDisplayName
(net.md_5.bungee.api.chat.BaseComponent... displayName) Sets the display name.setDisplayName
(xyz.xenondevs.inventoryaccess.component.ComponentWrapper component) Sets the display name.setEnchantments
(@NotNull HashMap<org.bukkit.enchantments.Enchantment, Pair<Integer, Boolean>> enchantments) Sets the enchantments.setItemFlags
(@NotNull List<org.bukkit.inventory.ItemFlag> itemFlags) Sets theItemFlags
.setLegacyLore
(@NotNull List<@NotNull String> lore) Sets the lore using the legacy text format.Sets the lore.setMaterial
(@NotNull org.bukkit.Material material) Sets theMaterial
of this builder.setUnbreakable
(boolean unbreakable) Sets the unbreakable state.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface xyz.xenondevs.invui.item.ItemProvider
get
-
Field Details
-
base
protected org.bukkit.inventory.ItemStack baseTheItemStack
to use as a base. -
material
protected org.bukkit.Material materialTheMaterial
of theItemStack
. -
amount
protected int amountThe amount of theItemStack
. -
damage
protected int damageThe damage value of theItemStack
-
customModelData
protected int customModelDataThe custom model data value of theItemStack
. -
unbreakable
The unbreakable state of theItemStack
. -
displayName
protected xyz.xenondevs.inventoryaccess.component.ComponentWrapper displayNameThe display name of theItemStack
. -
lore
The lore of theItemStack
. -
itemFlags
The selectedItemFlags
of theItemStack
. -
enchantments
The enchantments of theItemStack
. -
modifiers
Additional modifier functions to be run after building theItemStack
.
-
-
Constructor Details
-
AbstractItemBuilder
public AbstractItemBuilder(@NotNull @NotNull org.bukkit.Material material) Constructs a newAbstractItemBuilder
based on the givenMaterial
.- Parameters:
material
- TheMaterial
-
AbstractItemBuilder
public AbstractItemBuilder(@NotNull @NotNull org.bukkit.Material material, int amount) Constructs a newAbstractItemBuilder
based on the givenMaterial
and amount.- Parameters:
material
- TheMaterial
amount
- The amount
-
AbstractItemBuilder
public AbstractItemBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack base) Constructs a newAbstractItemBuilder
based on the giveItemStack
. This will keep theItemStack
and uses it'sItemMeta
- Parameters:
base
- Theto use as a base
-
-
Method Details
-
get
@Contract(value="_ -> new", pure=true) @NotNull public @NotNull org.bukkit.inventory.ItemStack get(@Nullable @Nullable String lang) Builds theItemStack
- Specified by:
get
in interfaceItemProvider
- Parameters:
lang
- The language to translate the item in.- Returns:
- The
ItemStack
-
removeLoreLine
Removes a lore line at the given index.- Parameters:
index
- The index of the lore line to remove- Returns:
- The builder instance
-
clearLore
Clears the lore.- Returns:
- The builder instance
-
getBase
@Nullable public @Nullable org.bukkit.inventory.ItemStack getBase()Gets the baseItemStack
of this builder.- Returns:
- The base
ItemStack
-
getMaterial
@Nullable public @Nullable org.bukkit.Material getMaterial()Gets theMaterial
of this builder.- Returns:
- The
Material
-
setMaterial
@Contract("_ -> this") @NotNull public S setMaterial(@NotNull @NotNull org.bukkit.Material material) Sets theMaterial
of this builder.- Parameters:
material
- TheMaterial
- Returns:
- The builder instance
-
getAmount
public int getAmount()Gets the amount.- Returns:
- The amount
-
setAmount
Sets the amount.- Parameters:
amount
- The amount- Returns:
- The builder instance
-
getDamage
public int getDamage()Gets the damage value.- Returns:
- The damage value
-
setDamage
Sets the damage value.- Parameters:
damage
- The damage value- Returns:
- The builder instance
-
getCustomModelData
public int getCustomModelData()Gets the custom model data value.- Returns:
- The custom model data value
-
setCustomModelData
Sets the custom model data value.- Parameters:
customModelData
- The custom model data value- Returns:
- The builder instance
-
isUnbreakable
Gets the unbreakable state, null for default.- Returns:
- The unbreakable state
-
setUnbreakable
Sets the unbreakable state.- Parameters:
unbreakable
- The unbreakable state- Returns:
- The builder instance
-
getDisplayName
@Nullable public @Nullable xyz.xenondevs.inventoryaccess.component.ComponentWrapper getDisplayName()Gets the display name.- Returns:
- The display name
-
setDisplayName
Sets the display name.- Parameters:
displayName
- The display name- Returns:
- The builder instance
-
setDisplayName
@Contract("_ -> this") @NotNull public S setDisplayName(net.md_5.bungee.api.chat.BaseComponent... displayName) Sets the display name.- Parameters:
displayName
- The display name- Returns:
- The builder instance
-
setDisplayName
@Contract("_ -> this") @NotNull public S setDisplayName(xyz.xenondevs.inventoryaccess.component.ComponentWrapper component) Sets the display name.- Parameters:
component
- The display name- Returns:
- The builder instance
-
getLore
Gets the lore.- Returns:
- The lore
-
setLore
@Contract("_ -> this") @NotNull public S setLore(@NotNull @NotNull List<@NotNull xyz.xenondevs.inventoryaccess.component.ComponentWrapper> lore) Sets the lore.- Parameters:
lore
- The lore- Returns:
- The builder instance
-
setLegacyLore
@Contract("_ -> this") @NotNull public S setLegacyLore(@NotNull @NotNull List<@NotNull String> lore) Sets the lore using the legacy text format.- Parameters:
lore
- The lore- Returns:
- The builder instance
-
addLoreLines
Adds lore lindes using the legacy text format.- Parameters:
lines
- The lore lines- Returns:
- The builder instance
-
addLoreLines
@Contract("_ -> this") @NotNull public S addLoreLines(@NotNull @NotNull net.md_5.bungee.api.chat.BaseComponent[]... lines) Adds lore lines.- Parameters:
lines
- The lore lines, where eachBaseComponent
array represents a line.- Returns:
- The builder instance
-
addLoreLines
@Contract("_ -> this") @NotNull public S addLoreLines(@NotNull @NotNull xyz.xenondevs.inventoryaccess.component.ComponentWrapper... lines) Adds lore lines.- Parameters:
lines
- The lore lines- Returns:
- The builder instance
-
addLoreLines
@Contract("_ -> this") @NotNull public S addLoreLines(@NotNull @NotNull List<@NotNull xyz.xenondevs.inventoryaccess.component.ComponentWrapper> lines) Adds lore lines.- Parameters:
lines
- The lore lines- Returns:
- The builder instance
-
addLegacyLoreLines
@Contract("_ -> this") @NotNull public S addLegacyLoreLines(@NotNull @NotNull List<@NotNull String> lines) Adds lore lines using the legacy text format.- Parameters:
lines
- The lore lines- Returns:
- The builder instance
-
getItemFlags
Gets the configuredItemFlags
.- Returns:
- The
ItemFlags
-
setItemFlags
@Contract("_ -> this") @NotNull public S setItemFlags(@NotNull @NotNull List<org.bukkit.inventory.ItemFlag> itemFlags) Sets theItemFlags
.- Parameters:
itemFlags
- TheItemFlags
- Returns:
- The builder instance
-
addItemFlags
@Contract("_ -> this") @NotNull public S addItemFlags(@NotNull @NotNull org.bukkit.inventory.ItemFlag... itemFlags) AddsItemFlags
.- Parameters:
itemFlags
- TheItemFlags
- Returns:
- The builder instance
-
addAllItemFlags
Adds all existingItemFlags
.- Returns:
- The builder instance
-
removeItemFlags
@Contract("_ -> this") @NotNull public S removeItemFlags(@NotNull @NotNull org.bukkit.inventory.ItemFlag... itemFlags) Removes the specifiedItemFlags
.- Parameters:
itemFlags
- TheItemFlags
to remove- Returns:
- The builder instance
-
clearItemFlags
Removes allItemFlags
.- Returns:
- The builder instance
-
getEnchantments
@Nullable public @Nullable HashMap<org.bukkit.enchantments.Enchantment,Pair<Integer, getEnchantments()Boolean>> Gets the enchantments.- Returns:
- The enchantments
-
setEnchantments
@Contract("_ -> this") @NotNull public S setEnchantments(@NotNull @NotNull HashMap<org.bukkit.enchantments.Enchantment, Pair<Integer, Boolean>> enchantments) Sets the enchantments.- Parameters:
enchantments
- The enchantments- Returns:
- The builder instance
-
addEnchantment
@Contract("_, _, _ -> this") @NotNull public S addEnchantment(org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction) Adds an enchantment.- Parameters:
enchantment
- The enchantmentlevel
- The levelignoreLevelRestriction
- Whether to ignore the level restriction- Returns:
- The builder instance
-
removeEnchantment
@Contract("_ -> this") @NotNull public S removeEnchantment(org.bukkit.enchantments.Enchantment enchantment) Adds an enchantment.- Parameters:
enchantment
- The enchantment- Returns:
- The builder instance
-
clearEnchantments
Removes all enchantments.- Returns:
- The builder instance
-
getModifiers
@Nullable public @Nullable List<Function<org.bukkit.inventory.ItemStack,org.bukkit.inventory.ItemStack>> getModifiers()Gets the configured modifier functions.- Returns:
- The modifier functions
-
addModifier
@Contract("_ -> this") @NotNull public S addModifier(Function<org.bukkit.inventory.ItemStack, org.bukkit.inventory.ItemStack> modifier) Adds a modifier function, which will be run after building theItemStack
.- Parameters:
modifier
- The modifier function- Returns:
- The builder instance
-
clearModifiers
Removes all modifier functions.- Returns:
- The builder instance
-
clone
Clones this builder.
-