# TeamHelper

`com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper`

**Since:** 1.3.0

Exposes a scoreboard team and its display, membership, color, and team-rule settings.  
 Obtain a team from a player entry or from [ScoreboardsHelper.getTeams()](ScoreboardsHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.ScoreboardsHelper_getTeams-).  
 
 Team colors have distinct representations: [getColorFormat()](#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getColorFormat-) returns formatting,  
 [getColorIndex()](#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getColorIndex-) its index, [getColorValue()](#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getColorValue-) its packed value (or `-1`
 when unset), and [getColorName()](#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getColorName-) its name.  
 ```js
const board = World.getScoreboards();  
if (board !== null) {
  const teams = board.getTeams();  
  for (let i = 0; i !== teams.size(); i += 1) {
    const team = teams.get(i);  
    Chat.log(`${team.getName()} is shown as ${team.getDisplayName().getString()}`);  
    Chat.log(`  colour ${team.getColorName()}, value ${team.getColorValue()}`);  
    Chat.log(`  ${team.getPlayerList().size()} members, prefix ${team.getPrefix()}`);  
  }
}

// and the team a particular player is on, which is null when they are on none
const entry = World.getPlayerEntry("Notch");  
if (entry !== null) {
  const team = entry.getTeam();  
  Chat.log(team === null ? "not in a team" : `on ${team.getName()}`);  
}
 ```

## Constructors

### new TeamHelper {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_constructor-PlayerTeam-}

```js
new TeamHelper(PlayerTeam t)
```

Wraps the supplied raw scoreboard team without changing it.

**Parameters:**
- `t`: raw scoreboard team to wrap

## Methods

### deathMessageVisibility {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_deathMessageVisibility-}

```js
deathMessageVisibility(): String
```

Returns the death-message visibility rule, configured separately from
 [nametagVisibility()](#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_nametagVisibility-).

**Returns:** this team's death message visibility rule.

**Since:** 1.3.0

### getCollisionRule {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getCollisionRule-}

```js
getCollisionRule(): String
```

Returns the collision rule name: `always`, `never`, `pushOtherTeams`, or
 `pushOwnTeam`.

**Returns:** the team's collision rule.

**Since:** 1.3.0

### getColorFormat {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getColorFormat-}

```js
getColorFormat(): FormattingHelper
```

Returns the team's color formatting. An unset team color is represented by reset formatting;  
 use [getColorValue()](#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getColorValue-) to distinguish it from a set color.

**Returns:** the formatting of this team's color.

**Since:** 1.8.4

### getColorIndex {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getColorIndex-}

```js
getColorIndex(): int
```

Returns the team's color index, distinct from the packed value returned by
 [getColorValue()](#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getColorValue-).

**Returns:** the color index of this team.

**Since:** 1.8.4

### getColorName {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getColorName-}

```js
getColorName(): String
```

Returns the team's color name.

**Returns:** the name of this team's color.

**Since:** 1.8.4

### getColorValue {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getColorValue-}

```js
getColorValue(): int
```

Returns the packed color value, or `-1` when the team color has no packed value.

**Returns:** the color value for this team or `-1` if it has no color.

**Since:** 1.8.4

### getDisplayName {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getDisplayName-}

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

Returns the team's display text, which may differ from [getName()](#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getName-).

**Returns:** the display name of this team.

**Since:** 1.3.0

### getName {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getName-}

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

Returns the team's registered name.

**Returns:** the team's registered name.

**Since:** 1.3.0

### getPlayerList {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getPlayerList-}

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

Returns a copy of the team's scoreboard member names; changing the returned list does not
 change team membership.

**Returns:** a copy of the list of member names.

**Since:** 1.3.0

### getPrefix {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getPrefix-}

```js
getPrefix(): TextHelper
```

Returns the text prepended to member names; it may be empty and may include formatting.

**Returns:** the prefix set on this team.

**Since:** 1.3.0

### getScoreboard {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getScoreboard-}

```js
getScoreboard(): ScoreboardsHelper
```

Returns the scoreboard this team belongs to.

**Returns:** the scoreboard including this team.

**Since:** 1.8.4

### getSuffix {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_getSuffix-}

```js
getSuffix(): TextHelper
```

Returns the text appended to member names; it may be empty and may include formatting.

**Returns:** the suffix set on this team.

**Since:** 1.3.0

### isFriendlyFire {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_isFriendlyFire-}

```js
isFriendlyFire(): boolean
```

Returns the team's friendly-fire setting.

**Returns:** `true` if members of this team can hurt each other.

**Since:** 1.3.0

### nametagVisibility {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_nametagVisibility-}

```js
nametagVisibility(): String
```

Returns the name-tag visibility rule: `always`, `never`,  
 `hideForOtherTeams`, or `hideForOwnTeam`.

**Returns:** this team's nametag visibility rule.

**Since:** 1.3.0

### showFriendlyInvisibles {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_showFriendlyInvisibles-}

```js
showFriendlyInvisibles(): boolean
```

Returns whether team members can see other members while they are invisible.

**Returns:** `true` if members of this team can see each other through invisibility.

**Since:** 1.3.0

### toString {#com.jsmacrosce.jsmacros.client.api.helper.world.TeamHelper_toString-}

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

Returns a diagnostic representation containing the team's display-name helper representation.

**Returns:** a diagnostic representation of the wrapped team
