feat: Suppress duplicate active effect notifications

This commit is contained in:
Anon 2026-04-15 18:42:14 +02:00 committed by GitHub
commit e511d33452
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 49 additions and 12 deletions

View file

@ -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()));
}
/// <summary>
/// Called when an entity effects
/// </summary>
@ -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));

View file

@ -735,6 +735,9 @@ Usage examples: "/tell &lt;mybot&gt; connect Server1", "/connect Server2"</value
<data name="Main.Advanced.show_inventory_layout" xml:space="preserve">
<value>Show inventory layout as ASCII art in inventory command.</value>
</data>
<data name="Main.Advanced.show_effect_messages" xml:space="preserve">
<value>Show chat notifications when your active effects are gained or expire. Set to false to disable these messages entirely.</value>
</data>
<data name="Main.Advanced.show_effect_names_in_tui" xml:space="preserve">
<value>Show full effect names and levels in the TUI status bar instead of compact effect icons only.</value>
</data>

View file

@ -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;

View file

@ -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:**