fully fix PlayerPayload problem for own character

This commit is contained in:
2022-09-15 22:26:50 +02:00
parent 248ef429d4
commit 0ffc845083
3 changed files with 9 additions and 16 deletions

View File

@@ -257,6 +257,13 @@ namespace PlayerTags.Features
ApplyStringChanges(message, stringChanges, stringMatch.PreferredPayload);
}
// Replace PlayerPayloads of your own character with TextPayloads
foreach (var payload in message.Payloads.ToArray())
{
if (payload is PlayerPayload playerPayload && playerPayload.PlayerName.Contains(PluginServices.ClientState.LocalPlayer.Name.TextValue))
message.Payloads.Remove(payload);
}
}
}
}

View File

@@ -116,9 +116,8 @@ namespace PlayerTags.Features
// Normally used to end PlayerPayload linking. But for the own player it has no affect. Anyway, use it, just because. Maybe it's needed in the future somewhere else.
seString.Payloads.Insert(++playerPayloadIndex, RawPayload.LinkTerminator);
// Remove the text payload (display text)
if (ShouldRemovePlayerNameTextPayload?.Invoke(this) ?? true)
seString.Payloads.Remove(playerTextPayload);
// The PlayerPayload is just temporary. We keep the TextPayload.
// The PayerPayload gets removed at the ChatTagTargetFeature at the end.
}
}
}

View File

@@ -44,7 +44,6 @@ namespace PlayerTags
UiBuilder_OpenConfigUi();
}) { HelpMessage = "Shows the config" });
m_LinkSelfInChatFeature = new LinkSelfInChatFeature(m_PluginConfiguration, m_PluginData);
m_LinkSelfInChatFeature.ShouldRemovePlayerNameTextPayload += LinkSelfInChatFeature_ShouldRemovePlayerNameTextPayload;
m_CustomTagsContextMenuFeature = new CustomTagsContextMenuFeature(m_PluginConfiguration, m_PluginData);
m_NameplatesTagTargetFeature = new NameplateTagTargetFeature(m_PluginConfiguration, m_PluginData);
m_ChatTagTargetFeature = new ChatTagTargetFeature(m_PluginConfiguration, m_PluginData);
@@ -62,18 +61,6 @@ namespace PlayerTags
PluginServices.DalamudPluginInterface.UiBuilder.Draw -= UiBuilder_Draw;
}
private bool LinkSelfInChatFeature_ShouldRemovePlayerNameTextPayload(object sender)
{
return !IsChatTwoActive();
}
private bool IsChatTwoActive()
{
var file = Path.Combine(Path.GetDirectoryName(PluginServices.DalamudPluginInterface.ConfigDirectory.FullName), @"ChatTwo\chat-log.db");
var exists = File.Exists(file);
return exists;
}
private void DalamudPluginInterface_LanguageChanged(string langCode)
{
Localizer.SetLanguage(langCode);