Class: Scoreboard
scoreboardBeta
表示记分板。其上包含了记分项和分数持有者。
Contains objectives and participants for the scoreboard.
Example
updateScoreboard.ts
Methods
addObjective()
addObjective(
objectiveId,displayName?):ScoreboardObjective
World Mutation Beta
Parameters
objectiveId
string
记分项名称。
displayName?
string
记分项的显示名称。
Returns
创建的记分项对象。
Remarks
在记分板上添加一个新的记分项。
Adds a new objective to the scoreboard.
Throws
若同名记分项已存在时,抛出 "Failed to add objective 'objectiveId' as it is already being tracked"。
Example
updateScoreboard.ts
clearObjectiveAtDisplaySlot()
clearObjectiveAtDisplaySlot(
displaySlotId):ScoreboardObjective|undefined
World Mutation Beta
Parameters
displaySlotId
显示位置。
Returns
ScoreboardObjective | undefined
先前正显示的记分项,为空时返回 null。
Remarks
清除显示位置上正在显示的记分项。
Clears the objective that occupies a display slot.
getObjective()
getObjective(
objectiveId):ScoreboardObjective|undefined
Beta
Parameters
objectiveId
string
记分项名称。
Identifier of the objective.
Returns
ScoreboardObjective | undefined
指定的记分项对象。不存在时返回 null。
Remarks
获取名称为 objectiveId 的记分项对象。
Returns a specific objective (by id).
getObjectiveAtDisplaySlot()
getObjectiveAtDisplaySlot(
displaySlotId):ScoreboardObjectiveDisplayOptions|undefined
Beta
Parameters
displaySlotId
显示位置。
Returns
ScoreboardObjectiveDisplayOptions | undefined
位于指定显示位置的记分项显示配置。为空时返回 null。
Remarks
获取位于指定显示位置上的记分项对象与显示配置。
Returns an objective that occupies the specified display slot.
getObjectives()
getObjectives():
ScoreboardObjective[]
Beta
Returns
所有记分项对象组成的数组。
Remarks
获取记分板上的已定义的所有记分项。
Returns all defined objectives.
getParticipants()
getParticipants():
ScoreboardIdentity[]
Beta
Returns
所有分数持有者对象组成的数组。
Remarks
获取所有已经定义的分数持有者。
Returns all defined scoreboard identities.
removeObjective()
removeObjective(
objectiveId):boolean
World Mutation Beta
Parameters
objectiveId
string | ScoreboardObjective
记分项对象或名称。
Returns
boolean
总是返回 true。
Remarks
从记分板上移除指定的记分项。
Removes an objective from the scoreboard.
Throws
若指定的记分项不存在时,抛出 "Failed to find the objective specified"。
setObjectiveAtDisplaySlot()
setObjectiveAtDisplaySlot(
displaySlotId,objectiveDisplaySetting):ScoreboardObjective|undefined
World Mutation Beta
Parameters
displaySlotId
显示位置。
objectiveDisplaySetting
ScoreboardObjectiveDisplayOptions
记分项显示配置。
Returns
ScoreboardObjective | undefined
显示位上先前显示的记分项对象。先前未显示记分项时,返回 undefined。
Returns the previous ScoreboardObjective set at the
display slot, if no objective was previously set it returns
undefined.
Remarks
设置指定的显示位置显示的记分项与其他显示配置。
Sets an objective into a display slot with specified additional display settings.
Throws
若记分项无效,抛出 "Failed to set invalid objective at DisplaySlot"。
