Class FireworkBuilder
java.lang.Object
io.github.lucfr1746.llibrary.itemstack.ItemBuilder
io.github.lucfr1746.llibrary.itemstack.FireworkBuilder
The
FireworkBuilder
class extends ItemBuilder
to provide
additional functionality for modifying FireworkMeta
of an ItemStack
.
This class allows adding, removing, and customizing firework effects, as well as setting firework power.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aFireworkBuilder
with a new firework rocket.FireworkBuilder
(@NotNull org.bukkit.inventory.ItemStack itemStack) Constructs aFireworkBuilder
using an existingItemStack
. -
Method Summary
Modifier and TypeMethodDescriptionaddEffect
(@NotNull org.bukkit.FireworkEffect effect) Adds a single firework effect to the firework.addEffects
(@NotNull Iterable<org.bukkit.FireworkEffect> effects) Adds a collection of firework effects to the firework.addEffects
(@NotNull org.bukkit.FireworkEffect... effects) Adds multiple firework effects to the firework.Clears all firework effects from the firework.List
<org.bukkit.FireworkEffect> Gets the list of firework effects.int
Gets the number of firework effects.int
getPower()
Gets the current power of the firework.boolean
Checks if the firework has any effects.boolean
hasPower()
Checks if the firework has a set power value.removeEffect
(int index) Removes a firework effect at the specified index.setPower
(int power) Sets the power of the firework, determining its flight duration.Methods inherited from class io.github.lucfr1746.llibrary.itemstack.ItemBuilder
addAttributeModifier, addEnchant, addEnchant, addEnchant, addItemFlags, addLore, build, getAmount, getAttributeModifiers, getAttributeModifiers, getAttributeModifiers, getCustomModelData, getDamageResistant, getDisplayName, getEnchantable, getEnchantLevel, getEnchantmentGlintOverride, getEnchants, getEquippableComponent, getFoodComponent, getItemFlags, getItemMeta, getItemModel, getJukeboxPlayableComponent, getMaxStackSize, getRarity, getToolComponent, getTooltipStyle, getTranslationKey, getType, getUseCooldownComponent, getUseRemainder, hasAttributeModifiers, hasConflictingEnchant, hasCustomModelData, hasDamageResistant, hasEnchant, hasEnchantable, hasEnchantmentGlintOverride, hasEnchants, hasEquippableComponent, hasFoodComponent, hasItemFlag, hasItemModel, hasJukeboxPlayableComponent, hasMaxStackSize, hasRarity, hasToolComponent, hasTooltipStyle, hasUseCooldownComponent, hasUseRemainder, hideAllItemFlags, insertLore, isGlider, isHideTooltip, isUnbreakable, removeAttributeModifier, removeAttributeModifier, removeAttributeModifier, removeEnchant, removeEnchants, removeItemFlags, replaceLore, setAmount, setAttributeModifiers, setCustomModelData, setDamageResistant, setDisplayName, setEnchantable, setEnchantmentGlintOverride, setEquippableComponent, setEquippableComponent, setFood, setFoodComponent, setGlider, setHideTooltip, setItemModel, setItemModel, setJukeboxPlayableComponent, setJukeboxPlayableComponent, setJukeboxPlayableComponent, setLores, setLores, setMaxStackSize, setRarity, setToolComponent, setToolComponent, setTooltipStyle, setTooltipStyle, setType, setUnbreakable, setUseCooldownComponent, setUseCooldownComponent, setUseCooldownComponent, setUseRemainder
-
Constructor Details
-
FireworkBuilder
public FireworkBuilder()Constructs aFireworkBuilder
with a new firework rocket. -
FireworkBuilder
public FireworkBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) Constructs aFireworkBuilder
using an existingItemStack
.- Parameters:
itemStack
- the item stack to modify- Throws:
IllegalArgumentException
- if the item's meta is not an instance ofFireworkMeta
-
-
Method Details
-
addEffect
Adds a single firework effect to the firework.- Parameters:
effect
- the firework effect to add- Returns:
- this
FireworkBuilder
instance for method chaining
-
addEffects
Adds multiple firework effects to the firework.- Parameters:
effects
- the firework effects to add- Returns:
- this
FireworkBuilder
instance for method chaining
-
addEffects
Adds a collection of firework effects to the firework.- Parameters:
effects
- the iterable collection of firework effects to add- Returns:
- this
FireworkBuilder
instance for method chaining
-
removeEffect
Removes a firework effect at the specified index.- Parameters:
index
- the index of the effect to remove- Returns:
- this
FireworkBuilder
instance for method chaining
-
clearEffects
Clears all firework effects from the firework.- Returns:
- this
FireworkBuilder
instance for method chaining
-
getEffects
Gets the list of firework effects.- Returns:
- a list of firework effects
-
getEffectsSize
public int getEffectsSize()Gets the number of firework effects.- Returns:
- the number of firework effects
-
setPower
Sets the power of the firework, determining its flight duration.- Parameters:
power
- the firework's power (0-127)- Returns:
- this
FireworkBuilder
instance for method chaining - Throws:
IllegalArgumentException
- if power is out of range
-
getPower
public int getPower()Gets the current power of the firework.- Returns:
- the power of the firework
-
hasEffects
public boolean hasEffects()Checks if the firework has any effects.- Returns:
- true if the firework has effects, false otherwise
-
hasPower
public boolean hasPower()Checks if the firework has a set power value.- Returns:
- true if the firework has a power set, false otherwise
-