For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /server/classes/ScoreboardObjective.md.

Class: ScoreboardObjective

scoreboard

Beta

表示记分板上的记分项。包含了分数持有者和各自的分数。

Contains objectives and participants for the scoreboard.

Properties

displayName

readonly displayName: string

Beta

Remarks

此记分项的显示名称。

Returns the player-visible name of this scoreboard objective.

Throws

若记分项无效,则抛出。


id

readonly id: string

Beta

Remarks

此记分项的名称。

Identifier of the scoreboard objective.

Throws

若记分项无效,则抛出。


isValid

readonly isValid: boolean

Beta

Remarks

如果此 ScoreboardObjective 引用仍然有效,则返回 true。

Returns true if the ScoreboardObjective reference is still valid.

Methods

addScore()

addScore(participant, scoreToAdd): number

World Mutation Beta

Parameters

participant

string | Entity | ScoreboardIdentity

要对其应用记分项分数增加的分数持有者。

Participant to apply the scoreboard value addition to.

scoreToAdd

number

Returns

number

Remarks

为给定分数持有者和记分项添加分数。

Adds a score to the given participant and objective.

Throws

This function can throw errors.


getParticipants()

getParticipants(): ScoreboardIdentity[]

Beta

Returns

ScoreboardIdentity[]

由分数持有者对象组成的数组。

Remarks

返回此记分项上已记录的分数持有者。

Returns all objective participant identities.

Throws

若记分项无效时,抛出。


getScore()

getScore(participant): number | undefined

Beta

Parameters

participant

string | Entity | ScoreboardIdentity

分数持有者。

Identifier of the participant to retrieve a score for.

Returns

number | undefined

指定分数持有者的分数。

Remarks

获取指定分数持有者的分数。

Returns a specific score for a participant.

Throws

若此记分项上未记录分数持有者的分数,抛出 "Failed to retrieve score for '<participant>'"。 若记分项无效时,抛出。


getScores()

getScores(): ScoreboardScoreInfo[]

Beta

Returns

ScoreboardScoreInfo[]

由分数信息对象组成的数组。

Remarks

获取记分项上记录的所有分数信息。

Returns specific scores for this objective for all participants.

Throws

若记分项无效时,抛出。


hasParticipant()

hasParticipant(participant): boolean

Beta

Parameters

participant

string | Entity | ScoreboardIdentity

Returns

boolean

Remarks

返回指定身份是否是该记分项的分数持有者。

Returns if the specified identity is a participant of the scoreboard objective.

Throws

This function can throw errors.


removeParticipant()

removeParticipant(participant): boolean

World Mutation Beta

Parameters

participant

string | Entity | ScoreboardIdentity

要从该记分项追踪中移除的分数持有者。

Participant to remove from being tracked with this objective.

Returns

boolean

Remarks

从该记分项中移除一个分数持有者。

Removes a participant from this scoreboard objective.

Throws

This function can throw errors.


setScore()

setScore(participant, score): void

World Mutation Beta

Parameters

participant

string | Entity | ScoreboardIdentity

分数持有者的身份。

Identity of the participant.

score

number

新的分数。

New value of the score.

Returns

void

Remarks

为分数持有者设置分数。

Sets a score for a participant.

Throws

This function can throw errors.

同领域相关