Package net.minestom.server.scoreboard
Class Sidebar
java.lang.Object
net.minestom.server.scoreboard.Sidebar
- All Implemented Interfaces:
Audience
,ForwardingAudience
,Pointered
,PacketGroupingAudience
,Scoreboard
,Viewable
Represents a sidebar which can contain up to 16
Sidebar.ScoreboardLine
.
In order to use it you need to create a new instance using the constructor Sidebar(String)
and create new lines
with createLine(ScoreboardLine)
. You can then add a Player
to the viewing list using addViewer(Player)
and remove him later with removeViewer(Player)
.
Lines can be modified using their respective identifier using
updateLineContent(String, Component)
and updateLineScore(String, int)
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
static class
This class is used to create a line for the sidebar.Nested classes/interfaces inherited from interface net.kyori.adventure.audience.ForwardingAudience
ForwardingAudience.Single
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a viewer.void
createLine
(@NotNull Sidebar.ScoreboardLine scoreboardLine) Creates a newSidebar.ScoreboardLine
.@Nullable Sidebar.ScoreboardLine
Gets aSidebar.ScoreboardLine
through the given identifier@NotNull Set
<Sidebar.ScoreboardLine> getLines()
Gets aSet
containing all the registered lines.@NotNull String
Gets the objective name of the scoreboard.Gets all the viewers of this viewable element.void
removeLine
(@NotNull String id) Removes aSidebar.ScoreboardLine
through the given identifierboolean
removeViewer
(@NotNull Player player) Removes a viewer.void
Deprecated.void
Changes theSidebar
titlevoid
updateLineContent
(@NotNull String id, @NotNull Component content) Updates aSidebar.ScoreboardLine
content through the given identifier.void
updateLineScore
(@NotNull String id, int score) Updates the score of aSidebar.ScoreboardLine
through the given identifierMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.kyori.adventure.audience.Audience
deleteMessage, openBook, removeResourcePacks, removeResourcePacks, removeResourcePacks, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendResourcePacks, sendResourcePacks, showTitle, stopSound
Methods inherited from interface net.kyori.adventure.audience.ForwardingAudience
clearResourcePacks, deleteMessage, filterAudience, forEachAudience, openBook, playSound, pointers, removeResourcePacks, removeResourcePacks, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendResourcePacks
Methods inherited from interface net.minestom.server.adventure.audience.PacketGroupingAudience
audiences, clearTitle, hideBossBar, playSound, playSound, playSound, resetTitle, sendActionBar, sendGroupedPacket, sendMessage, sendNotification, sendPlayerListHeaderAndFooter, sendTitlePart, showBossBar, stopSound
Methods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFrom
Methods inherited from interface net.minestom.server.scoreboard.Scoreboard
getCreationObjectivePacket, getCreationObjectivePacket, getDestructionObjectivePacket, getDisplayScoreboardPacket, getPlayers, updateScore
Methods inherited from interface net.minestom.server.Viewable
getViewersAsAudience, getViewersAsAudiences, isViewer, sendPacketsToViewers, sendPacketsToViewers, sendPacketToViewers, sendPacketToViewersAndSelf
-
Constructor Details
-
Sidebar
Deprecated.Creates a new sidebar- Parameters:
title
- The title of the sidebar
-
Sidebar
Creates a new sidebar- Parameters:
title
- The title of the sidebar
-
-
Method Details
-
setTitle
Deprecated.Changes theSidebar
title- Parameters:
title
- The new sidebar title
-
setTitle
Changes theSidebar
title- Parameters:
title
- The new sidebar title
-
createLine
Creates a newSidebar.ScoreboardLine
.- Parameters:
scoreboardLine
- the new scoreboard line- Throws:
IllegalStateException
- if the sidebar cannot take more lineIllegalArgumentException
- if the sidebar already contains the linescoreboardLine
or has a line with the same id
-
updateLineContent
Updates aSidebar.ScoreboardLine
content through the given identifier.- Parameters:
id
- The identifier of theSidebar.ScoreboardLine
content
- The new content for theSidebar.ScoreboardLine
-
updateLineScore
Updates the score of aSidebar.ScoreboardLine
through the given identifier- Parameters:
id
- The identifier of the teamscore
- The new score for theSidebar.ScoreboardLine
-
getLine
Gets aSidebar.ScoreboardLine
through the given identifier- Parameters:
id
- The identifier of the line- Returns:
- a
Sidebar.ScoreboardLine
ornull
-
getLines
Gets aSet
containing all the registered lines.- Returns:
- an unmodifiable set containing the sidebar's lines
-
removeLine
Removes aSidebar.ScoreboardLine
through the given identifier- Parameters:
id
- the identifier of theSidebar.ScoreboardLine
-
addViewer
Description copied from interface:Viewable
Adds a viewer. -
removeViewer
Description copied from interface:Viewable
Removes a viewer.- Specified by:
removeViewer
in interfaceViewable
- Parameters:
player
- the viewer to remove- Returns:
- true if the player has been removed, false otherwise (could be because he was not a viewer)
-
getViewers
Description copied from interface:Viewable
Gets all the viewers of this viewable element.- Specified by:
getViewers
in interfaceViewable
- Returns:
- A Set containing all the element's viewers
-
getObjectiveName
Description copied from interface:Scoreboard
Gets the objective name of the scoreboard.- Specified by:
getObjectiveName
in interfaceScoreboard
- Returns:
- the objective name
-
Sidebar(Component)