Objective
Namespace Mc.Scripting · Kind class (sealed)
public sealed class ObjectiveAn 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.
Properties
Section titled “Properties”| Member | Description |
|---|---|
string Name { get; } |
The objective’s name (what commands use). |
public string Name { get; }The objective’s name (what commands use).
Methods
Section titled “Methods”| 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. |
AddScore
Section titled “AddScore”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.
GetScore
Section titled “GetScore”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?
ResetScore
Section titled “ResetScore”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.
SetScore
Section titled “SetScore”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. |
SetTitle
Section titled “SetTitle”public void SetTitle(Component title)Sets the title shown above the sidebar.
Parameters
| Name | Type | Description |
|---|---|---|
title |
Component |
The title. |