forked from aers/EnemyListDebuffs
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEnemyListDebuffsPlugin.cs
100 lines (86 loc) · 3.61 KB
/
EnemyListDebuffsPlugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using Dalamud.Game.Command;
using Dalamud.Plugin;
using Lumina.Excel.Sheets;
using System.Collections.Generic;
using Dalamud.Game;
using Dalamud.Plugin.Services;
using EnemyListDebuffs.StatusNode;
namespace EnemyListDebuffs
{
public class EnemyListDebuffsPlugin : IDalamudPlugin
{
public string Name => "EnemyListDebuffs";
public IClientState ClientState { get; private set; } = null!;
public static ICommandManager CommandManager { get; private set; } = null!;
public IDalamudPluginInterface Interface { get; private set; } = null!;
public IDataManager DataManager { get; private set; } = null!;
public IFramework Framework { get; private set; } = null!;
public PluginAddressResolver Address { get; private set; } = null!;
public StatusNodeManager StatusNodeManager { get; private set; } = null!;
public static ISigScanner SigScanner { get; private set; } = null!;
public static AddonEnemyListHooks Hooks { get; private set; } = null!;
public EnemyListDebuffsPluginUI UI { get; private set; } = null!;
public EnemyListDebuffsPluginConfig Config { get; private set; } = null!;
public IGameInteropProvider GameInteropProvider { get; private set; } = null!;
public IAddonLifecycle AddonLifecycle { get; private set; } = null!;
public IPluginLog PluginLog { get; private set; } = null!;
internal bool InPvp;
public EnemyListDebuffsPlugin(
IClientState clientState,
ICommandManager commandManager,
IDalamudPluginInterface pluginInterface,
IDataManager dataManager,
IFramework framework,
ISigScanner sigScanner,
IGameInteropProvider gameInteropProvider,
IAddonLifecycle addonLifecycle,
IPluginLog pluginLog)
{
ClientState = clientState;
CommandManager = commandManager;
DataManager = dataManager;
Interface = pluginInterface;
Framework = framework;
SigScanner = sigScanner;
GameInteropProvider = gameInteropProvider;
AddonLifecycle = addonLifecycle;
PluginLog = pluginLog;
Config = pluginInterface.GetPluginConfig() as EnemyListDebuffsPluginConfig ?? new EnemyListDebuffsPluginConfig();
Config.Initialize(pluginInterface);
Address = new PluginAddressResolver(this);
Address.Setup(sigScanner);
StatusNodeManager = new StatusNodeManager(this);
Hooks = new AddonEnemyListHooks(this);
Hooks.Initialize();
UI = new EnemyListDebuffsPluginUI(this);
ClientState.TerritoryChanged += OnTerritoryChange;
CommandManager.AddHandler("/eldebuffs", new CommandInfo(this.ToggleConfig)
{
HelpMessage = "Toggles config window."
});
}
public void Dispose()
{
ClientState.TerritoryChanged -= OnTerritoryChange;
CommandManager.RemoveHandler("/eldebuffs");
UI.Dispose();
Hooks.Dispose();
StatusNodeManager.Dispose();
}
private void OnTerritoryChange(ushort e)
{
try
{
InPvp = DataManager.GetExcelSheet<TerritoryType>().GetRow(e).IsPvpZone;
}
catch (KeyNotFoundException)
{
PluginLog.Warning("Could not get territory for current zone");
}
}
private void ToggleConfig(string command, string args)
{
UI.ToggleConfig();
}
}
}