mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
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
This commit is contained in:
parent
f15c000868
commit
db5faa22b1
5 changed files with 32 additions and 4 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -3636,9 +3636,13 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
/// Get max length for chat messages
|
||||
/// </summary>
|
||||
/// <returns>Max length, in characters</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the current protocol version.
|
||||
|
|
|
|||
|
|
@ -1703,6 +1703,15 @@ namespace MinecraftClient {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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..
|
||||
/// </summary>
|
||||
internal static string Main_Advanced_max_chat_message_length {
|
||||
get {
|
||||
return ResourceManager.GetString("Main.Advanced.max_chat_message_length", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Enable support for joining Minecraft Realms worlds..
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -655,6 +655,9 @@ Usage examples: "/tell <mybot> reco Player2", "/connect <serverip> P
|
|||
<data name="Main.Advanced.message_cooldown" xml:space="preserve">
|
||||
<value>Controls the minimum interval (in seconds) between sending each message to the server.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.max_chat_message_length" xml:space="preserve">
|
||||
<value>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.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.minecraft_realms" xml:space="preserve">
|
||||
<value>Enable support for joining Minecraft Realms worlds.</value>
|
||||
</data>
|
||||
|
|
|
|||
|
|
@ -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<string> BotOwners = new() { "Player1", "Player2" };
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue