merge brigadier-dev into milutinke:1.19.3

This commit is contained in:
BruceChen 2023-01-14 20:42:15 +08:00
commit ba0d9ba3fc
139 changed files with 12057 additions and 3183 deletions

View file

@ -54,7 +54,22 @@ namespace MinecraftClient.Protocol.Handlers.packet.s2c
Nodes[i] = new(flags, childs, redirectNode, name, paser, suggestionsType);
}
RootIdx = dataTypes.ReadNextVarInt(packetData);
RootIdx = dataTypes.ReadNextVarInt(packetData);
ConsoleIO.OnDeclareMinecraftCommand(ExtractRootCommand());
}
private static string[] ExtractRootCommand()
{
List<string> commands = new();
CommandNode root = Nodes[RootIdx];
foreach (var child in root.Clildren)
{
string? childName = Nodes[child].Name;
if (childName != null)
commands.Add(childName);
}
return commands.ToArray();
}
public static List<Tuple<string, string>> CollectSignArguments(string command)
@ -113,7 +128,7 @@ namespace MinecraftClient.Protocol.Handlers.packet.s2c
public string? Name;
public Paser? Paser;
public string? SuggestionsType;
public CommandNode(byte Flags,
int[] Clildren,

View file

@ -9,10 +9,11 @@ using System.Threading;
using MinecraftClient.Crypto;
using MinecraftClient.Inventory;
using MinecraftClient.Mapping;
using MinecraftClient.Protocol.Keys;
using MinecraftClient.Protocol.Message;
using MinecraftClient.Protocol.ProfileKey;
using MinecraftClient.Protocol.Session;
using MinecraftClient.Proxy;
using MinecraftClient.Scripting;
using static MinecraftClient.Settings;
namespace MinecraftClient.Protocol.Handlers
@ -24,8 +25,6 @@ namespace MinecraftClient.Protocol.Handlers
class Protocol16Handler : IMinecraftCom
{
readonly IMinecraftComHandler handler;
private bool autocomplete_received = false;
private string autocomplete_result = "";
private bool encrypted = false;
private readonly int protocolversion;
private Tuple<Thread, CancellationTokenSource>? netRead = null;
@ -193,7 +192,14 @@ namespace MinecraftClient.Protocol.Handlers
if (online) { handler.OnPlayerJoin(new PlayerInfo(name, FakeUUID)); } else { handler.OnPlayerLeave(FakeUUID); }
break;
case 0xCA: if (protocolversion >= 72) { ReadData(9); } else ReadData(3); break;
case 0xCB: autocomplete_result = ReadNextString(); autocomplete_received = true; break;
case 0xCB:
string resultString = ReadNextString();
if (!string.IsNullOrEmpty(resultString))
{
string[] result = resultString.Split((char)0x00);
handler.OnAutoCompleteDone(0, result);
}
break;
case 0xCC: ReadNextString(); ReadData(4); break;
case 0xCD: ReadData(1); break;
case 0xCE: if (protocolversion > 51) { ReadNextString(); ReadNextString(); ReadData(1); } break;
@ -820,27 +826,21 @@ namespace MinecraftClient.Protocol.Handlers
catch (System.IO.IOException) { return false; }
}
IEnumerable<string> IAutoComplete.AutoComplete(string BehindCursor)
int IAutoComplete.AutoComplete(string BehindCursor)
{
if (String.IsNullOrEmpty(BehindCursor))
return Array.Empty<string>();
return -1;
byte[] autocomplete = new byte[3 + (BehindCursor.Length * 2)];
autocomplete[0] = 0xCB;
byte[] msglen = BitConverter.GetBytes((short)BehindCursor.Length);
Array.Reverse(msglen); msglen.CopyTo(autocomplete, 1);
Array.Reverse(msglen);
msglen.CopyTo(autocomplete, 1);
byte[] msg = Encoding.BigEndianUnicode.GetBytes(BehindCursor);
msg.CopyTo(autocomplete, 3);
autocomplete_received = false;
autocomplete_result = BehindCursor;
ConsoleIO.AutoCompleteDone = false;
Send(autocomplete);
int wait_left = 50; //do not wait more than 5 seconds (50 * 100 ms)
while (wait_left > 0 && !autocomplete_received) { System.Threading.Thread.Sleep(100); wait_left--; }
if (!String.IsNullOrEmpty(autocomplete_result) && autocomplete_received)
ConsoleIO.WriteLineFormatted("§8" + autocomplete_result.Replace((char)0x00, ' '), false);
return autocomplete_result.Split((char)0x00);
return 0;
}
private static byte[] ConcatBytes(params byte[][] bytes)

View file

@ -19,10 +19,11 @@ using MinecraftClient.Mapping.EntityPalettes;
using MinecraftClient.Protocol.Handlers.Forge;
using MinecraftClient.Protocol.Handlers.packet.s2c;
using MinecraftClient.Protocol.Handlers.PacketPalettes;
using MinecraftClient.Protocol.Keys;
using MinecraftClient.Protocol.Message;
using MinecraftClient.Protocol.ProfileKey;
using MinecraftClient.Protocol.Session;
using MinecraftClient.Proxy;
using MinecraftClient.Scripting;
using static MinecraftClient.Settings;
namespace MinecraftClient.Protocol.Handlers
@ -65,9 +66,7 @@ namespace MinecraftClient.Protocol.Handlers
internal const int MC_1_19_3_Version = 761;
private int compression_treshold = 0;
private bool autocomplete_received = false;
private int autocomplete_transaction_id = 0;
private readonly List<string> autocomplete_result = new();
private readonly Dictionary<int, short> window_actions = new();
private bool login_phase = true;
private readonly int protocolVersion;
@ -1514,6 +1513,7 @@ namespace MinecraftClient.Protocol.Handlers
}
break;
case PacketTypesIn.TabComplete:
int old_transaction_id = autocomplete_transaction_id;
if (protocolVersion >= MC_1_13_Version)
{
autocomplete_transaction_id = dataTypes.ReadNextVarInt(packetData);
@ -1522,20 +1522,19 @@ namespace MinecraftClient.Protocol.Handlers
}
int autocomplete_count = dataTypes.ReadNextVarInt(packetData);
autocomplete_result.Clear();
string[] autocomplete_result = new string[autocomplete_count];
for (int i = 0; i < autocomplete_count; i++)
{
autocomplete_result.Add(dataTypes.ReadNextString(packetData));
autocomplete_result[i] = dataTypes.ReadNextString(packetData);
if (protocolVersion >= MC_1_13_Version)
{
// Skip optional tooltip for each tab-complete result
// Skip optional tooltip for each tab-complete resul`t
if (dataTypes.ReadNextBool(packetData))
dataTypes.SkipNextString(packetData);
}
}
autocomplete_received = true;
handler.OnAutoCompleteDone(old_transaction_id, autocomplete_result);
break;
case PacketTypesIn.PluginMessage:
String channel = dataTypes.ReadNextString(packetData);
@ -2320,11 +2319,10 @@ namespace MinecraftClient.Protocol.Handlers
/// </summary>
/// <param name="BehindCursor">Text behind cursor</param>
/// <returns>Completed text</returns>
IEnumerable<string> IAutoComplete.AutoComplete(string BehindCursor)
int IAutoComplete.AutoComplete(string BehindCursor)
{
if (String.IsNullOrEmpty(BehindCursor))
return Array.Empty<string>();
if (string.IsNullOrEmpty(BehindCursor))
return -1;
byte[] transaction_id = DataTypes.GetVarInt(autocomplete_transaction_id);
byte[] assume_command = new byte[] { 0x00 };
@ -2337,16 +2335,14 @@ namespace MinecraftClient.Protocol.Handlers
if (protocolVersion >= MC_1_13_Version)
{
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, transaction_id);
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, dataTypes.GetString(BehindCursor));
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, dataTypes.GetString(BehindCursor.Replace(' ', (char)0x00)));
}
else
{
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, dataTypes.GetString(BehindCursor));
if (protocolVersion >= MC_1_9_Version)
{
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, assume_command);
}
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, has_position);
}
@ -2355,22 +2351,9 @@ namespace MinecraftClient.Protocol.Handlers
{
tabcomplete_packet = dataTypes.ConcatBytes(dataTypes.GetString(BehindCursor));
}
autocomplete_received = false;
autocomplete_result.Clear();
autocomplete_result.Add(BehindCursor);
ConsoleIO.AutoCompleteDone = false;
SendPacket(PacketTypesOut.TabComplete, tabcomplete_packet);
int wait_left = 50; //do not wait more than 5 seconds (50 * 100 ms)
ThreadStart start = new(delegate
{
while (wait_left > 0 && !autocomplete_received) { System.Threading.Thread.Sleep(100); wait_left--; }
if (autocomplete_result.Count > 0)
ConsoleIO.WriteLineFormatted("§8" + String.Join(" ", autocomplete_result), false);
});
Thread t1 = new(start);
t1.Start();
return autocomplete_result;
return autocomplete_transaction_id;
}
/// <summary>

View file

@ -4,6 +4,8 @@ using System.Linq;
using System.Text;
using System.Threading;
using MinecraftClient.Protocol.Handlers.Forge;
using MinecraftClient.Protocol.Message;
using MinecraftClient.Scripting;
namespace MinecraftClient.Protocol.Handlers
{

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using MinecraftClient.Inventory;
using MinecraftClient.Mapping;
using MinecraftClient.Protocol.Keys;
using MinecraftClient.Protocol.ProfileKey;
namespace MinecraftClient.Protocol
{

View file

@ -5,6 +5,7 @@ using MinecraftClient.Logger;
using MinecraftClient.Mapping;
using MinecraftClient.Protocol.Keys;
using MinecraftClient.Protocol.Message;
using MinecraftClient.Scripting;
namespace MinecraftClient.Protocol
{
@ -458,6 +459,13 @@ namespace MinecraftClient.Protocol
/// <param name="block">The block</param>
public void OnBlockChange(Location location, Block block);
/// <summary>
/// Called when "AutoComplete" completes.
/// </summary>
/// <param name="transactionId">The number of this result.</param>
/// <param name="result">All commands.</param>
public void OnAutoCompleteDone(int transactionId, string[] result);
/// <summary>
/// Send a click container button packet to the server.
/// Used for Enchanting table, Lectern, stone cutter and loom

View file

@ -1,14 +1,14 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using MinecraftClient.Protocol.Message;
using static MinecraftClient.Settings;
namespace MinecraftClient.Protocol
namespace MinecraftClient.Protocol.Message
{
/// <summary>
/// This class parses JSON chat data from MC 1.6+ and returns the appropriate string to be printed.
@ -144,7 +144,7 @@ namespace MinecraftClient.Protocol
if (message.isSystemChat)
{
if (Config.Signature.MarkSystemMessage)
color = z▍§r"; // Custom color code §z : Background Gray
color = §7▍§§r"; // Background Gray
}
else
{
@ -153,18 +153,18 @@ namespace MinecraftClient.Protocol
if (Config.Signature.ShowModifiedChat && message.unsignedContent != null)
{
if (Config.Signature.MarkModifiedMsg)
color = x▍§r"; // Custom color code §x : Background Yellow
color = §6▍§§r"; // Background Yellow
}
else
{
if (Config.Signature.MarkLegallySignedMsg)
color = y▍§r"; // Custom color code §y : Background Green
color = §2▍§§r"; // Background Green
}
}
else
{
if (Config.Signature.MarkIllegallySignedMsg)
color = w▍§r"; // Custom color code §w : Background Red
color = §4▍§§r"; // Background Red
}
}
return color + text;
@ -212,7 +212,7 @@ namespace MinecraftClient.Protocol
/// <summary>
/// Set of translation rules for formatting text
/// </summary>
private static readonly Dictionary<string, string> TranslationRules = new();
private static Dictionary<string, string> TranslationRules = new();
/// <summary>
/// Initialize translation rules.
@ -225,90 +225,85 @@ namespace MinecraftClient.Protocol
/// </summary>
private static void InitRules()
{
//Small default dictionnary of translation rules
TranslationRules["chat.type.admin"] = "[%s: %s]";
TranslationRules["chat.type.announcement"] = "§d[%s] %s";
TranslationRules["chat.type.emote"] = " * %s %s";
TranslationRules["chat.type.text"] = "<%s> %s";
TranslationRules["multiplayer.player.joined"] = "§e%s joined the game.";
TranslationRules["multiplayer.player.left"] = "§e%s left the game.";
TranslationRules["commands.message.display.incoming"] = "§7%s whispers to you: %s";
TranslationRules["commands.message.display.outgoing"] = "§7You whisper to %s: %s";
if (Config.Main.Advanced.Language == "en_us")
{
TranslationRules = JsonSerializer.Deserialize<Dictionary<string, string>>((byte[])MinecraftAssets.ResourceManager.GetObject("en_us.json")!)!;
return;
}
//Language file in a subfolder, depending on the language setting
if (!Directory.Exists("lang"))
Directory.CreateDirectory("lang");
string Language_File = "lang" + Path.DirectorySeparatorChar + Config.Main.Advanced.Language + ".lang";
string languageFilePath = "lang" + Path.DirectorySeparatorChar + Config.Main.Advanced.Language + ".json";
//File not found? Try downloading language file from Mojang's servers?
if (!File.Exists(Language_File))
// Load the external dictionnary of translation rules or display an error message
if (File.Exists(languageFilePath))
{
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_download, Config.Main.Advanced.Language));
HttpClient httpClient = new();
try
{
Task<string> fetch_index = httpClient.GetStringAsync(Settings.TranslationsFile_Website_Index);
fetch_index.Wait();
string assets_index = fetch_index.Result;
fetch_index.Dispose();
TranslationRules = JsonSerializer.Deserialize<Dictionary<string, string>>(File.OpenRead(languageFilePath))!;
}
catch (IOException) { }
catch (JsonException) { }
}
string[] tmp = assets_index.Split(new string[] { "minecraft/lang/" + Config.Main.Advanced.Language.ToLower() + ".json" }, StringSplitOptions.None);
tmp = tmp[1].Split(new string[] { "hash\": \"" }, StringSplitOptions.None);
string hash = tmp[1].Split('"')[0]; //Translations file identifier on Mojang's servers
string translation_file_location = Settings.TranslationsFile_Website_Download + '/' + hash[..2] + '/' + hash;
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_request, translation_file_location));
if (TranslationRules.TryGetValue("Version", out string? version) && version == Settings.TranslationsFile_Version)
{
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.chat_loaded, acceptnewlines: true);
return;
}
Task<string> fetch_file = httpClient.GetStringAsync(translation_file_location);
// Try downloading language file from Mojang's servers?
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_download, Config.Main.Advanced.Language));
HttpClient httpClient = new();
try
{
Task<string> fetch_index = httpClient.GetStringAsync(TranslationsFile_Website_Index);
fetch_index.Wait();
Match match = Regex.Match(fetch_index.Result, $"minecraft/lang/{Config.Main.Advanced.Language}.json" + @""":\s\{""hash"":\s""([\d\w]{40})""");
fetch_index.Dispose();
if (match.Success && match.Groups.Count == 2)
{
string hash = match.Groups[1].Value;
string translation_file_location = TranslationsFile_Website_Download + '/' + hash[..2] + '/' + hash;
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_request, translation_file_location));
Task<Stream> fetch_file = httpClient.GetStreamAsync(translation_file_location);
fetch_file.Wait();
string translation_file = fetch_file.Result;
TranslationRules = JsonSerializer.Deserialize<Dictionary<string, string>>(fetch_file.Result)!;
fetch_file.Dispose();
StringBuilder stringBuilder = new();
foreach (KeyValuePair<string, Json.JSONData> entry in Json.ParseJson(translation_file).Properties)
stringBuilder.Append(entry.Key).Append('=').Append(entry.Value.StringValue.Replace("\n", "\\n").Replace("\r", String.Empty)).Append(Environment.NewLine);
File.WriteAllText(Language_File, stringBuilder.ToString());
TranslationRules["Version"] = TranslationsFile_Version;
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_done, Language_File));
File.WriteAllText(languageFilePath, JsonSerializer.Serialize(TranslationRules, typeof(Dictionary<string, string>)), Encoding.UTF8);
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_done, languageFilePath));
return;
}
catch
else
{
ConsoleIO.WriteLineFormatted("§8" + Translations.chat_fail, acceptnewlines: true);
}
}
catch (HttpRequestException)
{
ConsoleIO.WriteLineFormatted("§8" + Translations.chat_fail, acceptnewlines: true);
}
catch (IOException)
{
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_save_fail, languageFilePath), acceptnewlines: true);
}
finally
{
httpClient.Dispose();
}
//Download Failed? Defaulting to en_GB.lang if the game is installed
if (!File.Exists(Language_File) //Try en_GB.lang
&& File.Exists(Settings.TranslationsFile_FromMCDir))
{
Language_File = Settings.TranslationsFile_FromMCDir;
ConsoleIO.WriteLineFormatted("§8" + Translations.chat_from_dir, acceptnewlines: true);
}
//Load the external dictionnary of translation rules or display an error message
if (File.Exists(Language_File))
{
foreach (var line in File.ReadLines(Language_File))
{
if (line.Length > 0)
{
string[] splitted = line.Split('=');
if (splitted.Length == 2)
{
TranslationRules[splitted[0]] = splitted[1];
}
}
}
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted("§8" + Translations.chat_loaded, acceptnewlines: true);
}
else //No external dictionnary found.
{
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_not_found, Language_File));
}
TranslationRules = JsonSerializer.Deserialize<Dictionary<string, string>>((byte[])MinecraftAssets.ResourceManager.GetObject("en_us.json")!)!;
ConsoleIO.WriteLine(Translations.chat_use_default);
}
public static string? TranslateString(string rulename)

View file

@ -214,7 +214,7 @@ namespace MinecraftClient.Protocol
fetchTask.Dispose();
}
catch (Exception)
{
{
return new MojangServiceStatus();
}

View file

@ -6,6 +6,7 @@ using System.Text;
using MinecraftClient.Protocol.Handlers;
using MinecraftClient.Protocol.Keys;
using MinecraftClient.Protocol.Message;
using MinecraftClient.Protocol.ProfileKey;
namespace MinecraftClient.Protocol
{

View file

@ -6,7 +6,7 @@ using MinecraftClient.Protocol.Handlers;
using MinecraftClient.Protocol.Message;
using static MinecraftClient.Protocol.Message.LastSeenMessageList;
namespace MinecraftClient.Protocol.Keys
namespace MinecraftClient.Protocol.ProfileKey
{
static class KeyUtils
{
@ -47,7 +47,7 @@ namespace MinecraftClient.Protocol.Keys
}
catch (Exception e)
{
int code = (response == null) ? 0 : response.StatusCode;
int code = response == null ? 0 : response.StatusCode;
ConsoleIO.WriteLineFormatted("§cFetch profile key failed: HttpCode = " + code + ", Error = " + e.Message);
if (Settings.Config.Logging.DebugMessages)
{
@ -57,7 +57,7 @@ namespace MinecraftClient.Protocol.Keys
}
}
public static byte[] DecodePemKey(String key, String prefix, String suffix)
public static byte[] DecodePemKey(string key, string prefix, string suffix)
{
int i = key.IndexOf(prefix);
if (i != -1)
@ -66,8 +66,8 @@ namespace MinecraftClient.Protocol.Keys
int j = key.IndexOf(suffix, i);
key = key[i..j];
}
key = key.Replace("\r", String.Empty);
key = key.Replace("\n", String.Empty);
key = key.Replace("\r", string.Empty);
key = key.Replace("\n", string.Empty);
return Convert.FromBase64String(key);
}
@ -198,11 +198,11 @@ namespace MinecraftClient.Protocol.Keys
char c = src[i];
bool needEscape = c < 32 || c == '"' || c == '\\';
// Broken lead surrogate
needEscape = needEscape || (c >= '\uD800' && c <= '\uDBFF' &&
(i == src.Length - 1 || src[i + 1] < '\uDC00' || src[i + 1] > '\uDFFF'));
needEscape = needEscape || c >= '\uD800' && c <= '\uDBFF' &&
(i == src.Length - 1 || src[i + 1] < '\uDC00' || src[i + 1] > '\uDFFF');
// Broken tail surrogate
needEscape = needEscape || (c >= '\uDC00' && c <= '\uDFFF' &&
(i == 0 || src[i - 1] < '\uD800' || src[i - 1] > '\uDBFF'));
needEscape = needEscape || c >= '\uDC00' && c <= '\uDFFF' &&
(i == 0 || src[i - 1] < '\uD800' || src[i - 1] > '\uDBFF');
// To produce valid JavaScript
needEscape = needEscape || c == '\u2028' || c == '\u2029';

View file

@ -6,7 +6,7 @@ using System.Timers;
using static MinecraftClient.Settings;
using static MinecraftClient.Settings.MainConfigHealper.MainConfig.AdvancedConfig;
namespace MinecraftClient.Protocol.Keys
namespace MinecraftClient.Protocol.ProfileKey
{
/// <summary>
/// Handle keys caching and storage.
@ -115,7 +115,7 @@ namespace MinecraftClient.Protocol.Keys
//User-editable keys cache file in text format
if (File.Exists(KeysCacheFilePlaintext))
{
if (Settings.Config.Logging.DebugMessages)
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_loading_keys, KeysCacheFilePlaintext));
try
@ -134,27 +134,27 @@ namespace MinecraftClient.Protocol.Keys
{
PlayerKeyPair playerKeyPair = PlayerKeyPair.FromString(value);
keys[login] = playerKeyPair;
if (Settings.Config.Logging.DebugMessages)
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_loaded_keys, playerKeyPair.ExpiresAt.ToString()));
}
catch (InvalidDataException e)
{
if (Settings.Config.Logging.DebugMessages)
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_ignore_string_keys, value, e.Message));
}
catch (FormatException e)
{
if (Settings.Config.Logging.DebugMessages)
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_ignore_string_keys, value, e.Message));
}
catch (ArgumentNullException e)
{
if (Settings.Config.Logging.DebugMessages)
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_ignore_string_keys, value, e.Message));
}
}
else if (Settings.Config.Logging.DebugMessages)
else if (Config.Logging.DebugMessages)
{
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_ignore_line_keys, line));
}

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.IO;
namespace MinecraftClient.Protocol.Keys
namespace MinecraftClient.Protocol.ProfileKey
{
public class PlayerKeyPair
{
@ -74,17 +74,17 @@ namespace MinecraftClient.Protocol.Keys
List<string> datas = new();
datas.Add(Convert.ToBase64String(PublicKey.Key));
if (PublicKey.Signature == null)
datas.Add(String.Empty);
datas.Add(string.Empty);
else
datas.Add(Convert.ToBase64String(PublicKey.Signature));
if (PublicKey.SignatureV2 == null)
datas.Add(String.Empty);
datas.Add(string.Empty);
else
datas.Add(Convert.ToBase64String(PublicKey.SignatureV2));
datas.Add(Convert.ToBase64String(PrivateKey.Key));
datas.Add(ExpiresAt.ToString(DataTimeFormat));
datas.Add(RefreshedAfter.ToString(DataTimeFormat));
return String.Join(",", datas.ToArray());
return string.Join(",", datas.ToArray());
}
}
}

View file

@ -3,7 +3,7 @@ using System.Security.Cryptography;
using MinecraftClient.Protocol.Message;
using static MinecraftClient.Protocol.Message.LastSeenMessageList;
namespace MinecraftClient.Protocol.Keys
namespace MinecraftClient.Protocol.ProfileKey
{
public class PrivateKey
{

View file

@ -2,7 +2,7 @@
using System.Security.Cryptography;
using MinecraftClient.Protocol.Message;
namespace MinecraftClient.Protocol.Keys
namespace MinecraftClient.Protocol.ProfileKey
{
public class PublicKey
{

View file

@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Authentication;
@ -193,7 +193,7 @@ namespace MinecraftClient.Protocol
response.Body = rbody ?? "";
response.StatusCode = statusCode;
response.Headers = headers;
try
{
stream.Close();

View file

@ -2,6 +2,7 @@
using System.IO;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using MinecraftClient.Scripting;
namespace MinecraftClient.Protocol.Session
{