mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Minecraft 1.11: Raise chat message max length to 256
This commit is contained in:
parent
8ec2b2e570
commit
609b939159
4 changed files with 30 additions and 6 deletions
|
|
@ -538,21 +538,22 @@ namespace MinecraftClient
|
||||||
/// <returns>True if the text was sent with no error</returns>
|
/// <returns>True if the text was sent with no error</returns>
|
||||||
public bool SendText(string text)
|
public bool SendText(string text)
|
||||||
{
|
{
|
||||||
if (text.Length > 100) //Message is too long?
|
int maxLength = handler.GetMaxChatMessageLength();
|
||||||
|
if (text.Length > maxLength) //Message is too long?
|
||||||
{
|
{
|
||||||
if (text[0] == '/')
|
if (text[0] == '/')
|
||||||
{
|
{
|
||||||
//Send the first 100 chars of the command
|
//Send the first 100/256 chars of the command
|
||||||
text = text.Substring(0, 100);
|
text = text.Substring(0, maxLength);
|
||||||
return handler.SendChatMessage(text);
|
return handler.SendChatMessage(text);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Send the message splitted into several messages
|
//Send the message splitted into several messages
|
||||||
while (text.Length > 100)
|
while (text.Length > maxLength)
|
||||||
{
|
{
|
||||||
handler.SendChatMessage(text.Substring(0, 100));
|
handler.SendChatMessage(text.Substring(0, maxLength));
|
||||||
text = text.Substring(100, text.Length - 100);
|
text = text.Substring(maxLength, text.Length - maxLength);
|
||||||
if (Settings.splitMessageDelay.TotalSeconds > 0)
|
if (Settings.splitMessageDelay.TotalSeconds > 0)
|
||||||
Thread.Sleep(Settings.splitMessageDelay);
|
Thread.Sleep(Settings.splitMessageDelay);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -586,6 +586,11 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
catch (System.IO.IOException) { }
|
catch (System.IO.IOException) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetMaxChatMessageLength()
|
||||||
|
{
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
|
||||||
public bool SendChatMessage(string message)
|
public bool SendChatMessage(string message)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(message))
|
if (String.IsNullOrEmpty(message))
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
private const int MC19Version = 107;
|
private const int MC19Version = 107;
|
||||||
private const int MC191Version = 108;
|
private const int MC191Version = 108;
|
||||||
private const int MC110Version = 210;
|
private const int MC110Version = 210;
|
||||||
|
private const int MC111Version = 315;
|
||||||
|
|
||||||
private int compression_treshold = 0;
|
private int compression_treshold = 0;
|
||||||
private bool autocomplete_received = false;
|
private bool autocomplete_received = false;
|
||||||
|
|
@ -1411,6 +1412,17 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get max length for chat messages
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Max length, in characters</returns>
|
||||||
|
public int GetMaxChatMessageLength()
|
||||||
|
{
|
||||||
|
return protocolversion >= MC111Version
|
||||||
|
? 256
|
||||||
|
: 100;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send a chat message to the server
|
/// Send a chat message to the server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,12 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="message">Reason</param>
|
/// <param name="message">Reason</param>
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get max length for chat messages
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Max length, in characters</returns>
|
||||||
|
int GetMaxChatMessageLength();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send a chat message or command to the server
|
/// Send a chat message or command to the server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue