From db5faa22b103bde664c79c5d0444ade60db3790a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 18:50:01 +0000 Subject: [PATCH] Add configurable MaxChatMessageLength to override default limits for older versions Adds a MaxChatMessageLength config option under [Main.Advanced] that allows users to override the protocol-defined maximum chat message length. Default is 0 (auto: 100 for MC 1.10 and below, 256 for MC 1.11+). Some servers like Hypixel support longer messages on older versions, so this lets users set a custom limit (e.g. 256 on 1.8.9). Includes a warning about potential kicks if set incorrectly. Closes #2947 Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com> Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/39c78e6a-f748-4f41-a905-2f5d27f99eff --- MinecraftClient/Protocol/Handlers/Protocol16.cs | 3 ++- MinecraftClient/Protocol/Handlers/Protocol18.cs | 10 +++++++--- .../ConfigComments/ConfigComments.Designer.cs | 9 +++++++++ .../Resources/ConfigComments/ConfigComments.resx | 3 +++ MinecraftClient/Settings.cs | 11 +++++++++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol16.cs b/MinecraftClient/Protocol/Handlers/Protocol16.cs index 21d2a488..8f8a8723 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol16.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol16.cs @@ -696,7 +696,8 @@ namespace MinecraftClient.Protocol.Handlers public int GetMaxChatMessageLength() { - return 100; + int configOverride = Settings.MainConfigHelper.Config.Advanced.MaxChatMessageLength; + return configOverride > 0 ? configOverride : 100; } public int GetProtocolVersion() diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 31ae3394..29fbc601 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -3636,9 +3636,13 @@ namespace MinecraftClient.Protocol.Handlers /// Get max length for chat messages /// /// Max length, in characters - public int GetMaxChatMessageLength() => protocolVersion > MC_1_10_Version - ? 256 - : 100; + public int GetMaxChatMessageLength() + { + int configOverride = Settings.MainConfigHelper.Config.Advanced.MaxChatMessageLength; + if (configOverride > 0) + return configOverride; + return protocolVersion > MC_1_10_Version ? 256 : 100; + } /// /// Get the current protocol version. diff --git a/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs b/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs index 91cd1cb1..43d81d95 100644 --- a/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs +++ b/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs @@ -1703,6 +1703,15 @@ namespace MinecraftClient { } } + /// + /// Looks up a localized string similar to Override the maximum chat message length. Set to 0 to use the default (100 for 1.10 and below, 256 for 1.11+). WARNING: Setting this incorrectly may cause you to be kicked from the server.. + /// + internal static string Main_Advanced_max_chat_message_length { + get { + return ResourceManager.GetString("Main.Advanced.max_chat_message_length", resourceCulture); + } + } + /// /// Looks up a localized string similar to Enable support for joining Minecraft Realms worlds.. /// diff --git a/MinecraftClient/Resources/ConfigComments/ConfigComments.resx b/MinecraftClient/Resources/ConfigComments/ConfigComments.resx index edbfc7af..454f78de 100644 --- a/MinecraftClient/Resources/ConfigComments/ConfigComments.resx +++ b/MinecraftClient/Resources/ConfigComments/ConfigComments.resx @@ -655,6 +655,9 @@ Usage examples: "/tell <mybot> reco Player2", "/connect <serverip> P Controls the minimum interval (in seconds) between sending each message to the server. + + Override the maximum chat message length. Set to 0 to use the default (100 for 1.10 and below, 256 for 1.11+). WARNING: Setting this incorrectly may cause you to be kicked from the server. + Enable support for joining Minecraft Realms worlds. diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index 2b11637e..5dd1f4c5 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -422,6 +422,14 @@ namespace MinecraftClient if (Advanced.MessageCooldown < 0) Advanced.MessageCooldown = 0; + if (Advanced.MaxChatMessageLength < 0) + Advanced.MaxChatMessageLength = 0; + else if (Advanced.MaxChatMessageLength > 32767) + Advanced.MaxChatMessageLength = 32767; + + if (Advanced.MaxChatMessageLength > 0) + ConsoleIO.WriteLineFormatted("§e[Settings] MaxChatMessageLength is set to " + Advanced.MaxChatMessageLength + ". Setting this incorrectly may cause you to be kicked from the server."); + if (Advanced.TcpTimeout < 1) Advanced.TcpTimeout = 1; @@ -529,6 +537,9 @@ namespace MinecraftClient [TomlInlineComment("$Main.Advanced.message_cooldown$")] public double MessageCooldown = 1.0; + [TomlInlineComment("$Main.Advanced.max_chat_message_length$")] + public int MaxChatMessageLength = 0; + [TomlInlineComment("$Main.Advanced.bot_owners$")] public List BotOwners = new() { "Player1", "Player2" };