Class FireworkBuilder

java.lang.Object
io.github.lucfr1746.llibrary.itemstack.ItemBuilder
io.github.lucfr1746.llibrary.itemstack.FireworkBuilder

public class FireworkBuilder extends ItemBuilder
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 Details

    • FireworkBuilder

      public FireworkBuilder()
      Constructs a FireworkBuilder with a new firework rocket.
    • FireworkBuilder

      public FireworkBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Constructs a FireworkBuilder using an existing ItemStack.
      Parameters:
      itemStack - the item stack to modify
      Throws:
      IllegalArgumentException - if the item's meta is not an instance of FireworkMeta
  • Method Details

    • addEffect

      public FireworkBuilder addEffect(@NotNull @NotNull org.bukkit.FireworkEffect effect)
      Adds a single firework effect to the firework.
      Parameters:
      effect - the firework effect to add
      Returns:
      this FireworkBuilder instance for method chaining
    • addEffects

      public FireworkBuilder addEffects(@NotNull @NotNull org.bukkit.FireworkEffect... effects)
      Adds multiple firework effects to the firework.
      Parameters:
      effects - the firework effects to add
      Returns:
      this FireworkBuilder instance for method chaining
    • addEffects

      public FireworkBuilder addEffects(@NotNull @NotNull Iterable<org.bukkit.FireworkEffect> effects)
      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

      public FireworkBuilder removeEffect(int index)
      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

      public FireworkBuilder clearEffects()
      Clears all firework effects from the firework.
      Returns:
      this FireworkBuilder instance for method chaining
    • getEffects

      public List<org.bukkit.FireworkEffect> 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

      public FireworkBuilder setPower(int power)
      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