Interface Team
-
public interface Team
A team on a scoreboard that has a common display theme and other properties.A team is comprised of different members, represented by
Component
objects. While anyComponent
can be added to a team, certainComponent
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
nameTagVisibility()
(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 ofallowFriendlyFire()
. For it to work, both players must have the same scoreboard, and be on a team registered to said scoreboard.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Team.Builder
Represents a builder tp createTeam
instances.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addMember(Component member)
Adds the specifiedComponent
to this team.boolean
allowFriendlyFire()
Gets whether friendly fire is enabled.static Team.Builder
builder()
Creates a newTeam.Builder
to build aTeam
.boolean
canSeeFriendlyInvisibles()
Gets whether invisible team members are shown.CollisionRule
collisionRule()
Gets theCollisionRule
for entities on this team.NamedTextColor
color()
Gets the color of this team.Visibility
deathMessageVisibility()
Gets theVisibility
which controls who death Texts for players on this team are visible to.Component
displayName()
Gets the name displayed to users for this team.Set<Component>
members()
Gets theComponent
s representing the members of this team.String
name()
Gets the name of this team.Visibility
nameTagVisibility()
Gets theVisibility
which controls to who nametags of players on this team are visible to.Component
prefix()
Gets the prefix prepended to the display name of users on this team.boolean
removeMember(Component member)
Removes the specifiedComponent
from this team.Optional<Scoreboard>
scoreboard()
Returns the scoreboard this team is registered on, if available.void
setAllowFriendlyFire(boolean enabled)
Sets whether friendly fire is enabled.void
setCanSeeFriendlyInvisibles(boolean enabled)
Sets whether invisible team members are shown.default void
setCollisionRule(Supplier<? extends CollisionRule> rule)
Sets theCollisionRule
for entities on this team.void
setCollisionRule(CollisionRule rule)
Sets theCollisionRule
for entities on this team.void
setColor(NamedTextColor color)
Sets the color of this team.default void
setDeathMessageVisibility(Supplier<? extends Visibility> visibility)
Sets theVisibility
which controls who death Texts of players on this team are visible to.void
setDeathMessageVisibility(Visibility visibility)
Sets theVisibility
which controls who death Texts of players on this team are visible to.void
setDisplayName(Component displayName)
Sets the name displayed to users for this team.default void
setNameTagVisibility(Supplier<? extends Visibility> visibility)
Sets theVisibility
which controls to who nametags of players on this team are visible to.void
setNameTagVisibility(Visibility visibility)
Sets theVisibility
which controls to who nametags of players on this team are visible to.void
setPrefix(Component prefix)
Sets the prefix prepended to the display name of users on this team.void
setSuffix(Component suffix)
Sets the suffix appended to the display name of users on this team.Component
suffix()
Gets the suffix appended to the display name of users on this team.boolean
unregister()
Unregisters this team from itsScoreboard
, if present.
-
-
-
Method Detail
-
builder
static Team.Builder builder()
Creates a newTeam.Builder
to build aTeam
.- Returns:
- The new builder
-
name
String name()
Gets the name of this team.- Returns:
- The name of this team
-
displayName
Component displayName()
Gets the name displayed to users for this team.- Returns:
- The display name for this team
-
setDisplayName
void setDisplayName(Component displayName) throws IllegalArgumentException
Sets the name displayed to users for this team.- Parameters:
displayName
- TheComponent
to use- Throws:
IllegalArgumentException
-
color
NamedTextColor color()
Gets the color of this team.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.
- Returns:
- The team color
-
setColor
void setColor(NamedTextColor color)
Sets the color of this team.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.
- Parameters:
color
- The team color
-
prefix
Component prefix()
Gets the prefix prepended to the display name of users on this team.- Returns:
- The prefix for this team
-
setPrefix
void setPrefix(Component prefix) throws IllegalArgumentException
Sets the prefix prepended to the display name of users on this team.- Parameters:
prefix
- The new prefix for this team- Throws:
IllegalArgumentException
-
suffix
Component suffix()
Gets the suffix appended to the display name of users on this team.- Returns:
- The team's current suffix
-
setSuffix
void setSuffix(Component suffix) throws IllegalArgumentException
Sets the suffix appended to the display name of users on this team.- Parameters:
suffix
- The new suffix for this team.- Throws:
IllegalArgumentException
-
allowFriendlyFire
boolean allowFriendlyFire()
Gets whether friendly fire is enabled.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).
- Returns:
- Whether friendly fire is enabled
-
setAllowFriendlyFire
void setAllowFriendlyFire(boolean enabled)
Sets whether friendly fire is enabled.- Parameters:
enabled
- Whether friendly fire is enabled
-
canSeeFriendlyInvisibles
boolean canSeeFriendlyInvisibles()
Gets whether invisible team members are shown.- Returns:
- Whether to show invisible team members
-
setCanSeeFriendlyInvisibles
void setCanSeeFriendlyInvisibles(boolean enabled)
Sets whether invisible team members are shown.- Parameters:
enabled
- Whether to show invisible teammates
-
nameTagVisibility
Visibility nameTagVisibility()
Gets theVisibility
which controls to who nametags of players on this team are visible to.- Returns:
- The
Visibility
for this team's nametags
-
setNameTagVisibility
default void setNameTagVisibility(Supplier<? extends Visibility> visibility)
Sets theVisibility
which controls to who nametags of players on this team are visible to.- Parameters:
visibility
- TheVisibility
for this team's nametags
-
setNameTagVisibility
void setNameTagVisibility(Visibility visibility)
Sets theVisibility
which controls to who nametags of players on this team are visible to.- Parameters:
visibility
- TheVisibility
for this team's nametags
-
deathMessageVisibility
Visibility deathMessageVisibility()
Gets theVisibility
which controls who death Texts for players on this team are visible to.- Returns:
- The
Visibility
for this team's death Texts
-
setDeathMessageVisibility
default void setDeathMessageVisibility(Supplier<? extends Visibility> visibility)
Sets theVisibility
which controls who death Texts of players on this team are visible to.- Parameters:
visibility
- TheVisibility
for this team's death Texts
-
setDeathMessageVisibility
void setDeathMessageVisibility(Visibility visibility)
Sets theVisibility
which controls who death Texts of players on this team are visible to.- Parameters:
visibility
- TheVisibility
for this team's death Texts
-
collisionRule
CollisionRule collisionRule()
Gets theCollisionRule
for entities on this team.- Returns:
- The
CollisionRule
for entities on this team
-
setCollisionRule
default void setCollisionRule(Supplier<? extends CollisionRule> rule)
Sets theCollisionRule
for entities on this team.- Parameters:
rule
- TheCollisionRule
for entities on this team
-
setCollisionRule
void setCollisionRule(CollisionRule rule)
Sets theCollisionRule
for entities on this team.- Parameters:
rule
- TheCollisionRule
for entities on this team
-
members
Set<Component> members()
Gets theComponent
s representing the members of this team.- Returns:
- the
Component
s for this team's members
-
addMember
void addMember(Component member)
Adds the specifiedComponent
to this team.While any
Component
may be added, theComponent
to use should normally be obtained by callingTeamMember.teamRepresentation()
on aTeamMember
, such as aPlayer
.- Parameters:
member
- theComponent
to add
-
removeMember
boolean removeMember(Component member)
Removes the specifiedComponent
from this team.While any
Component
may be removed, theComponent
to use should normally be obtained by callingTeamMember.teamRepresentation()
on aTeamMember
, such as aPlayer
.
-
scoreboard
Optional<Scoreboard> scoreboard()
Returns the scoreboard this team is registered on, if available.This will return
Optional.empty()
when a team has been removed from itsScoreboard
, or has been created but not yet registered.- Returns:
- The scoreboard this team is registered on, if available.
-
unregister
boolean unregister()
Unregisters this team from itsScoreboard
, 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, throughScoreboard.registerTeam(Team)
.- Returns:
- Whether this team was registered to a
Scoreboard
.
-
-