public interface Team
A team is comprised of different members, represented by Text
objects.
While any Text
can be added to a team, certain Text
s convey a special
meaning.
Examples of this include players, whose names gain the prefix and suffix of the team they are on.
With the exception of getNameTagVisibility()
(which is handled client-side),
all of the team options require players to have the same team object (and by
extension, the same scoreboard).
For example, consider two players who each have different scoreboards set.
Each scoreboard has a team registered with identical names, each containing
the same players. Both players would always be able to attack each other,
regardless of the value of allowFriendlyFire()
.
For it to work, both players must have the same scoreboard, and be on a team
registered to said scoreboard.
Modifier and Type | Interface and Description |
---|---|
static interface |
Team.Builder
Represents a builder tp create
Team instances. |
Modifier and Type | Method and Description |
---|---|
void |
addMember(Text member)
Adds the specified
Text to this team. |
boolean |
allowFriendlyFire()
Gets whether friendly fire is enabled.
|
static Team.Builder |
builder()
Creates a new
Team.Builder to build a Team . |
boolean |
canSeeFriendlyInvisibles()
Gets whether invisible team members are shown.
|
CollisionRule |
getCollisionRule()
Gets the
CollisionRule for entities on this team. |
TextColor |
getColor()
Gets the color of this team.
|
Visibility |
getDeathMessageVisibility()
Gets the
Visibility which controls who death Texts
for players on this team are visible to. |
Text |
getDisplayName()
Gets the name displayed to users for this team.
|
Set<Text> |
getMembers()
Gets the
Text s representing the members of this team. |
String |
getName()
Gets the name of this team.
|
Visibility |
getNameTagVisibility()
Gets the
Visibility which controls to who nametags
of players on this team are visible to. |
Text |
getPrefix()
Gets the prefix prepended to the display name of users on this team.
|
Optional<Scoreboard> |
getScoreboard()
Returns the scoreboard this team is registered on, if available.
|
Text |
getSuffix()
Gets the suffix appended to the display name of users on this team.
|
boolean |
removeMember(Text member)
Removes the specified
Text from this team. |
void |
setAllowFriendlyFire(boolean enabled)
Sets whether friendly fire is enabled.
|
void |
setCanSeeFriendlyInvisibles(boolean enabled)
Sets whether invisible team members are shown.
|
void |
setCollisionRule(CollisionRule rule)
Sets the
CollisionRule for entities on this team. |
void |
setColor(TextColor color)
Sets the color of this team.
|
void |
setDeathMessageVisibility(Visibility visibility)
Sets the
Visibility which controls who death Texts
of players on this team are visible to. |
void |
setDisplayName(Text displayName)
Sets the name displayed to users for this team.
|
void |
setNameTagVisibility(Visibility visibility)
Sets the
Visibility which controls to who nametags
of players on this team are visible to. |
void |
setPrefix(Text prefix)
Sets the prefix prepended to the display name of users on this team.
|
void |
setSuffix(Text suffix)
Sets the suffix appended to the display name of users on this team.
|
boolean |
unregister()
Unregisters this team from its
Scoreboard , if present. |
static Team.Builder builder()
Team.Builder
to build a Team
.String getName()
Text getDisplayName()
void setDisplayName(Text displayName) throws IllegalArgumentException
displayName
- The Text
to useIllegalArgumentException
- If displayName is longer than 32
characters (in its legacy representation)TextColor getColor()
The team's color is a distinct concept from its prefix or suffix. It is only used for colored sidebar display slots, and certain statistic criteria.
void setColor(TextColor color)
The team's color is a distinct concept from its prefix or suffix. It is only used for colored sidebar display slots, and certain statistic criteria.
color
- The team colorText getPrefix()
void setPrefix(Text prefix) throws IllegalArgumentException
prefix
- The new prefix for this teamIllegalArgumentException
- If prefix is longer than 16
charactersText getSuffix()
void setSuffix(Text suffix) throws IllegalArgumentException
suffix
- The new suffix for this team.IllegalArgumentException
- If suffix is longer than 16
characters (in its legacy representation)boolean allowFriendlyFire()
This option only controls players attacking other players. It has no affect other entities attacking other entities, or players attacking other entities (or vice-versa).
void setAllowFriendlyFire(boolean enabled)
enabled
- Whether friendly fire is enabledboolean canSeeFriendlyInvisibles()
void setCanSeeFriendlyInvisibles(boolean enabled)
enabled
- Whether to show invisible teammatesVisibility getNameTagVisibility()
Visibility
which controls to who nametags
of players on this team are visible to.Visibility
for this team's nametagsvoid setNameTagVisibility(Visibility visibility)
Visibility
which controls to who nametags
of players on this team are visible to.visibility
- The Visibility
for this team's nametagsVisibility getDeathMessageVisibility()
Visibility
which controls who death Texts
for players on this team are visible to.Visibility
for this team's death Textsvoid setDeathMessageVisibility(Visibility visibility)
Visibility
which controls who death Texts
of players on this team are visible to.visibility
- The Visibility
for this team's death TextsCollisionRule getCollisionRule()
CollisionRule
for entities on this team.CollisionRule
for entities on this teamvoid setCollisionRule(CollisionRule rule)
CollisionRule
for entities on this team.rule
- The CollisionRule
for entities on this teamSet<Text> getMembers()
Text
s representing the members of this team.Text
s for this team's membersvoid addMember(Text member)
Text
to this team.
While any Text
may be added, the Text
to use should
normally be obtained by calling
TeamMember.getTeamRepresentation()
on a TeamMember
, such
as a Player
.
member
- the Text
to addboolean removeMember(Text member)
Text
from this team.
While any Text
may be removed, the Text
to use should normally be obtained by calling TeamMember.getTeamRepresentation()
on a TeamMember
, such as a Player
.
Optional<Scoreboard> getScoreboard()
This will return Optional.empty()
when a team has
been removed from its Scoreboard
, or has been created
but not yet registered.
boolean unregister()
Scoreboard
, if present.
A team can still be fully used after being unregistered. However,
it will not affect the game in any way until registered to a
Scoreboard
again, through
Scoreboard.registerTeam(Team)
.
Scoreboard
.