diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index dc76441b..3ba651a5 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -741,7 +741,7 @@ namespace MinecraftClient if (!playerEffects.Remove(effect, out var effectData)) continue; - ConsoleIO.WriteLine(string.Format(Translations.bot_effect_expired, effectData.GetDisplayName())); + AnnouncePlayerEffectExpired(effectData); if (entities.TryGetValue(playerEntityID, out var playerEntity)) playerEntity.ActiveEffects.Remove(effect); @@ -3830,6 +3830,33 @@ namespace MinecraftClient DispatchBotEvent(bot => bot.OnEntitySpawn(entity)); } + private static bool ShouldAnnouncePlayerEffectGain(EffectData effectData, EffectData? previousPlayerEffect) + { + if (!Config.Main.Advanced.ShowEffectMessages) + return false; + + return previousPlayerEffect is null + || previousPlayerEffect.IsExpired + || previousPlayerEffect.Amplifier != effectData.Amplifier; + } + + private static void AnnouncePlayerEffectGain(EffectData effectData) + { + if (!Config.Main.Advanced.ShowEffectMessages) + return; + + ConsoleIO.WriteLine(string.Format(Translations.bot_effect_gained, + effectData.GetDisplayNameWithArticle(), effectData.GetInitialDurationText())); + } + + private static void AnnouncePlayerEffectExpired(EffectData effectData) + { + if (!Config.Main.Advanced.ShowEffectMessages) + return; + + ConsoleIO.WriteLine(string.Format(Translations.bot_effect_expired, effectData.GetDisplayName())); + } + /// /// Called when an entity effects /// @@ -3849,16 +3876,8 @@ namespace MinecraftClient playerEffects.TryGetValue(effect, out var previousPlayerEffect); playerEffects[effect] = effectData; - bool shouldAnnounceEffectGain = previousPlayerEffect is null - || previousPlayerEffect.Amplifier != amplifier - || (effectData.IsInfinite && !previousPlayerEffect.IsInfinite) - || (!effectData.IsInfinite && duration > previousPlayerEffect.RemainingTicks + 20); - - if (shouldAnnounceEffectGain) - { - ConsoleIO.WriteLine(string.Format(Translations.bot_effect_gained, - effectData.GetDisplayNameWithArticle(), effectData.GetInitialDurationText())); - } + if (ShouldAnnouncePlayerEffectGain(effectData, previousPlayerEffect)) + AnnouncePlayerEffectGain(effectData); } if (entity is not null) @@ -3886,7 +3905,7 @@ namespace MinecraftClient removedEffectData ??= playerEffectData; if (entityid == playerEntityID && removedEffectData is not null) - ConsoleIO.WriteLine(string.Format(Translations.bot_effect_expired, removedEffectData.GetDisplayName())); + AnnouncePlayerEffectExpired(removedEffectData); if (entity is not null) DispatchBotEvent(bot => bot.OnRemoveEntityEffect(entity, effect)); diff --git a/MinecraftClient/Resources/ConfigComments/ConfigComments.resx b/MinecraftClient/Resources/ConfigComments/ConfigComments.resx index 4ff326dd..ff52ffe3 100644 --- a/MinecraftClient/Resources/ConfigComments/ConfigComments.resx +++ b/MinecraftClient/Resources/ConfigComments/ConfigComments.resx @@ -735,6 +735,9 @@ Usage examples: "/tell <mybot> connect Server1", "/connect Server2" Show inventory layout as ASCII art in inventory command. + + Show chat notifications when your active effects are gained or expire. Set to false to disable these messages entirely. + Show full effect names and levels in the TUI status bar instead of compact effect icons only. diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index c4b264f2..73d0d4db 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -817,6 +817,9 @@ namespace MinecraftClient [TomlInlineComment("$Main.Advanced.show_inventory_layout$")] public bool ShowInventoryLayout = true; + [TomlInlineComment("$Main.Advanced.show_effect_messages$")] + public bool ShowEffectMessages = true; + [TomlInlineComment("$Main.Advanced.show_effect_names_in_tui$")] public bool ShowEffectNamesInTUI = false; diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index acb1ba55..1cb03726 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -503,6 +503,18 @@ Coordinate = { x = 145, y = 64, z = 2045 } - **Default:** `true` +#### `ShowEffectMessages` + +- **Description:** + + This setting controls whether MCC prints messages when one of your active effects is gained or expires. + + Set it to `false` if a beacon or another repeated effect source is spamming the console. + +- **Type:** `boolean` + +- **Default:** `true` + #### `ShowEffectNamesInTUI` - **Description:**