Interface Sidebar


@NonExtendable public interface Sidebar
Represents a sidebar. To get an instance of this interface, use ScoreboardLibrary.createSidebar(). Note: this interface is not thread-safe, meaning you can only use it from one thread at a time, although it does not have to be the main thread.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The max amount of lines a vanilla client can display at once.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    addPlayer(@NotNull org.bukkit.entity.Player player)
    Adds a viewer to this Sidebar.
    default void
    addPlayers(@NotNull Collection<org.bukkit.entity.Player> players)
    Adds multiple viewers to this Sidebar.
    default void
    Clears all lines in this sidebar.
    void
    Closes this Sidebar.
    boolean
     
    @Nullable net.kyori.adventure.text.Component
    line(@org.jetbrains.annotations.Range(from=0L, to=2147483646L) int line)
    Gets a line's value, or null if line isn't set.
    default void
    line(@org.jetbrains.annotations.Range(from=0L, to=2147483646L) int index, @Nullable net.kyori.adventure.text.ComponentLike value)
    Sets a line's value.
    void
    line(@org.jetbrains.annotations.Range(from=0L, to=2147483646L) int index, @Nullable net.kyori.adventure.text.ComponentLike value, @Nullable ScoreFormat scoreFormat)
    Sets a line's value with a custom score format.
    @Nullable Locale
     
    @org.jetbrains.annotations.Range(from=1L, to=2147483647L) int
     
    @NotNull Collection<org.bukkit.entity.Player>
     
    boolean
    removePlayer(@NotNull org.bukkit.entity.Player player)
    Removes a viewer from this Sidebar.
    default void
    removePlayers(@NotNull Collection<org.bukkit.entity.Player> players)
    Removes multiple viewers from this Sidebar
    @NotNull net.kyori.adventure.text.Component
     
    void
    title(@NotNull net.kyori.adventure.text.ComponentLike title)
    Sets the title of the sidebar.
  • Field Details

    • MAX_LINES

      static final int MAX_LINES
      The max amount of lines a vanilla client can display at once.
      See Also:
  • Method Details

    • maxLines

      @org.jetbrains.annotations.Range(from=1L, to=2147483647L) int maxLines()
      Returns:
      max amount of lines this sidebar can have
    • locale

      @Nullable @Nullable Locale locale()
      Returns:
      locale which is used for translating TranslatableComponents, or null if it depends on each player's client locale.
      See Also:
    • line

      @Nullable @Nullable net.kyori.adventure.text.Component line(@org.jetbrains.annotations.Range(from=0L, to=2147483646L) int line)
      Gets a line's value, or null if line isn't set.
      Parameters:
      line - line index
      Returns:
      value of line, or null if unset
    • line

      default void line(@org.jetbrains.annotations.Range(from=0L, to=2147483646L) int index, @Nullable @Nullable net.kyori.adventure.text.ComponentLike value)
      Sets a line's value. A null value hides the line.
      Parameters:
      index - line index
      value - new value, or null to hide
    • line

      void line(@org.jetbrains.annotations.Range(from=0L, to=2147483646L) int index, @Nullable @Nullable net.kyori.adventure.text.ComponentLike value, @Nullable @Nullable ScoreFormat scoreFormat)
      Sets a line's value with a custom score format. A null value hides the line. Note that custom score formats are only supported in Minecraft 1.20.3+.
      Parameters:
      index - line index
      value - new value, or null to hide
      scoreFormat - score format
    • clearLines

      default void clearLines()
      Clears all lines in this sidebar.
    • title

      @NotNull @NotNull net.kyori.adventure.text.Component title()
      Returns:
      title of the sidebar, defaults to Component.empty()
    • title

      void title(@NotNull @NotNull net.kyori.adventure.text.ComponentLike title)
      Sets the title of the sidebar.
      Parameters:
      title - title
    • players

      @NotNull @NotNull Collection<org.bukkit.entity.Player> players()
      Returns:
      unmodifiable collection of viewers in this Sidebar
      See Also:
    • addPlayer

      boolean addPlayer(@NotNull @NotNull org.bukkit.entity.Player player)
      Adds a viewer to this Sidebar. Note that a player can only see a single Sidebar at a time. The Sidebar will internally be added to a queue for this player who will start seeing it once they are removed from all previous Sidebars.
      Parameters:
      player - player to add
      Returns:
      whether the player was added
    • addPlayers

      default void addPlayers(@NotNull @NotNull Collection<org.bukkit.entity.Player> players)
      Adds multiple viewers to this Sidebar.
      Parameters:
      players - viewers to add
      See Also:
    • removePlayer

      boolean removePlayer(@NotNull @NotNull org.bukkit.entity.Player player)
      Removes a viewer from this Sidebar.
      Parameters:
      player - viewer to remove
      Returns:
      whether the viewer was removed
    • removePlayers

      default void removePlayers(@NotNull @NotNull Collection<org.bukkit.entity.Player> players)
      Removes multiple viewers from this Sidebar
      Parameters:
      players - viewers to remove
    • close

      void close()
      Closes this Sidebar. This must be called once you no longer need this Sidebar to prevent a memory leak.
    • closed

      boolean closed()
      Returns:
      Whether this sidebar is closed
      See Also: