diff --git a/PenumbraIpc.cs b/PenumbraIpc.cs
index fb4823e..06a61fd 100644
--- a/PenumbraIpc.cs
+++ b/PenumbraIpc.cs
@@ -51,6 +51,9 @@ internal class PenumbraIpc : IDisposable {
// events
+ ///
+ private EventSubscriber InitializedEvent { get; set; }
+
///
private EventSubscriber? ModAddedEvent { get; set; }
@@ -91,15 +94,27 @@ internal PenumbraIpc(Plugin plugin) {
}
public void Dispose() {
+ this.UnregisterEvents();
+ }
+
+ private void ReregisterEvents() {
+ this.UnregisterEvents();
+ this.RegisterEvents();
+ }
+
+ private void UnregisterEvents() {
this.PreSettingsDrawEvent?.Dispose();
this.PreSettingsTabBarDrawEvent?.Dispose();
this.PostEnabledDrawEvent?.Dispose();
this.ModMovedEvent?.Dispose();
this.ModDeletedEvent?.Dispose();
this.ModAddedEvent?.Dispose();
+ this.InitializedEvent?.Dispose();
}
private void RegisterEvents() {
+ this.InitializedEvent = Penumbra.Api.Ipc.Initialized.Subscriber(this.Plugin.Interface, this.ReregisterEvents);
+
this.ModAddedEvent = Penumbra.Api.Ipc.ModAdded.Subscriber(this.Plugin.Interface, _ => {
Task.Run(async () => await this.Plugin.State.UpdatePackages());
});