mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Update ChatParser.cs
This commit is contained in:
parent
c5dc517c43
commit
074a62f804
1 changed files with 12 additions and 9 deletions
|
|
@ -63,16 +63,19 @@ namespace MinecraftClient.Protocol.Message
|
|||
/// <param name="json">JSON serialized text</param>
|
||||
/// <param name="links">Optional container for links from JSON serialized text</param>
|
||||
/// <returns>Returns the translated text</returns>
|
||||
public static string ParseText(string json, List<string>? links = null)
|
||||
public static string ParseText(string json, List<string>? links = null)
|
||||
{
|
||||
return JSONData2String(Json.ParseJson(json), "", links);
|
||||
var isJson = false;
|
||||
try
|
||||
{
|
||||
isJson = JsonDocument.Parse(json) != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
isJson = false;
|
||||
}
|
||||
return !isJson ? json : JSONData2String(Json.ParseJson(json), "", links);
|
||||
}
|
||||
|
||||
public static string ParseText(Dictionary<string, object> nbt)
|
||||
{
|
||||
return NbtToString(nbt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The main function to convert text from MC 1.9+ JSON to MC 1.5.2 formatted text
|
||||
/// </summary>
|
||||
|
|
@ -551,4 +554,4 @@ namespace MinecraftClient.Protocol.Message
|
|||
return colorCode + message + extraBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue