Instead of '>'/'<' for partial messages, use ' >'/' <'. Also support fCraft's ' /'/' \' partial messages. Fixes #399.

This commit is contained in:
UnknownShadow200 2017-08-03 23:06:48 +10:00
parent 74a08df332
commit eb94e5f333
2 changed files with 15 additions and 7 deletions

View File

@ -33,7 +33,7 @@ namespace MCGalaxy.Network {
void ReceiveNextAsync();
/// <summary> Sends a block of data, either synchronously or asynchronously. </summary>
void Send(byte[] buffer, bool sync = false);
void Send(byte[] buffer, bool sync);
/// <summary> Sends a block of low-priority data, either synchronously or asynchronously. </summary>
void SendLowPriority(byte[] buffer);

View File

@ -189,7 +189,7 @@ namespace MCGalaxy {
int processedLen = 0;
try {
while (processedLen < bufferLen) {
int packetLen = PacketSize(buffer[processedLen]);
int packetLen = PacketSize(buffer[processedLen]);
if (packetLen == -1) return -1;
// Partial packet data received
@ -499,17 +499,17 @@ namespace MCGalaxy {
text = text.Replace("^detail.user=", "");
}
if (partialMessage.Length > 0 && !text.EndsWith(">") && !text.EndsWith("<")) {
if (partialMessage.Length > 0 && !(IsPartialSpaced(text) || IsPartialJoined(text))) {
text = partialMessage + text;
partialMessage = "";
}
if (text.EndsWith(">")) {
partialMessage += text.Substring(0, text.Length - 1) + " ";
if (IsPartialSpaced(text)) {
partialMessage += text.Substring(0, text.Length - 2) + " ";
SendMessage(Colors.teal + "Partial message: &f" + partialMessage);
return true;
} else if (text.EndsWith("<")) {
partialMessage += text.Substring(0, text.Length - 1);
} else if (IsPartialJoined(text)) {
partialMessage += text.Substring(0, text.Length - 2);
SendMessage(Colors.teal + "Partial message: &f" + partialMessage);
return true;
}
@ -522,6 +522,14 @@ namespace MCGalaxy {
return text.Length == 0;
}
static bool IsPartialSpaced(string text) {
return text.EndsWith(" >") || text.EndsWith(" /");
}
static bool IsPartialJoined(string text) {
return text.EndsWith(" <") || text.EndsWith(" \\");
}
bool DoCommand(string text) {
// Typing / repeats last command executed
if (text == "/") {