[CharacterSwitch] Don't print error in chat when building DTR on unknown character

This commit is contained in:
Liza 2024-05-11 18:45:57 +02:00
parent 0fe6450ab1
commit ee9e43c707
Signed by: liza
GPG Key ID: 7199F8D727D55F67

View File

@ -75,7 +75,7 @@ internal sealed class CharacterSwitch : IDisposable
UpdateDtrBar(); UpdateDtrBar();
} }
private Target? FindCharacter(int direction) private Target? FindCharacter(int direction, bool showError = true)
{ {
_pluginLog.Verbose($"Switching characters ({direction})"); _pluginLog.Verbose($"Switching characters ({direction})");
@ -83,7 +83,8 @@ internal sealed class CharacterSwitch : IDisposable
int index = characterIds.IndexOf(_clientState.LocalContentId); int index = characterIds.IndexOf(_clientState.LocalContentId);
if (index < 0) if (index < 0)
{ {
_chatGui.PrintError("[KitchenSink] Current character not known."); if (showError)
_chatGui.PrintError("[KitchenSink] Current character not known.");
return null; return null;
} }
@ -94,7 +95,8 @@ internal sealed class CharacterSwitch : IDisposable
target = _autoRetainerApi.GetOfflineCharacterData(characterIds[index]); target = _autoRetainerApi.GetOfflineCharacterData(characterIds[index]);
if (target?.CID == _clientState.LocalContentId) if (target?.CID == _clientState.LocalContentId)
{ {
_chatGui.PrintError("[KitchenSink] No character to switch to found."); if (showError)
_chatGui.PrintError("[KitchenSink] No character to switch to found.");
return null; return null;
} }
@ -184,8 +186,8 @@ internal sealed class CharacterSwitch : IDisposable
{ {
_dtrBarEntry.Text = seIconChar.ToIconString(); _dtrBarEntry.Text = seIconChar.ToIconString();
var previous = FindCharacter(-1); var previous = FindCharacter(-1, showError: false);
var next = FindCharacter(1); var next = FindCharacter(1, showError: false);
if (previous != null && next != null) if (previous != null && next != null)
_dtrBarEntry.Tooltip = $"Prev: {previous.Name}\nNext: {next.Name}"; _dtrBarEntry.Tooltip = $"Prev: {previous.Name}\nNext: {next.Name}";
else if (previous != null) else if (previous != null)