mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Suppress duplicate active effect notifications
Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/8649d41a-e2aa-4fdd-aee8-96f4b35c9be0 Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
This commit is contained in:
parent
b445d2bdec
commit
443f4874df
3 changed files with 37 additions and 12 deletions
|
|
@ -741,7 +741,7 @@ namespace MinecraftClient
|
||||||
if (!playerEffects.Remove(effect, out var effectData))
|
if (!playerEffects.Remove(effect, out var effectData))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ConsoleIO.WriteLine(string.Format(Translations.bot_effect_expired, effectData.GetDisplayName()));
|
AnnouncePlayerEffectExpired(effectData);
|
||||||
|
|
||||||
if (entities.TryGetValue(playerEntityID, out var playerEntity))
|
if (entities.TryGetValue(playerEntityID, out var playerEntity))
|
||||||
playerEntity.ActiveEffects.Remove(effect);
|
playerEntity.ActiveEffects.Remove(effect);
|
||||||
|
|
@ -3830,6 +3830,33 @@ namespace MinecraftClient
|
||||||
DispatchBotEvent(bot => bot.OnEntitySpawn(entity));
|
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>
|
/// <summary>
|
||||||
/// Called when an entity effects
|
/// Called when an entity effects
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -3849,16 +3876,8 @@ namespace MinecraftClient
|
||||||
playerEffects.TryGetValue(effect, out var previousPlayerEffect);
|
playerEffects.TryGetValue(effect, out var previousPlayerEffect);
|
||||||
playerEffects[effect] = effectData;
|
playerEffects[effect] = effectData;
|
||||||
|
|
||||||
bool shouldAnnounceEffectGain = previousPlayerEffect is null
|
if (ShouldAnnouncePlayerEffectGain(effectData, previousPlayerEffect))
|
||||||
|| previousPlayerEffect.Amplifier != amplifier
|
AnnouncePlayerEffectGain(effectData);
|
||||||
|| (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 (entity is not null)
|
if (entity is not null)
|
||||||
|
|
@ -3886,7 +3905,7 @@ namespace MinecraftClient
|
||||||
removedEffectData ??= playerEffectData;
|
removedEffectData ??= playerEffectData;
|
||||||
|
|
||||||
if (entityid == playerEntityID && removedEffectData is not null)
|
if (entityid == playerEntityID && removedEffectData is not null)
|
||||||
ConsoleIO.WriteLine(string.Format(Translations.bot_effect_expired, removedEffectData.GetDisplayName()));
|
AnnouncePlayerEffectExpired(removedEffectData);
|
||||||
|
|
||||||
if (entity is not null)
|
if (entity is not null)
|
||||||
DispatchBotEvent(bot => bot.OnRemoveEntityEffect(entity, effect));
|
DispatchBotEvent(bot => bot.OnRemoveEntityEffect(entity, effect));
|
||||||
|
|
|
||||||
|
|
@ -735,6 +735,9 @@ Usage examples: "/tell <mybot> connect Server1", "/connect Server2"</value
|
||||||
<data name="Main.Advanced.show_inventory_layout" xml:space="preserve">
|
<data name="Main.Advanced.show_inventory_layout" xml:space="preserve">
|
||||||
<value>Show inventory layout as ASCII art in inventory command.</value>
|
<value>Show inventory layout as ASCII art in inventory command.</value>
|
||||||
</data>
|
</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">
|
<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>
|
<value>Show full effect names and levels in the TUI status bar instead of compact effect icons only.</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
||||||
|
|
@ -817,6 +817,9 @@ namespace MinecraftClient
|
||||||
[TomlInlineComment("$Main.Advanced.show_inventory_layout$")]
|
[TomlInlineComment("$Main.Advanced.show_inventory_layout$")]
|
||||||
public bool ShowInventoryLayout = true;
|
public bool ShowInventoryLayout = true;
|
||||||
|
|
||||||
|
[TomlInlineComment("$Main.Advanced.show_effect_messages$")]
|
||||||
|
public bool ShowEffectMessages = true;
|
||||||
|
|
||||||
[TomlInlineComment("$Main.Advanced.show_effect_names_in_tui$")]
|
[TomlInlineComment("$Main.Advanced.show_effect_names_in_tui$")]
|
||||||
public bool ShowEffectNamesInTUI = false;
|
public bool ShowEffectNamesInTUI = false;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue