content: package org.allaymc.api.bossbar;
  
  import org.allaymc.api.AllayAPI;
  import org.jetbrains.annotations.Range;
  import org.jetbrains.annotations.UnmodifiableView;
  
  import java.util.Collection;
  
  /**
   * Represents a boss bar, a visual element often used in games to display progress, health, or status.
   * It supports customization options such as color, style, title, progress, and visibility behavior.
   *
   * @author daoge_cmd
   */
  public interface BossBar {
  
      AllayAPI.APIInstanceHolder<Factory> FACTORY = AllayAPI.APIInstanceHolder.create();
  
      /**
       * Create a new boss bar.
       *
       * @return the boss bar
       */
      static BossBar create() {
          return FACTORY.get().create();
      }
  
      /**
       * Add a viewer to the boss bar.
       *
       * @param viewer the viewer to add
       */
      void addViewer(BossBarViewer viewer);
  
      /**
       * Remove a viewer from the boss bar.
       *
       * @param viewer the viewer to remove
       */
      void removeViewer(BossBarViewer viewer);
  
      /**
       * Remove all viewers from the boss bar.
       */
      default void removeAllViewers() {
          getViewers().forEach(this::removeViewer);
      }
  
      /**
       * Get the viewers of the boss bar.
       *
       * @return the viewers of the boss bar
       */
      @UnmodifiableView
      Collection<BossBarViewer> getViewers();
  
      /**
       * Get the color of the boss bar.
       *
       * @return the color of the boss bar
       */
      BossBarColor getColor();
  
      /**
       * Set the color of the boss bar.
       *
       * @param color the color to set
       */
      void setColor(BossBarColor color);
  
      /**
       * Get the style of the boss bar.
       *
       * @return the style of the boss bar
       */
      BossBarStyle getStyle();
  
      /**
       * Set the style of the boss bar.
       *
       * @param style the style to set
       */
      void setStyle(BossBarStyle style);
  
      /**
       * Check if the boss bar will darken the sky
       *
       * @return {@code true} if the boss bar will darken the sky, otherwise {@code false}.
       */
      boolean isDarkenSky();
  
      /**
       * Set if the boss bar will darken the sky.
       *
       * @param darkenSky {@code true} if the boss bar will darken the sky, otherwise {@code false}
       */
      void setDarkenSky(boolean darkenSky);
  
      /**
       * Get the progress of the boss bar.
       *
       * @return the progress of the boss bar, between 0 and 1
       */
      @Range(from = 0, to = 1)
      float getProgress();
  
      /**
       * Set the progress of the boss bar.
       *
       * @param progress the progress to set, between 0 and 1
       */
      void setProgress(@Range(from = 0, to = 1) float progress);
  
      /**
       * Get the title of the boss bar.
       *
       * @return the title of the boss bar
       */
      String getTitle();
  
      /**
       * Set the title of the boss bar.
       *
       * @param name the title to set
       */
      void setTitle(String name);
  
      interface Factory {
          BossBar create();
      }
  }
  