Class BossBarManager

java.lang.Object
net.minestom.server.adventure.bossbar.BossBarManager

public class BossBarManager extends Object
Manages all boss bars known to this Minestom instance. Although this class can be used to show boss bars to players, it is preferable to use the boss bar methods in the Audience class instead.

This implementation is heavily based on Velocity's boss bar management system.

See Also:
  • Constructor Details

  • Method Details

    • addBossBar

      public void addBossBar(@NotNull @NotNull Player player, @NotNull @NotNull BossBar bar)
      Adds the specified player to the boss bar's viewers and spawns the boss bar, registering the boss bar if needed.
      Parameters:
      player - the intended viewer
      bar - the boss bar to show
    • removeBossBar

      public void removeBossBar(@NotNull @NotNull Player player, @NotNull @NotNull BossBar bar)
      Removes the specified player from the boss bar's viewers and despawns the boss bar.
      Parameters:
      player - the intended viewer
      bar - the boss bar to hide
    • addBossBar

      public void addBossBar(@NotNull @NotNull Collection<Player> players, @NotNull @NotNull BossBar bar)
      Adds the specified players to the boss bar's viewers and spawns the boss bar, registering the boss bar if needed.
      Parameters:
      players - the players
      bar - the boss bar
    • removeBossBar

      public void removeBossBar(@NotNull @NotNull Collection<Player> players, @NotNull @NotNull BossBar bar)
      Removes the specified players from the boss bar's viewers and despawns the boss bar.
      Parameters:
      players - the intended viewers
      bar - the boss bar to hide
    • destroyBossBar

      public void destroyBossBar(@NotNull @NotNull BossBar bossBar)
      Completely destroys a boss bar, removing it from all players.
      Parameters:
      bossBar - the boss bar
    • removeAllBossBars

      public void removeAllBossBars(@NotNull @NotNull Player player)
      Removes a player from all of their boss bars. Note that this method does not send any removal packets to the player. It is meant to be used when a player is disconnecting from the server.
      Parameters:
      player - the player
    • getPlayerBossBars

      @NotNull public @NotNull Collection<BossBar> getPlayerBossBars(@NotNull @NotNull Player player)
      Gets a collection of all boss bars currently visible to a given player.
      Parameters:
      player - the player
      Returns:
      the boss bars
    • getBossBarViewers

      @NotNull public @NotNull Collection<Player> getBossBarViewers(@NotNull @NotNull BossBar bossBar)
      Gets all the players for whom the given boss bar is currently visible.
      Parameters:
      bossBar - the boss bar
      Returns:
      the players