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
FieldsModifier and TypeFieldDescriptionstatic final intThe max amount of lines a vanilla client can display at once. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddPlayer(@NotNull org.bukkit.entity.Player player) Adds a viewer to this Sidebar.default voidaddPlayers(@NotNull Collection<org.bukkit.entity.Player> players) Adds multiple viewers to this Sidebar.default voidClears all lines in this sidebar.voidclose()Closes this Sidebar.booleanclosed()@Nullable net.kyori.adventure.text.Componentline(@org.jetbrains.annotations.Range(from=0L, to=2147483646L) int line) Gets a line's value.default voidline(@org.jetbrains.annotations.Range(from=0L, to=2147483646L) int index, @Nullable net.kyori.adventure.text.ComponentLike value) Sets a line's value.voidline(@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 Localelocale()@org.jetbrains.annotations.Range(from=1L, to=2147483647L) intmaxLines()@NotNull Collection<org.bukkit.entity.Player>players()booleanremovePlayer(@NotNull org.bukkit.entity.Player player) Removes a viewer from this Sidebar.default voidremovePlayers(@NotNull Collection<org.bukkit.entity.Player> players) Removes multiple viewers from this Sidebar@NotNull net.kyori.adventure.text.Componenttitle()voidtitle(@NotNull net.kyori.adventure.text.ComponentLike title) Sets the title of the sidebar.
-
Field Details
-
MAX_LINES
static final int MAX_LINESThe 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
- 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.- 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.- Parameters:
index- line indexvalue- 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. Note that custom score formats are only supported in Minecraft 1.20.3+.- Parameters:
index- line indexvalue- new value, or null to hidescoreFormat- 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
- 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
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
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:
-