Package org.bukkit

Class FireworkEffect.Builder

java.lang.Object
org.bukkit.FireworkEffect.Builder
Enclosing class:
FireworkEffect

public static final class FireworkEffect.Builder
extends java.lang.Object
This is a builder for FireworkEffects.
See Also:
FireworkEffect.builder()
  • Method Details

    • with

      public FireworkEffect.Builder with​(FireworkEffect.Type type) throws java.lang.IllegalArgumentException
      Specify the type of the firework effect.
      Parameters:
      type - The effect type
      Returns:
      This object, for chaining
      Throws:
      java.lang.IllegalArgumentException - If type is null
    • withFlicker

      public FireworkEffect.Builder withFlicker()
      Add a flicker to the firework effect.
      Returns:
      This object, for chaining
    • flicker

      public FireworkEffect.Builder flicker​(boolean flicker)
      Set whether the firework effect should flicker.
      Parameters:
      flicker - true if it should flicker, false if not
      Returns:
      This object, for chaining
    • withTrail

      public FireworkEffect.Builder withTrail()
      Add a trail to the firework effect.
      Returns:
      This object, for chaining
    • trail

      public FireworkEffect.Builder trail​(boolean trail)
      Set whether the firework effect should have a trail.
      Parameters:
      trail - true if it should have a trail, false for no trail
      Returns:
      This object, for chaining
    • withColor

      public FireworkEffect.Builder withColor​(Color color) throws java.lang.IllegalArgumentException
      Add a primary color to the firework effect.
      Parameters:
      color - The color to add
      Returns:
      This object, for chaining
      Throws:
      java.lang.IllegalArgumentException - If color is null
    • withColor

      public FireworkEffect.Builder withColor​(Color... colors) throws java.lang.IllegalArgumentException
      Add several primary colors to the firework effect.
      Parameters:
      colors - The colors to add
      Returns:
      This object, for chaining
      Throws:
      java.lang.IllegalArgumentException - If colors is null
      java.lang.IllegalArgumentException - If any color is null (may be thrown after changes have occurred)
    • withColor

      public FireworkEffect.Builder withColor​(java.lang.Iterable<?> colors) throws java.lang.IllegalArgumentException
      Add several primary colors to the firework effect.
      Parameters:
      colors - An iterable object whose iterator yields the desired colors
      Returns:
      This object, for chaining
      Throws:
      java.lang.IllegalArgumentException - If colors is null
      java.lang.IllegalArgumentException - If any color is null (may be thrown after changes have occurred)
    • withFade

      public FireworkEffect.Builder withFade​(Color color) throws java.lang.IllegalArgumentException
      Add a fade color to the firework effect.
      Parameters:
      color - The color to add
      Returns:
      This object, for chaining
      Throws:
      java.lang.IllegalArgumentException - If colors is null
      java.lang.IllegalArgumentException - If any color is null (may be thrown after changes have occurred)
    • withFade

      public FireworkEffect.Builder withFade​(Color... colors) throws java.lang.IllegalArgumentException
      Add several fade colors to the firework effect.
      Parameters:
      colors - The colors to add
      Returns:
      This object, for chaining
      Throws:
      java.lang.IllegalArgumentException - If colors is null
      java.lang.IllegalArgumentException - If any color is null (may be thrown after changes have occurred)
    • withFade

      public FireworkEffect.Builder withFade​(java.lang.Iterable<?> colors) throws java.lang.IllegalArgumentException
      Add several fade colors to the firework effect.
      Parameters:
      colors - An iterable object whose iterator yields the desired colors
      Returns:
      This object, for chaining
      Throws:
      java.lang.IllegalArgumentException - If colors is null
      java.lang.IllegalArgumentException - If any color is null (may be thrown after changes have occurred)
    • build

      public FireworkEffect build()
      Create a FireworkEffect from the current contents of this builder.

      To successfully build, you must have specified at least one color.

      Returns:
      The representative firework effect