Package net.minestom.server.scoreboard
Class Sidebar
java.lang.Object
net.minestom.server.scoreboard.Sidebar
- All Implemented Interfaces:
net.kyori.adventure.audience.Audience,net.kyori.adventure.audience.ForwardingAudience,net.kyori.adventure.pointer.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(Component) 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 classstatic classThis class is used to create a line for the sidebar.Nested classes/interfaces inherited from interface net.kyori.adventure.audience.ForwardingAudience
net.kyori.adventure.audience.ForwardingAudience.Single -
Constructor Summary
ConstructorsConstructorDescriptionSidebar(@NotNull net.kyori.adventure.text.Component title) Creates a new sidebar -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a viewer.voidcreateLine(@NotNull Sidebar.ScoreboardLine scoreboardLine) Creates a newSidebar.ScoreboardLine.@Nullable Sidebar.ScoreboardLineGets aSidebar.ScoreboardLinethrough the given identifier@NotNull Set<Sidebar.ScoreboardLine> getLines()Gets aSetcontaining all the registered lines.@NotNull StringGets the objective name of the scoreboard.Gets all the viewers of this viewable element.voidremoveLine(@NotNull String id) Removes aSidebar.ScoreboardLinethrough the given identifierbooleanremoveViewer(@NotNull Player player) Removes a viewer.voidsetTitle(@NotNull net.kyori.adventure.text.Component title) Changes theSidebartitlevoidupdateLineContent(@NotNull String id, @NotNull net.kyori.adventure.text.Component content) Updates aSidebar.ScoreboardLinecontent through the given identifier.voidupdateLineScore(@NotNull String id, int score) Updates the score of aSidebar.ScoreboardLinethrough the given identifierMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, stopSoundMethods inherited from interface net.kyori.adventure.audience.ForwardingAudience
clearResourcePacks, deleteMessage, filterAudience, forEachAudience, openBook, playSound, pointers, removeResourcePacks, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendResourcePacksMethods inherited from interface net.minestom.server.adventure.audience.PacketGroupingAudience
audiences, clearTitle, hideBossBar, playSound, playSound, playSound, resetTitle, sendActionBar, sendGroupedPacket, sendMessage, sendPlayerListHeaderAndFooter, sendTitlePart, showBossBar, stopSoundMethods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFromMethods inherited from interface net.minestom.server.scoreboard.Scoreboard
getCreationObjectivePacket, getDestructionObjectivePacket, getDisplayScoreboardPacket, getPlayers, updateScoreMethods inherited from interface net.minestom.server.Viewable
getViewersAsAudience, getViewersAsAudiences, isViewer, sendPacketsToViewers, sendPacketsToViewers, sendPacketToViewers, sendPacketToViewersAndSelf
-
Constructor Details
-
Sidebar
public Sidebar(@NotNull @NotNull net.kyori.adventure.text.Component title) Creates a new sidebar- Parameters:
title- The title of the sidebar
-
-
Method Details
-
setTitle
public void setTitle(@NotNull @NotNull net.kyori.adventure.text.Component title) Changes theSidebartitle- 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 linescoreboardLineor has a line with the same id
-
updateLineContent
public void updateLineContent(@NotNull @NotNull String id, @NotNull @NotNull net.kyori.adventure.text.Component content) 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
-
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
Description copied from interface:ViewableAdds a viewer. -
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
-