Package net.minestom.server.scoreboard
Class Sidebar
java.lang.Object
net.minestom.server.scoreboard.Sidebar
- All Implemented Interfaces:
Scoreboard
,Viewable
public class Sidebar extends java.lang.Object implements Scoreboard
Represents a sidebar which can contain up to 16
Sidebar.ScoreboardLine
.
In order to use it you need to create a new instance using 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, ColoredText)
and updateLineScore(String, int)
.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Sidebar.ScoreboardLine
This class is used to create a line for the sidebar. -
Constructor Summary
Constructors Constructor Description Sidebar(java.lang.String title)
Creates a new sidebar -
Method Summary
Modifier and Type Method Description boolean
addViewer(Player player)
Adds a viewer.void
createLine(Sidebar.ScoreboardLine scoreboardLine)
Creates a newSidebar.ScoreboardLine
.Sidebar.ScoreboardLine
getLine(java.lang.String id)
Gets aSidebar.ScoreboardLine
through the given identifierjava.lang.String
getObjectiveName()
Gets the objective name of the scoreboardjava.util.Set<Player>
getViewers()
Gets all the viewers of this viewable element.void
removeLine(java.lang.String id)
Removes aSidebar.ScoreboardLine
through the given identifierboolean
removeViewer(Player player)
Removes a viewer.void
setTitle(java.lang.String title)
Changes theSidebar
titlevoid
updateLineContent(java.lang.String id, ColoredText content)
Updates aSidebar.ScoreboardLine
content through the given identifier.void
updateLineScore(java.lang.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.minestom.server.scoreboard.Scoreboard
getCreationObjectivePacket, getDestructionObjectivePacket, getDisplayScoreboardPacket, updateScore
Methods inherited from interface net.minestom.server.Viewable
isViewer, sendPacketsToViewers, sendPacketToViewers, sendPacketToViewersAndSelf
-
Constructor Details
-
Sidebar
public Sidebar(java.lang.String title)Creates a new sidebar- Parameters:
title
- The title of the sidebar
-
-
Method Details
-
setTitle
public void setTitle(java.lang.String title)Changes theSidebar
title- Parameters:
title
- The new sidebar title
-
createLine
Creates a newSidebar.ScoreboardLine
.- Parameters:
scoreboardLine
- the new scoreboard line- Throws:
java.lang.IllegalStateException
- if the sidebar cannot take more linejava.lang.IllegalArgumentException
- 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
public void updateLineScore(java.lang.String id, int score)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
-
removeLine
public void removeLine(java.lang.String id)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
public java.lang.String getObjectiveName()Description copied from interface:Scoreboard
Gets the objective name of the scoreboard- Specified by:
getObjectiveName
in interfaceScoreboard
- Returns:
- the objective name
-