Skip to content

TeamHelper ​

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

Since1.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().

Team colors have distinct representations: getColorFormat() returns formatting,
getColorIndex() its index, getColorValue() its packed value (or -1 when unset), and 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 ​

new TeamHelper(PlayerTeam t)#
Wraps the supplied raw scoreboard team without changing it.

Parameters:

  • t: raw scoreboard team to wrap

Methods ​

deathMessageVisibility ​

deathMessageVisibility(): StringSince1.3.0#
Returns the death-message visibility rule, configured separately from nametagVisibility().
Returns: this team's death message visibility rule.

getCollisionRule ​

getCollisionRule(): StringSince1.3.0#
Returns the collision rule name: always, never, pushOtherTeams, or pushOwnTeam.
Returns: the team's collision rule.

getColorFormat ​

getColorFormat(): FormattingHelperSince1.8.4#
Returns the team's color formatting. An unset team color is represented by reset formatting; use getColorValue() to distinguish it from a set color.
Returns: the formatting of this team's color.

getColorIndex ​

getColorIndex(): intSince1.8.4#
Returns the team's color index, distinct from the packed value returned by getColorValue().
Returns: the color index of this team.

getColorName ​

getColorName(): StringSince1.8.4#
Returns the team's color name.
Returns: the name of this team's color.

getColorValue ​

getColorValue(): intSince1.8.4#
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.

getDisplayName ​

getDisplayName(): TextHelperSince1.3.0#
Returns the team's display text, which may differ from getName().
Returns: the display name of this team.

getName ​

getName(): StringSince1.3.0#
Returns the team's registered name.
Returns: the team's registered name.

getPlayerList ​

getPlayerList(): List<String>Since1.3.0#
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.

getPrefix ​

getPrefix(): TextHelperSince1.3.0#
Returns the text prepended to member names; it may be empty and may include formatting.
Returns: the prefix set on this team.

getScoreboard ​

getScoreboard(): ScoreboardsHelperSince1.8.4#
Returns the scoreboard this team belongs to.
Returns: the scoreboard including this team.

getSuffix ​

getSuffix(): TextHelperSince1.3.0#
Returns the text appended to member names; it may be empty and may include formatting.
Returns: the suffix set on this team.

isFriendlyFire ​

isFriendlyFire(): booleanSince1.3.0#
Returns the team's friendly-fire setting.
Returns: true if members of this team can hurt each other.

nametagVisibility ​

nametagVisibility(): StringSince1.3.0#
Returns the name-tag visibility rule: always, never, hideForOtherTeams, or hideForOwnTeam.
Returns: this team's nametag visibility rule.

showFriendlyInvisibles ​

showFriendlyInvisibles(): booleanSince1.3.0#
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.

toString ​

toString(): String#
Returns a diagnostic representation containing the team's display-name helper representation.
Returns: a diagnostic representation of the wrapped team