Class Scoreboard
Objectives can be divided in two states: inactive and active. Inactive objectives is the default state for objectives that have been created using the SetObjective packet. Scores can be added, updated and removed, but as long as they're inactive they aren't shown to the player. An objective becomes active when a SetDisplayObjective packet is received, which contains the slot that the objective should be displayed at.
While Bedrock can handle showing one objective on multiple slots at the same time, we have to help Bedrock a bit for example by limiting the amount of sidebar scores to the amount of lines that can be shown (otherwise Bedrock may lag) and only showing online players in the playerlist (otherwise it's too cluttered.) This fact is the biggest contributor for the class being structured like it is.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddisplayObjective(String objectiveId, org.geysermc.mcprotocollib.protocol.data.game.scoreboard.ScoreboardPosition slot) voidentityRegistered(Entity entity) voidentityRemoved(Entity entity) getObjective(String objectiveName) Map<org.geysermc.mcprotocollib.protocol.data.game.scoreboard.ScoreboardPosition, DisplaySlot> Required to preserve vanilla behavior, which also uses a map.getTeamFor(String playerNameOrEntityUuid) longnextId()voidonUpdate()voidplayerRegistered(PlayerEntity player) voidplayerRemoved(PlayerEntity player) @Nullable ObjectiveregisterNewObjective(String objectiveId) voidregisterNewTeam(String teamName, String[] players, net.kyori.adventure.text.Component name, net.kyori.adventure.text.Component prefix, net.kyori.adventure.text.Component suffix, org.geysermc.mcprotocollib.protocol.data.game.scoreboard.NameTagVisibility visibility, org.geysermc.mcprotocollib.protocol.data.game.scoreboard.TeamColor color) voidremoveObjective(Objective objective) voidvoidremoveTeam(String teamName) voidresetPlayerScores(String playerNameOrEntityUuid) session()voidsetTeamFor(Team team, Set<String> entities)
-
Constructor Details
-
Scoreboard
-
-
Method Details
-
removeScoreboard
public void removeScoreboard() -
registerNewObjective
-
displayObjective
public void displayObjective(String objectiveId, org.geysermc.mcprotocollib.protocol.data.game.scoreboard.ScoreboardPosition slot) -
registerNewTeam
public void registerNewTeam(String teamName, String[] players, net.kyori.adventure.text.Component name, net.kyori.adventure.text.Component prefix, net.kyori.adventure.text.Component suffix, org.geysermc.mcprotocollib.protocol.data.game.scoreboard.NameTagVisibility visibility, org.geysermc.mcprotocollib.protocol.data.game.scoreboard.TeamColor color) -
onUpdate
public void onUpdate() -
getObjective
-
removeObjective
-
resetPlayerScores
-
getTeam
-
getTeamFor
-
removeTeam
-
getTeamNames
-
playerRegistered
-
playerRemoved
-
entityRegistered
-
entityRemoved
-
setTeamFor
-
nextId
public long nextId() -
session
-
getObjectiveSlots
public Map<org.geysermc.mcprotocollib.protocol.data.game.scoreboard.ScoreboardPosition,DisplaySlot> getObjectiveSlots() -
getPlayerToTeam
Required to preserve vanilla behavior, which also uses a map. Otherwise, for example, if TAB has a team for a player and vanilla has a team, "race conditions" that do not match vanilla could occur.
-