Package dev.triumphteam.gui.builder.item
Class BaseItemBuilder<B extends BaseItemBuilder<B>>
java.lang.Object
dev.triumphteam.gui.builder.item.BaseItemBuilder<B>
- Type Parameters:
B- The ItemBuilder type so the methods can cast to the subtype
- Direct Known Subclasses:
BannerBuilder,BookBuilder,FireworkBuilder,ItemBuilder,MapBuilder,SkullBuilder
Contains all the common methods for the future ItemBuilders
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseItemBuilder(@NotNull org.bukkit.inventory.ItemStack itemStack) -
Method Summary
Modifier and TypeMethodDescriptionaddEnchantment(@NotNull org.bukkit.enchantments.Enchantment enchantment) Deprecated.addEnchantment(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level) Deprecated.In favor ofenchant(Enchantment, int), nothing changed just the name, will be removed in 3.0.1addEnchantment(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction) Deprecated.In favor ofenchant(Enchantment, int, boolean), nothing changed just the name, will be removed in 3.0.1addItemFlags(@NotNull org.bukkit.inventory.ItemFlag... flags) Deprecated.In favor offlags(ItemFlag...), nothing changed just the name, will be removed in 3.0.1Deprecated.In favor oflore(Consumer), will be removed in 3.0.1Deprecated.In favor oflore(Consumer), will be removed in 3.0.1amount(int amount) Sets the amount of items@NotNull GuiItemCreates aGuiIteminstead of anItemStack@NotNull GuiItemCreates aGuiIteminstead of anItemStack@NotNull org.bukkit.inventory.ItemStackbuild()Builds the item intoItemStackcolor(@NotNull org.bukkit.Color color) Color anItemStackdisenchant(@NotNull org.bukkit.enchantments.Enchantment enchantment) Disenchants a certainEnchantmentfrom theItemStackEnchants theItemStackwith the specified map where the value is the level of the key's enchantmentenchant(@NotNull Map<org.bukkit.enchantments.Enchantment, Integer> enchantments, boolean ignoreLevelRestriction) Enchants theItemStackwith the specified map where the value is the level of the key's enchantmentenchant(@NotNull org.bukkit.enchantments.Enchantment enchantment) Enchants theItemStackenchant(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level) Enchants theItemStackenchant(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction) Enchants theItemStackflags(@NotNull org.bukkit.inventory.ItemFlag... flags) Add anItemFlagto the itemprotected @NotNull org.bukkit.inventory.ItemStackPackage private getter for extended buildersprotected @NotNull org.bukkit.inventory.meta.ItemMetagetMeta()Package private getter for extended buildersglow()Makes theItemStackglowglow(boolean glow) Adds or removes theItemStackglowConsumer for freely adding to the loreSet the lore lines of an itemlore(@Nullable net.kyori.adventure.text.Component @NotNull ... lore) Set the lore lines of an itemmodel(int modelData) Sets the custom model data of the item Added in 1.13name(@NotNull net.kyori.adventure.text.Component name) Sets the display name of the item usingComponentConsumer for applyingPersistentDataContainerto the item This method will only work on versions above 1.14removeEnchantment(@NotNull org.bukkit.enchantments.Enchantment enchantment) Deprecated.In favor ofdisenchant(Enchantment), nothing changed just the name, will be removed in 3.0.1Removes NBT tag from theItemStacksetAmount(int amount) Deprecated.In favor ofamount(int), nothing changed just the name, will be removed in 3.0.1protected voidsetItemStack(@NotNull org.bukkit.inventory.ItemStack itemStack) Package private setter for the extended buildersDeprecated.In favor oflore(Component...), will be removed in 3.0.1Deprecated.In favor oflore(List), will be removed in 3.0.1protected voidsetMeta(@NotNull org.bukkit.inventory.meta.ItemMeta meta) Package private setter for the extended buildersDeprecated.In favor ofname(Component), will be removed in 3.0.1Sets NBT tag to theItemStackSets NBT tag to theItemStacksetUnbreakable(boolean unbreakable) Deprecated.In favor ofunbreakable(), nothing changed just the name, will be removed in 3.0.1Makes theItemStackunbreakableunbreakable(boolean unbreakable) Sets the item as unbreakable
-
Constructor Details
-
BaseItemBuilder
protected BaseItemBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
-
-
Method Details
-
name
@NotNull @Contract("_ -> this") public B name(@NotNull @NotNull net.kyori.adventure.text.Component name) Sets the display name of the item usingComponent- Parameters:
name- TheComponentname- Returns:
ItemBuilder- Since:
- 3.0.0
-
amount
Sets the amount of items- Parameters:
amount- the amount of items- Returns:
ItemBuilder- Since:
- 3.0.0
-
lore
@NotNull @Contract("_ -> this") public B lore(@Nullable @Nullable net.kyori.adventure.text.Component @NotNull ... lore) Set the lore lines of an item- Parameters:
lore- Lore lines as varargs- Returns:
ItemBuilder- Since:
- 3.0.0
-
lore
@NotNull @Contract("_ -> this") public B lore(@NotNull @NotNull List<@Nullable net.kyori.adventure.text.Component> lore) Set the lore lines of an item- Parameters:
lore- AListwith the lore lines- Returns:
ItemBuilder- Since:
- 3.0.0
-
lore
@NotNull @Contract("_ -> this") public B lore(@NotNull @NotNull Consumer<List<@Nullable net.kyori.adventure.text.Component>> lore) Consumer for freely adding to the lore- Parameters:
lore- AConsumerwith theListof loreComponent- Returns:
ItemBuilder- Since:
- 3.0.0
-
enchant
@NotNull @Contract("_, _, _ -> this") public B enchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction) Enchants theItemStack- Parameters:
enchantment- TheEnchantmentto addlevel- The level of theEnchantmentignoreLevelRestriction- If should or not ignore it- Returns:
ItemBuilder- Since:
- 3.0.0
-
enchant
@NotNull @Contract("_, _ -> this") public B enchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level) Enchants theItemStack- Parameters:
enchantment- TheEnchantmentto addlevel- The level of theEnchantment- Returns:
ItemBuilder- Since:
- 3.0.0
-
enchant
@NotNull @Contract("_ -> this") public B enchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment) Enchants theItemStack- Parameters:
enchantment- TheEnchantmentto add- Returns:
ItemBuilder- Since:
- 3.0.0
-
enchant
@NotNull @Contract("_, _ -> this") public B enchant(@NotNull @NotNull Map<org.bukkit.enchantments.Enchantment, Integer> enchantments, boolean ignoreLevelRestriction) Enchants theItemStackwith the specified map where the value is the level of the key's enchantment- Parameters:
enchantments- Enchantments to addignoreLevelRestriction- If level restriction should be ignored- Returns:
ItemBuilder- Since:
- 3.1.2
-
enchant
@NotNull @Contract("_ -> this") public B enchant(@NotNull @NotNull Map<org.bukkit.enchantments.Enchantment, Integer> enchantments) Enchants theItemStackwith the specified map where the value is the level of the key's enchantment- Parameters:
enchantments- Enchantments to add- Returns:
ItemBuilder- Since:
- 3.1.2
-
disenchant
@NotNull @Contract("_ -> this") public B disenchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment) Disenchants a certainEnchantmentfrom theItemStack- Parameters:
enchantment- TheEnchantmentto remove- Returns:
ItemBuilder- Since:
- 3.0.0
-
flags
@NotNull @Contract("_ -> this") public B flags(@NotNull @NotNull org.bukkit.inventory.ItemFlag... flags) Add anItemFlagto the item- Parameters:
flags- TheItemFlagto add- Returns:
ItemBuilder- Since:
- 3.0.0
-
unbreakable
Makes theItemStackunbreakable- Returns:
ItemBuilder- Since:
- 3.0.0
-
unbreakable
Sets the item as unbreakable- Parameters:
unbreakable- If should or not be unbreakable- Returns:
ItemBuilder
-
glow
Makes theItemStackglow- Returns:
ItemBuilder- Since:
- 3.0.0
-
glow
Adds or removes theItemStackglow- Parameters:
glow- Should the item glow- Returns:
ItemBuilder
-
pdc
@NotNull @Contract("_ -> this") public B pdc(@NotNull @NotNull Consumer<org.bukkit.persistence.PersistentDataContainer> consumer) Consumer for applyingPersistentDataContainerto the item This method will only work on versions above 1.14- Parameters:
consumer- TheConsumerwith the PDC- Returns:
ItemBuilder- Since:
- 3.0.0
-
model
Sets the custom model data of the item Added in 1.13- Parameters:
modelData- The custom model data from the resource pack- Returns:
ItemBuilder- Since:
- 3.0.0
-
color
Color anItemStack- Parameters:
color- color- Returns:
BaseItemBuilder- Since:
- 3.0.3
- See Also:
-
LeatherArmorMeta.setColor(Color)MapMeta.setColor(Color)
-
setNbt
@NotNull @Contract("_, _ -> this") public B setNbt(@NotNull @NotNull String key, @NotNull @NotNull String value) Sets NBT tag to theItemStack- Parameters:
key- The NBT keyvalue- The NBT value- Returns:
ItemBuilder
-
setNbt
Sets NBT tag to theItemStack- Parameters:
key- The NBT keyvalue- The NBT value- Returns:
ItemBuilder
-
removeNbt
Removes NBT tag from theItemStack- Parameters:
key- The NBT key- Returns:
ItemBuilder
-
build
@NotNull public @NotNull org.bukkit.inventory.ItemStack build()Builds the item intoItemStack- Returns:
- The fully built
ItemStack
-
asGuiItem
Creates aGuiIteminstead of anItemStack -
asGuiItem
@NotNull @Contract("_ -> new") public @NotNull GuiItem asGuiItem(@NotNull @NotNull GuiAction<org.bukkit.event.inventory.InventoryClickEvent> action) Creates aGuiIteminstead of anItemStack -
getItemStack
@NotNull protected @NotNull org.bukkit.inventory.ItemStack getItemStack()Package private getter for extended builders- Returns:
- The ItemStack
-
setItemStack
protected void setItemStack(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) Package private setter for the extended builders- Parameters:
itemStack- The ItemStack
-
getMeta
@NotNull protected @NotNull org.bukkit.inventory.meta.ItemMeta getMeta()Package private getter for extended builders- Returns:
- The ItemMeta
-
setMeta
protected void setMeta(@NotNull @NotNull org.bukkit.inventory.meta.ItemMeta meta) Package private setter for the extended builders- Parameters:
meta- The ItemMeta
-
setName
Deprecated.In favor ofname(Component), will be removed in 3.0.1Set display name of the item- Parameters:
name- the display name of the item- Returns:
ItemBuilder
-
setAmount
Deprecated.In favor ofamount(int), nothing changed just the name, will be removed in 3.0.1Sets the amount of items- Parameters:
amount- the amount of items- Returns:
ItemBuilder
-
addLore
Deprecated.In favor oflore(Consumer), will be removed in 3.0.1Add lore lines of an item- Parameters:
lore- the lore lines to add- Returns:
ItemBuilder
-
addLore
Deprecated.In favor oflore(Consumer), will be removed in 3.0.1Set lore lines of an item- Parameters:
lore- AListwith the lore lines to add- Returns:
ItemBuilder
-
setLore
Deprecated.In favor oflore(Component...), will be removed in 3.0.1Set the lore lines of an item- Parameters:
lore- the lore lines to set- Returns:
ItemBuilder
-
setLore
Deprecated.In favor oflore(List), will be removed in 3.0.1Set the lore lines of an item- Parameters:
lore- AListwith the lore lines- Returns:
ItemBuilder
-
addEnchantment
@Deprecated public B addEnchantment(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction) Deprecated.In favor ofenchant(Enchantment, int, boolean), nothing changed just the name, will be removed in 3.0.1Add enchantment to an item- Parameters:
enchantment- theEnchantmentto addlevel- the level of theEnchantmentignoreLevelRestriction- If should or not ignore it- Returns:
ItemBuilder
-
addEnchantment
@Deprecated public B addEnchantment(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level) Deprecated.In favor ofenchant(Enchantment, int), nothing changed just the name, will be removed in 3.0.1Add enchantment to an item- Parameters:
enchantment- theEnchantmentto addlevel- the level of theEnchantment- Returns:
ItemBuilder
-
addEnchantment
@Deprecated public B addEnchantment(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment) Deprecated.In favor ofenchant(Enchantment), nothing changed just the name, will be removed in 3.0.1Add enchantment to an item- Parameters:
enchantment- theEnchantmentto add- Returns:
ItemBuilder
-
removeEnchantment
@Deprecated public B removeEnchantment(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment) Deprecated.In favor ofdisenchant(Enchantment), nothing changed just the name, will be removed in 3.0.1Removes a certainEnchantmentfrom the item- Parameters:
enchantment- TheEnchantmentto remove- Returns:
ItemBuilder
-
addItemFlags
Deprecated.In favor offlags(ItemFlag...), nothing changed just the name, will be removed in 3.0.1Add a customItemFlagto the item- Parameters:
flags- theItemFlagto add- Returns:
ItemBuilder
-
setUnbreakable
Deprecated.In favor ofunbreakable(), nothing changed just the name, will be removed in 3.0.1Sets the item as unbreakable- Parameters:
unbreakable- If should or not be unbreakable- Returns:
ItemBuilder
-
enchant(Enchantment), nothing changed just the name, will be removed in 3.0.1