Class BaseItemBuilder<B extends BaseItemBuilder<B>>
java.lang.Object
io.rhythmknights.coreapi.modal.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
This class expects Components to be pre-parsed by CoreFramework's TextUtility.
CoreAPI handles ONLY GUI building - no text parsing.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseItemBuilder(@NotNull org.bukkit.inventory.ItemStack itemStack) -
Method Summary
Modifier and TypeMethodDescriptionamount(int amount) Sets the amount of items@NotNull ModalItemCreates aModalIteminstead of anItemStack@NotNull ModalItemasModalItem(@NotNull ModalAction<org.bukkit.event.inventory.InventoryClickEvent> action) Creates aModalIteminstead of anItemStack@NotNull org.bukkit.inventory.ItemStackbuild()Builds the item intoItemStackcolor(@NotNull org.bukkit.Color color) Color anItemStackprotected @NotNull net.kyori.adventure.text.ComponentdeserializeComponent(@NotNull Object obj) Deserializes the object with the right ComponentSerializer for the current MC versiondisenchant(@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 theItemStackglowSet the lore lines of an item Components should be pre-parsed by CoreFramework's TextUtilityConsumer for freely adding to the lore Components should be pre-parsed by CoreFramework's TextUtilitylore(@Nullable net.kyori.adventure.text.Component @NotNull ... lore) Set the lore lines of an item Components should be pre-parsed by CoreFramework's TextUtilitymodel(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 usingComponentComponent should be pre-parsed by CoreFramework's TextUtilityConsumer for applyingPersistentDataContainerto the item This method will only work on versions above 1.14Removes NBT tag from theItemStackprotected @NotNull ObjectserializeComponent(@NotNull net.kyori.adventure.text.Component component) Serializes the component with the right ComponentSerializer for the current MC version Expects Components to be pre-parsed by CoreFramework's TextUtilityprotected voidsetItemStack(@NotNull org.bukkit.inventory.ItemStack itemStack) Package private setter for the extended buildersprotected voidsetMeta(@NotNull org.bukkit.inventory.meta.ItemMeta meta) Package private setter for the extended buildersSets NBT tag to theItemStackSets NBT tag to theItemStackMakes theItemStackunbreakableunbreakable(boolean unbreakable) Sets the item as unbreakable
-
Constructor Details
-
BaseItemBuilder
protected BaseItemBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
-
-
Method Details
-
serializeComponent
@NotNull protected @NotNull Object serializeComponent(@NotNull @NotNull net.kyori.adventure.text.Component component) Serializes the component with the right ComponentSerializer for the current MC version Expects Components to be pre-parsed by CoreFramework's TextUtility- Parameters:
component- component to serialize (already parsed)- Returns:
- the serialized representation of the component
-
deserializeComponent
@NotNull protected @NotNull net.kyori.adventure.text.Component deserializeComponent(@NotNull @NotNull Object obj) Deserializes the object with the right ComponentSerializer for the current MC version- Parameters:
obj- object to deserialize- Returns:
- the component
-
name
@NotNull @Contract("_ -> this") public B name(@NotNull @NotNull net.kyori.adventure.text.Component name) Sets the display name of the item usingComponentComponent should be pre-parsed by CoreFramework's TextUtility- Parameters:
name- TheComponentname (pre-parsed)- 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 Components should be pre-parsed by CoreFramework's TextUtility- Parameters:
lore- Lore lines as varargs (pre-parsed)- 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 Components should be pre-parsed by CoreFramework's TextUtility- Parameters:
lore- AListwith the lore lines (pre-parsed)- 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 Components should be pre-parsed by CoreFramework's TextUtility- 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:
-
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
-
asModalItem
Creates aModalIteminstead of anItemStack- Returns:
- A
ModalItemwith noModalAction
-
asModalItem
@NotNull @Contract("_ -> new") public @NotNull ModalItem asModalItem(@NotNull @NotNull ModalAction<org.bukkit.event.inventory.InventoryClickEvent> action) Creates aModalIteminstead of anItemStack- Parameters:
action- TheModalActionto apply to the item- Returns:
- A
ModalItemwithModalAction
-
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
-