feat: inject properties before calling ctor

This commit is contained in:
goat 2021-08-24 00:39:17 +02:00
parent bed7973a95
commit 48081bba7d
No known key found for this signature in database
GPG key ID: F18F057873895461
3 changed files with 110 additions and 26 deletions

View file

@ -2,6 +2,7 @@ using System;
using Dalamud.Game.Command;
using Dalamud.Interface.Windowing;
using Dalamud.IoC;
using Dalamud.Logging;
using Dalamud.Plugin;
@ -17,6 +18,9 @@ namespace Dalamud.CorePlugin
// private Localization localizationManager;
[PluginService]
public static CommandManager CmdManager { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="PluginImpl"/> class.
/// </summary>
@ -33,7 +37,9 @@ namespace Dalamud.CorePlugin
this.Interface.UiBuilder.Draw += this.OnDraw;
this.Interface.UiBuilder.OpenConfigUi += this.OnOpenConfigUi;
Service<CommandManager>.Get().AddHandler("/di", new(this.OnCommand) { HelpMessage = $"Access the {this.Name} plugin." });
CmdManager.AddHandler("/coreplug", new(this.OnCommand) { HelpMessage = $"Access the {this.Name} plugin." });
PluginLog.Information("CorePlugin ctor!");
}
catch (Exception ex)
{
@ -52,7 +58,7 @@ namespace Dalamud.CorePlugin
/// <inheritdoc/>
public void Dispose()
{
Service<CommandManager>.Get().RemoveHandler("/di");
CmdManager.RemoveHandler("/coreplug");
this.Interface.UiBuilder.Draw -= this.OnDraw;
@ -92,6 +98,7 @@ namespace Dalamud.CorePlugin
private void OnCommand(string command, string args)
{
PluginLog.Information("Command called!");
// this.window.IsOpen = true;
}