Skip to content

ScoreboardObjectiveHelper ​

com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper

Since1.2.9

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 ​

new ScoreboardObjectiveHelper(Objective o)#
Wraps the supplied scoreboard objective.

Parameters:

  • o: raw scoreboard objective to wrap

Methods ​

getDisplayName ​

getDisplayName(): TextHelperSince1.2.9#
Returns the objective's display title as a text wrapper, preserving its styling.
Returns: the text drawn above this objective's scores

getKnownPlayers ​

getKnownPlayers(): List<String>Since1.7.0#
Returns the scoreboard's tracked owner names, whether or not each has a score on this objective. Names are raw scoreboard names, and the returned list is newly built.
Returns: the names the scoreboard is tracking

getKnownPlayersDisplayNames ​

getKnownPlayersDisplayNames(): List<TextHelper>Since1.8.0#
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 ​

getName(): StringSince1.2.9#
Returns the objective's identifier, distinct from its display name.
Returns: name of scoreboard

getPlayerScores ​

getPlayerScores(): Map<String, Integer>#
Returns a new map of raw scoreboard owner names to their scores, including hidden entries. The map preserves the iteration order supplied by the scoreboard; modifying it does not modify scoreboard state.
Returns: player name to score map

getTexts ​

getTexts(): List<TextHelper>Since2.0.0#
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 ​

scoreToDisplayName(): Map<Integer, TextHelper>Since1.8.0#
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

toString ​

toString(): String#
Returns a diagnostic representation containing the objective identifier and display-name helper representation.
Returns: diagnostic representation of the scoreboard objective