From 6d3cf6665b624795085680d652ab3e4cf0d69ea0 Mon Sep 17 00:00:00 2001 From: Anna Date: Mon, 23 Aug 2021 20:44:03 -0400 Subject: [PATCH] refactor: use DI attributes --- Globetrotter/GlobetrotterPlugin.cs | 34 ++++++++++++++---------------- Globetrotter/TreasureMaps.cs | 4 ++-- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Globetrotter/GlobetrotterPlugin.cs b/Globetrotter/GlobetrotterPlugin.cs index 79bbf98..312be2b 100644 --- a/Globetrotter/GlobetrotterPlugin.cs +++ b/Globetrotter/GlobetrotterPlugin.cs @@ -4,6 +4,7 @@ using System; using Dalamud.Data; using Dalamud.Game; using Dalamud.Game.Gui; +using Dalamud.IoC; namespace Globetrotter { // ReSharper disable once ClassNeverInstantiated.Global @@ -12,29 +13,26 @@ namespace Globetrotter { public string Name => "Globetrotter"; - private DalamudPluginInterface Interface { get; } - private CommandManager CommandManager { get; } - internal DataManager DataManager { get; } - internal GameGui GameGui { get; } - internal SigScanner SigScanner { get; } + [PluginService] + private DalamudPluginInterface Interface { get; init; } = null!; + + [PluginService] + private CommandManager CommandManager { get; init; } = null!; + + [PluginService] + internal DataManager DataManager { get; init; } = null!; + + [PluginService] + internal GameGui GameGui { get; init; } = null!; + + [PluginService] + internal SigScanner SigScanner { get; init; } = null!; internal Configuration Config { get; } private PluginUi Ui { get; } private TreasureMaps Maps { get; } - public GlobetrotterPlugin( - DalamudPluginInterface pluginInterface, - CommandManager commandManager, - DataManager dataManager, - GameGui gameGui, - SigScanner scanner - ) { - this.Interface = pluginInterface; - this.CommandManager = commandManager; - this.DataManager = dataManager; - this.GameGui = gameGui; - this.SigScanner = scanner; - + public GlobetrotterPlugin() { this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration(); this.Config.Initialize(this.Interface); diff --git a/Globetrotter/TreasureMaps.cs b/Globetrotter/TreasureMaps.cs index 8677db3..721b787 100644 --- a/Globetrotter/TreasureMaps.cs +++ b/Globetrotter/TreasureMaps.cs @@ -21,7 +21,7 @@ namespace Globetrotter { var mapToRow = new Dictionary(); - foreach (var rank in this.Plugin.DataManager.GetExcelSheet()) { + foreach (var rank in this.Plugin.DataManager.GetExcelSheet()!) { var unopened = rank.ItemName.Value; if (unopened == null) { continue; @@ -143,7 +143,7 @@ namespace Globetrotter { return; } - var spot = this.Plugin.DataManager.GetExcelSheet().GetRow(rowId, packet.SubRowId); + var spot = this.Plugin.DataManager.GetExcelSheet()!.GetRow(rowId, packet.SubRowId); var loc = spot?.Location?.Value; var map = loc?.Map?.Value;