2022-08-15 23:55:44 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
|
2022-08-27 02:10:44 +08:00
|
|
|
|
namespace MinecraftClient.Protocol.Message
|
2022-08-15 23:55:44 +08:00
|
|
|
|
{
|
|
|
|
|
|
public class ChatMessage
|
|
|
|
|
|
{
|
2023-03-25 16:42:28 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// In 1.19 and above, isSignedChat = true
|
|
|
|
|
|
/// </summary>
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public bool isSignedChat;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public string content;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public bool isJson, isSenderJson;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
|
2023-03-25 16:42:28 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 0: chat (chat box), 1: system message (chat box), 2: game info (above hotbar), 3: say command,
|
|
|
|
|
|
/// 4: msg command, 5: team msg command, 6: emote command, 7: tellraw command
|
|
|
|
|
|
/// </summary>
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public int chatTypeId;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public Guid senderUUID;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public bool isSystemChat;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public string? unsignedContent;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public string? displayName;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public string? teamName;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public DateTime? timestamp;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public byte[]? signature;
|
2022-08-27 02:10:44 +08:00
|
|
|
|
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public bool? isSignatureLegal;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
|
2023-01-14 02:41:03 +08:00
|
|
|
|
public ChatMessage(string content, bool isJson, int chatType, Guid senderUUID, string? unsignedContent, string displayName, string? teamName, long timestamp, byte[]? signature, bool isSignatureLegal)
|
2022-08-15 23:55:44 +08:00
|
|
|
|
{
|
2022-08-27 02:10:44 +08:00
|
|
|
|
isSignedChat = true;
|
|
|
|
|
|
isSystemChat = false;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
this.content = content;
|
|
|
|
|
|
this.isJson = isJson;
|
2022-10-02 18:31:08 +08:00
|
|
|
|
chatTypeId = chatType;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
this.senderUUID = senderUUID;
|
|
|
|
|
|
this.unsignedContent = unsignedContent;
|
|
|
|
|
|
this.displayName = displayName;
|
|
|
|
|
|
this.teamName = teamName;
|
2022-08-27 02:10:44 +08:00
|
|
|
|
this.timestamp = DateTimeOffset.FromUnixTimeMilliseconds(timestamp).DateTime;
|
|
|
|
|
|
this.signature = signature;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
this.isSignatureLegal = isSignatureLegal;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-14 00:53:36 +08:00
|
|
|
|
public ChatMessage(string content, string? displayName, bool isJson, int chatType, Guid senderUUID, bool isSystemChat = false)
|
2022-08-15 23:55:44 +08:00
|
|
|
|
{
|
2022-08-27 02:10:44 +08:00
|
|
|
|
isSignedChat = isSystemChat;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
this.isSystemChat = isSystemChat;
|
|
|
|
|
|
this.content = content;
|
2023-01-14 00:53:36 +08:00
|
|
|
|
this.displayName = displayName;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
this.isJson = isJson;
|
2022-10-02 18:31:08 +08:00
|
|
|
|
chatTypeId = chatType;
|
2022-08-15 23:55:44 +08:00
|
|
|
|
this.senderUUID = senderUUID;
|
|
|
|
|
|
}
|
2022-08-27 02:10:44 +08:00
|
|
|
|
|
2023-01-13 16:12:10 +08:00
|
|
|
|
public LastSeenMessageList.AcknowledgedMessage? ToLastSeenMessageEntry()
|
2022-08-27 02:10:44 +08:00
|
|
|
|
{
|
2023-01-13 16:12:10 +08:00
|
|
|
|
return signature != null ? new LastSeenMessageList.AcknowledgedMessage(senderUUID, signature, true) : null;
|
2022-08-27 02:10:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-02 18:31:08 +08:00
|
|
|
|
public bool LacksSender()
|
2022-08-27 02:10:44 +08:00
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
return senderUUID == Guid.Empty;
|
2022-08-27 02:10:44 +08:00
|
|
|
|
}
|
2022-08-15 23:55:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|