Minecraft-Console-Client/MinecraftClient/Protocol/ChatMessage.cs
BruceChen a8bbb1ac76
Basic support for minecraft 1.19 (#2084)
* merge commit from milutinke
* chat signature & encrypted login
* Bug fix :EncryptionResponse format error below 1.18.2
* Implemented chat command signature
* Chat message parsing and verification for 1.19
* Add signature settings
* Update Simplified Chinese Translation
* Clear up comments
* Fix wrong variable naming
* Bug fix: SignatureV2 Processing
2022-08-15 17:55:44 +02:00

61 lines
2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MinecraftClient.Protocol
{
public class ChatMessage
{
// in 1.19 and above, isSignedChat = true
public readonly bool isSignedChat;
public readonly string content;
public readonly bool isJson;
// 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
public readonly int chatType;
public readonly Guid senderUUID;
public readonly bool isSystemChat;
public readonly string? unsignedContent;
public readonly string? displayName;
public readonly string? teamName;
public readonly DateTime? timestamp;
public readonly bool? isSignatureLegal;
public ChatMessage(string content, bool isJson, int chatType, Guid senderUUID, string? unsignedContent, string displayName, string? teamName, long timestamp, bool isSignatureLegal)
{
this.isSignedChat = true;
this.isSystemChat = false;
this.content = content;
this.isJson = isJson;
this.chatType = chatType;
this.senderUUID = senderUUID;
this.unsignedContent = unsignedContent;
this.displayName = displayName;
this.teamName = teamName;
this.timestamp = DateTimeOffset.FromUnixTimeMilliseconds(timestamp).DateTime;
this.isSignatureLegal = isSignatureLegal;
}
public ChatMessage(string content, bool isJson, int chatType, Guid senderUUID, bool isSystemChat = false)
{
this.isSignedChat = isSystemChat;
this.isSystemChat = isSystemChat;
this.content = content;
this.isJson = isJson;
this.chatType = chatType;
this.senderUUID = senderUUID;
}
}
}