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
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic classThis class is used to create a line for the sidebar.Nested classes/interfaces inherited from interface ForwardingAudience
ForwardingAudience.Single -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a viewer.voidcreateLine(Sidebar.ScoreboardLine scoreboardLine) Creates a newSidebar.ScoreboardLine.Gets aSidebar.ScoreboardLinethrough the given identifiergetLines()Gets aSetcontaining all the registered lines.Gets the objective name of the scoreboard.getTitle()Gets theSidebartitleGets all the viewers of this viewable element.voidremoveLine(String id) Removes aSidebar.ScoreboardLinethrough the given identifierbooleanremoveViewer(Player player) Removes a viewer.voidDeprecated.voidChanges theSidebartitlevoidupdateLineContent(String id, Component content) Updates aSidebar.ScoreboardLinecontent through the given identifier.voidupdateLineNumberFormat(String id, Sidebar.NumberFormat numberFormat) Updates aSidebar.ScoreboardLinenumber format through the given identifier.voidupdateLineScore(String id, int score) Updates the score of aSidebar.ScoreboardLinethrough the given identifierMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Audience
deleteMessage, openBook, removeResourcePacks, removeResourcePacks, removeResourcePacks, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendResourcePacks, sendResourcePacks, showTitle, stopSoundMethods inherited from interface ForwardingAudience
clearResourcePacks, closeDialog, deleteMessage, filterAudience, forEachAudience, openBook, playSound, pointers, removeResourcePacks, removeResourcePacks, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendResourcePacks, showDialogMethods inherited from interface PacketGroupingAudience
audiences, clearTitle, hideBossBar, playSound, playSound, playSound, resetTitle, sendActionBar, sendGroupedPacket, sendMessage, sendNotification, sendPlayerListHeaderAndFooter, sendTitlePart, showBossBar, stopSoundMethods inherited from interface Pointered
get, getOrDefault, getOrDefaultFromMethods inherited from interface Scoreboard
getCreationObjectivePacket, getCreationObjectivePacket, getDestructionObjectivePacket, getDisplayScoreboardPacket, getPlayers, updateScoreMethods inherited from interface Viewable
getViewersAsAudience, getViewersAsAudiences, isViewer, sendPacketsToViewers, sendPacketsToViewers, sendPacketToViewers, sendPacketToViewersAndSelf
-
Constructor Details
-
Sidebar
Deprecated.Creates a new sidebar- Parameters:
title- The title of the sidebar
-
Sidebar
-
-
Method Details
-
setTitle
-
getTitle
-
setTitle
-
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 linescoreboardLineor has a line with the same id
-
updateLineContent
Updates aSidebar.ScoreboardLinecontent through the given identifier.- Parameters:
id- The identifier of theSidebar.ScoreboardLinecontent- The new content for theSidebar.ScoreboardLine
-
updateLineScore
Updates the score of aSidebar.ScoreboardLinethrough the given identifier- Parameters:
id- The identifier of the teamscore- The new score for theSidebar.ScoreboardLine
-
updateLineNumberFormat
Updates aSidebar.ScoreboardLinenumber format through the given identifier.- Parameters:
id- The identifier of theSidebar.ScoreboardLinenumberFormat- The new number format for theSidebar.ScoreboardLine
-
getLine
Gets aSidebar.ScoreboardLinethrough the given identifier- Parameters:
id- The identifier of the line- Returns:
- a
Sidebar.ScoreboardLineornull
-
getLines
Gets aSetcontaining all the registered lines.- Returns:
- an unmodifiable set containing the sidebar's lines
-
removeLine
Removes aSidebar.ScoreboardLinethrough the given identifier- Parameters:
id- the identifier of theSidebar.ScoreboardLine
-
addViewer
-
removeViewer
Description copied from interface:ViewableRemoves a viewer.- Specified by:
removeViewerin 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:ViewableGets all the viewers of this viewable element.- Specified by:
getViewersin interfaceViewable- Returns:
- A Set containing all the element's viewers
-
getObjectiveName
Description copied from interface:ScoreboardGets the objective name of the scoreboard.- Specified by:
getObjectiveNamein interfaceScoreboard- Returns:
- the objective name
-
Sidebar(Component)