Allow access to raw JSON messages from ChatBot

See #275
This commit is contained in:
ORelio 2017-05-31 20:54:16 +02:00
parent 7c9c12bee7
commit dc09896959
8 changed files with 28 additions and 11 deletions

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MinecraftClient.Protocol.Handlers
namespace MinecraftClient.Protocol
{
/// <summary>
/// This class parses JSON chat data from MC 1.6+ and returns the appropriate string to be printed.

View file

@ -88,9 +88,7 @@ namespace MinecraftClient.Protocol.Handlers
case 0x02: readData(1); readNextString(); readNextString(); readData(4); break;
case 0x03:
string message = readNextString();
List<string> links = new List<string>();
if (protocolversion >= 72) { message = ChatParser.ParseText(message, links); }
handler.OnTextReceived(message, links); break;
handler.OnTextReceived(message, protocolversion >= 72); break;
case 0x04: readData(16); break;
case 0x05: readData(6); readNextItemSlot(); break;
case 0x06: readData(12); break;

View file

@ -258,8 +258,7 @@ namespace MinecraftClient.Protocol.Handlers
break;
}
catch (ArgumentOutOfRangeException) { /* No message type */ }
List<string> links = new List<string>();
handler.OnTextReceived(ChatParser.ParseText(message, links), links);
handler.OnTextReceived(message, true);
break;
case PacketIncomingType.Respawn:
this.currentDimension = readNextInt(packetData);

View file

@ -35,8 +35,8 @@ namespace MinecraftClient.Protocol
/// This method is called when the protocol handler receives a chat message
/// </summary>
/// <param name="text">Text received from the server</param>
/// <param name="links">Links embedded in text (for click events)</param>
void OnTextReceived(string text, IEnumerable<string> links);
/// <param name="isJson">TRUE if the text is JSON-Encoded</param>
void OnTextReceived(string text, bool isJson);
/// <summary>
/// This method is called when a new player joins the game