refactor: use DI attributes

This commit is contained in:
Anna 2021-08-23 20:44:03 -04:00
parent 3a6bd7c5a0
commit 6d3cf6665b
2 changed files with 18 additions and 20 deletions

View File

@ -4,6 +4,7 @@ using System;
using Dalamud.Data; using Dalamud.Data;
using Dalamud.Game; using Dalamud.Game;
using Dalamud.Game.Gui; using Dalamud.Game.Gui;
using Dalamud.IoC;
namespace Globetrotter { namespace Globetrotter {
// ReSharper disable once ClassNeverInstantiated.Global // ReSharper disable once ClassNeverInstantiated.Global
@ -12,29 +13,26 @@ namespace Globetrotter {
public string Name => "Globetrotter"; public string Name => "Globetrotter";
private DalamudPluginInterface Interface { get; } [PluginService]
private CommandManager CommandManager { get; } private DalamudPluginInterface Interface { get; init; } = null!;
internal DataManager DataManager { get; }
internal GameGui GameGui { get; } [PluginService]
internal SigScanner SigScanner { get; } 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; } internal Configuration Config { get; }
private PluginUi Ui { get; } private PluginUi Ui { get; }
private TreasureMaps Maps { get; } private TreasureMaps Maps { get; }
public GlobetrotterPlugin( 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;
this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration(); this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
this.Config.Initialize(this.Interface); this.Config.Initialize(this.Interface);

View File

@ -21,7 +21,7 @@ namespace Globetrotter {
var mapToRow = new Dictionary<uint, uint>(); var mapToRow = new Dictionary<uint, uint>();
foreach (var rank in this.Plugin.DataManager.GetExcelSheet<TreasureHuntRank>()) { foreach (var rank in this.Plugin.DataManager.GetExcelSheet<TreasureHuntRank>()!) {
var unopened = rank.ItemName.Value; var unopened = rank.ItemName.Value;
if (unopened == null) { if (unopened == null) {
continue; continue;
@ -143,7 +143,7 @@ namespace Globetrotter {
return; return;
} }
var spot = this.Plugin.DataManager.GetExcelSheet<TreasureSpot>().GetRow(rowId, packet.SubRowId); var spot = this.Plugin.DataManager.GetExcelSheet<TreasureSpot>()!.GetRow(rowId, packet.SubRowId);
var loc = spot?.Location?.Value; var loc = spot?.Location?.Value;
var map = loc?.Map?.Value; var map = loc?.Map?.Value;