Skip to content

Objective

Namespace Mc.Scripting · Kind class (sealed)

public sealed class Objective

An objective of the server scoreboard (the one /scoreboard edits and the world saves): scores per holder name, shown in a display slot. For content that differs per player use Sidebar instead.

Member Description
string Name { get; } The objective’s name (what commands use).
public string Name { get; }

The objective’s name (what commands use).

Member Description
int AddScore(string holder, int amount) Adds to the score of a holder (a missing score counts as 0).
int? GetScore(string holder) The score of a holder (a player name, or any text for a fake entry), null when none is set.
bool ResetScore(string holder) Removes the score of a holder.
void SetScore(string holder, int value) Sets the score of a holder.
void SetTitle(Component title) Sets the title shown above the sidebar.
public int AddScore(string holder, int amount)

Adds to the score of a holder (a missing score counts as 0).

Parameters

Name Type Description
holder string The score holder.
amount int What to add.

Returns int: The new score.

public int? GetScore(string holder)

The score of a holder (a player name, or any text for a fake entry), null when none is set.

Parameters

Name Type Description
holder string The score holder.

Returns int?

public bool ResetScore(string holder)

Removes the score of a holder.

Parameters

Name Type Description
holder string The score holder.

Returns bool: Whether there was one.

public void SetScore(string holder, int value)

Sets the score of a holder.

Parameters

Name Type Description
holder string The score holder.
value int The score.
public void SetTitle(Component title)

Sets the title shown above the sidebar.

Parameters

Name Type Description
title Component The title.

Component