Files
AetherBags/AetherBags/Plugin.cs
T
KnackAtNite 0d42a6a7dc
Debug Build and Test / Build against Latest Dalamud (push) Has been cancelled
Debug Build and Test / Build against Staging Dalamud (push) Has been cancelled
v1.0.2: Fix bags and settings auto-opening on login
Made-with: Cursor
2026-02-25 20:22:08 -05:00

120 lines
3.7 KiB
C#

using System.Numerics;
using AetherBags.Addons;
using AetherBags.Commands;
using AetherBags.Helpers;
using AetherBags.Hooks;
using AetherBags.Inventory;
using AetherBags.Inventory.Context;
using AetherBags.IPC;
using AetherBags.IPC.AetherBagsAPI;
using AetherBags.Monitoring;
using Dalamud.Plugin;
using KamiToolKit;
namespace AetherBags;
public class Plugin : IDalamudPlugin
{
private readonly CommandHandler _commandHandler;
private readonly InventoryHooks _inventoryHooks;
private readonly InventoryMonitor inventoryMonitor;
public Plugin(IDalamudPluginInterface pluginInterface)
{
pluginInterface.Create<Services>();
System.Config = Util.LoadConfigOrDefault();
BackupHelper.DoConfigBackup(pluginInterface);
KamiToolKitLibrary.Initialize(pluginInterface);
System.IPC = new IPCService();
System.IPC.UpdateUnifiedCategorySupport(System.Config.General.UseUnifiedExternalCategories);
ItemContextMenuHandler.Initialize();
System.LootedItemsTracker = new LootedItemsTracker();
System.AddonInventoryWindow = new AddonInventoryWindow
{
InternalName = "AetherBags_MainBags",
Title = "AetherBags",
Size = new Vector2(750, 750),
};
System.AddonSaddleBagWindow = new AddonSaddleBagWindow
{
InternalName = "AetherBags_SaddleBag",
Title = "AetherSaddlebag",
Size = new Vector2(750, 750),
};
System.AddonRetainerWindow = new AddonRetainerWindow
{
InternalName = "AetherBags_Retainer",
Title = "AetherRetainerbag",
Size = new Vector2(750, 750),
};
System.AddonConfigurationWindow = new AddonConfigurationWindow
{
InternalName = "AetherBags_Config",
Title = "AetherBags Config",
Size = new Vector2(640, 512),
};
Services.PluginInterface.UiBuilder.OpenMainUi += System.AddonInventoryWindow.Toggle;
Services.PluginInterface.UiBuilder.OpenConfigUi += System.AddonConfigurationWindow.Toggle;
System.AetherBagsAPI = new AetherBagsIPCProvider();
_commandHandler = new CommandHandler();
Services.ClientState.Login += OnLogin;
Services.ClientState.Logout += OnLogout;
if (Services.ClientState.IsLoggedIn) {
Services.Framework.RunOnFrameworkThread(OnLogin);
}
_inventoryHooks = new InventoryHooks();
inventoryMonitor = new InventoryMonitor();
}
public void Dispose()
{
InventoryAddonContextMenu.Close();
ItemContextMenuHandler.Dispose();
_inventoryHooks.Dispose();
inventoryMonitor.Dispose();
System.LootedItemsTracker.Dispose();
System.AetherBagsAPI?.Dispose();
System.IPC.Dispose();
HighlightState.ClearAll();
System.AddonInventoryWindow.Dispose();
System.AddonSaddleBagWindow.Dispose();
System.AddonRetainerWindow.Dispose();
System.AddonConfigurationWindow.Dispose();
Util.SaveConfig(System.Config);
KamiToolKitLibrary.Dispose();
}
private void OnLogin()
{
System.Config = Util.LoadConfigOrDefault();
System.IPC.UpdateUnifiedCategorySupport(System.Config.General.UseUnifiedExternalCategories);
System.LootedItemsTracker.Enable();
}
private void OnLogout(int type, int code)
{
Util.SaveConfig(System.Config);
System.LootedItemsTracker.Disable();
System.AddonInventoryWindow.Close();
System.AddonSaddleBagWindow.Close();
System.AddonRetainerWindow.Close();
System.AddonConfigurationWindow.Close();
}
}