ScoreboardObjectiveHelper
com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper
An objective holds scores for scoreboard owners and can be displayed in a scoreboard slot.
getPlayerScores() maps raw owner names to scores; repeated names overwrite earlier entries. getTexts() omits hidden entries,
orders the rest by descending score then case-insensitive owner name, and limits the result to fifteen. Both display-name methods apply team formatting.
js
const boards = World.getScoreboards();
if (boards !== null) {
const sidebar = boards.getCurrentScoreboard();
if (sidebar !== null) {
Chat.log(`${sidebar.getName()}: ${sidebar.getDisplayName().getString()}`);
// the fifteen the sidebar would draw, highest first
const texts = sidebar.getTexts();
for (let i = 0; i !== texts.size(); i += 1) {
Chat.log(` ${texts.get(i).getString()}`);
}
// scores keyed by raw owner name (repeated names overwrite)
for (const entry of sidebar.getPlayerScores().entrySet()) {
Chat.log(` ${entry.getKey()} on ${entry.getValue()}`);
}
}
}Constructors
new ScoreboardObjectiveHelper
Methods
getDisplayName
Returns the objective's display title as a text wrapper, preserving its styling.
Returns: the text drawn above this objective's scores
getKnownPlayers
getKnownPlayersDisplayNames
Returns display names for tracked owners in getKnownPlayers() order. Owners without a custom display name use their scoreboard name as literal text; team formatting is not applied.
Returns: the display name for each tracked player
getName
getPlayerScores
getTexts
Returns team-formatted owner names for visible entries, ordered by descending score then case-insensitive owner name and limited to fifteen. Scores are not included; use getPlayerScores() or scoreToDisplayName() to retrieve them.
Returns: the names the sidebar draws for this objective, highest score first
scoreToDisplayName
Returns a new map from score to team-formatted owner text. Since the score is the key, owners with equal scores overwrite one another; iteration is not sorted.
Returns: a map from score to the name to display for it