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.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);

View File

@ -21,7 +21,7 @@ namespace Globetrotter {
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;
if (unopened == null) {
continue;
@ -143,7 +143,7 @@ namespace Globetrotter {
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 map = loc?.Map?.Value;