Skip to content

API reference Obsidian.API

ChatMessage record

public sealed record ChatMessage : INetworkSerializable<ChatMessage>, IEquatable<ChatMessage>

In Obsidian.API.

Constructors

public ChatMessage();

Properties

public bool? Bold { get; set; }public ClickComponent ClickEvent { get; set; }public HexColor? Color { get; set; }public static ChatMessage Empty { get; }public List<ChatMessage> Extra { get; }public HoverComponent HoverEvent { get; set; }public string Insertion { get; set; }public bool? Italic { get; set; }

Keybind

public string Keybind { get; set; }

The key bound to this keybind, like key.jump, as the client shows it.

public bool? Obfuscated { get; set; }

ShadowColor

public int? ShadowColor { get; set; }

Optional signed ARGB shadow color from the text component codec.

public bool? Strikethrough { get; set; }public string Text { get; set; }public string Translate { get; set; }public bool? Underlined { get; set; }public List<ChatMessage> With { get; }

Methods

public ChatMessage AddChatComponent(ChatMessage message);public ChatMessage AddChatComponent(IEnumerable<ChatMessage> message);public ChatMessage AddExtra(ChatMessage message);public ChatMessage AddExtra(IEnumerable<ChatMessage> messages);public ChatMessage AddExtra(List<ChatMessage> messages);public ChatMessage AppendColor(ChatColor color);public ChatMessage AppendText(string text);public ChatMessage AppendText(string text, ChatColor color);

Click(ChatMessage, ClickAction, string)

public static ChatMessage Click(ChatMessage message, ClickAction action, string value);

Appends an underlying ChatMessage.ClickEvent (ClickComponent) to the given ChatMessage.

Parameters

message
The message which will hold the ClickComponent.
action
The action which will be executed when clicking.
value
The value which will be executed with the action.

Returns

The given ChatMessage.

public IEnumerable<ChatMessage> GetExtraChatComponents();public IEnumerable<ChatMessage> GetExtras();

Hover(ChatMessage, HoverAction, IHoverContent)

public static ChatMessage Hover(ChatMessage message, HoverAction action, IHoverContent contents);

Appends an underlying ChatMessage.HoverEvent (HoverComponent) to the given ChatMessage.

Parameters

message
The message which will hold the HoverComponent.
action
The action which will be executed when clicking.
contents
The contents which will be executed with the action.

Returns

The given ChatMessage.

public static ChatMessage Read(INetStreamReader reader);

ReformatAmpersandPrefixes(string)

public static string ReformatAmpersandPrefixes(string originalText);

Converts all formatting codes which are using '&' to their respective '§' formatting code.

Parameters

originalText
The text to be reformatted.

Returns

The formatted text.

Simple(string)

public static ChatMessage Simple(string text);

Creates a new ChatMessage object with plain text.

Parameters

text
The text of the ChatMessage.

Returns

The created ChatMessage object.

Simple(string, ChatColor)

public static ChatMessage Simple(string text, ChatColor color);

Creates a new ChatMessage object with plain text.

Parameters

text
The text of the ChatMessage.
color
The ChatColor of the ChatMessage.

Returns

The created ChatMessage object.

SimpleLegacy(string)

public static ChatMessage SimpleLegacy(string text);

Creates a new ChatMessage object with plain text. The text will be reformatted by using the ChatMessage.ReformatAmpersandPrefixes method.

Parameters

text
The text of the ChatMessage.

Returns

The created ChatMessage object.

SimpleLegacy(string, ChatColor)

public static ChatMessage SimpleLegacy(string text, ChatColor color);

Creates a new ChatMessage object with plain text. The text will be reformatted by using the ChatMessage.ReformatAmpersandPrefixes method.

Parameters

text
The text of the ChatMessage.
color
The ChatColor of the ChatMessage.

Returns

The created ChatMessage object.

public string ToString(JsonSerializerOptions options);public static ChatMessage TranslatableChatMessageType(string text, ChatColor color, string username);public static ChatMessage TranslatableChatMessageType(string text, string username);public static void Write(ChatMessage value, INetStreamWriter writer);

Operators

public static implicit operator ChatMessage(string text);

operator +(ChatMessage, ChatColor)

public static ChatMessage operator +(ChatMessage a, ChatColor b);

Adds the given ChatColor to the text of the given ChatMessage.

Parameters

a
The message on which the chat color gets appended.
b
The chat color which will be appended.

Returns

The modified chat message.

operator +(ChatMessage, ChatMessage)

public static ChatMessage operator +(ChatMessage a, ChatMessage b);

Adds the right ChatMessage to the ChatMessage.Extra of the left ChatMessage.

Parameters

a
The left chat message on which the right one gets appended.
b
The right chat message which will be appended.

Returns

The modified chat message.

On this page