diff --git a/Dalamud/Game/Gui/Dtr/DtrBar.cs b/Dalamud/Game/Gui/Dtr/DtrBar.cs
index 779dbf7f9..55b2573f0 100644
--- a/Dalamud/Game/Gui/Dtr/DtrBar.cs
+++ b/Dalamud/Game/Gui/Dtr/DtrBar.cs
@@ -76,6 +76,17 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
this.configuration.QueueSave();
}
+ ///
+ /// Event type fired each time a DtrEntry was removed.
+ ///
+ /// The title of the bar entry.
+ internal delegate void DtrEntryRemovedDelegate(string title);
+
+ ///
+ /// Event fired each time a DtrEntry was removed.
+ ///
+ internal event DtrEntryRemovedDelegate? DtrEntryRemoved;
+
///
public IReadOnlyList Entries => this.entries;
@@ -136,6 +147,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
if (data.ShouldBeRemoved)
{
this.RemoveEntry(data);
+ this.DtrEntryRemoved?.Invoke(data.Title);
}
}
@@ -525,7 +537,6 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
/// Plugin-scoped version of a AddonEventManager service.
///
[PluginInterface]
-
[ServiceManager.ScopedService]
#pragma warning disable SA1015
[ResolveVia]
@@ -536,13 +547,23 @@ internal class DtrBarPluginScoped : IInternalDisposableService, IDtrBar
private readonly DtrBar dtrBarService = Service.Get();
private readonly Dictionary pluginEntries = new();
-
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ internal DtrBarPluginScoped()
+ {
+ this.dtrBarService.DtrEntryRemoved += this.OnDtrEntryRemoved;
+ }
+
///
public IReadOnlyList Entries => this.dtrBarService.Entries;
///
void IInternalDisposableService.DisposeService()
{
+ this.dtrBarService.DtrEntryRemoved -= this.OnDtrEntryRemoved;
+
foreach (var entry in this.pluginEntries)
{
entry.Value.Remove();
@@ -569,4 +590,9 @@ internal class DtrBarPluginScoped : IInternalDisposableService, IDtrBar
this.pluginEntries.Remove(title);
}
}
+
+ private void OnDtrEntryRemoved(string title)
+ {
+ this.pluginEntries.Remove(title);
+ }
}