# ScoreboardObjectiveHelper

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

**Since:** 1.2.9

An objective holds scores for scoreboard owners and can be displayed in a scoreboard slot.  
 
 [getPlayerScores()](#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_getPlayerScores-) maps raw owner names to scores; repeated names overwrite earlier
 entries. [getTexts()](#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_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 {#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_constructor-Objective-}

```js
new ScoreboardObjectiveHelper(Objective o)
```

Wraps the supplied scoreboard objective.

**Parameters:**
- `o`: raw scoreboard objective to wrap

## Methods

### getDisplayName {#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_getDisplayName-}

```js
getDisplayName(): TextHelper
```

Returns the objective's display title as a text wrapper, preserving its styling.

**Returns:** the text drawn above this objective's scores

**Since:** 1.2.9

### getKnownPlayers {#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_getKnownPlayers-}

```js
getKnownPlayers(): List<String>
```

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

**Since:** 1.7.0

### getKnownPlayersDisplayNames {#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_getKnownPlayersDisplayNames-}

```js
getKnownPlayersDisplayNames(): List<TextHelper>
```

Returns display names for tracked owners in [getKnownPlayers()](#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_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

**Since:** 1.8.0

### getName {#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_getName-}

```js
getName(): String
```

Returns the objective's identifier, distinct from its display name.

**Returns:** name of scoreboard

**Since:** 1.2.9

### getPlayerScores {#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_getPlayerScores-}

```js
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 {#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_getTexts-}

```js
getTexts(): List<TextHelper>
```

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()](#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_getPlayerScores-) or [scoreToDisplayName()](#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_scoreToDisplayName-) to retrieve them.

**Returns:** the names the sidebar draws for this objective, highest score first

**Since:** 2.1.0

### scoreToDisplayName {#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_scoreToDisplayName-}

```js
scoreToDisplayName(): Map<Integer, TextHelper>
```

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

**Since:** 1.8.0

### toString {#com.jsmacrosce.jsmacros.client.api.helper.screen.ScoreboardObjectiveHelper_toString-}

```js
toString(): String
```

Returns a diagnostic representation containing the objective identifier and display-name helper representation.

**Returns:** diagnostic representation of the scoreboard objective
