From 9ba9e049fb8b07b16859dfabe0d208b66bab8f33 Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Tue, 14 Jun 2022 14:49:58 +0200 Subject: [PATCH] avoid static where reasonable --- Glamourer/Api/GlamourerIpc.cs | 7 ++++--- Glamourer/Glamourer.cs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Glamourer/Api/GlamourerIpc.cs b/Glamourer/Api/GlamourerIpc.cs index 62bd0cc..98e2f3a 100644 --- a/Glamourer/Api/GlamourerIpc.cs +++ b/Glamourer/Api/GlamourerIpc.cs @@ -16,15 +16,16 @@ namespace Glamourer.Api { public const string LabelProviderGetCharacterCustomization = "Glamourer.GetCharacterCustomization"; public const string LabelProviderApplyCharacterCustomization = "Glamourer.ApplyCharacterCustomization"; - + private readonly ClientState clientState; private readonly ObjectTable objectTable; private readonly DalamudPluginInterface pi; internal ICallGateProvider? ProviderGetCharacterCustomization; internal ICallGateProvider? ProviderApplyCharacterCustomization; - public GlamourerIpc(ObjectTable objectTable, DalamudPluginInterface pi) + public GlamourerIpc(ClientState clientState, ObjectTable objectTable, DalamudPluginInterface pi) { + this.clientState = clientState; this.objectTable = objectTable; this.pi = pi; @@ -82,7 +83,7 @@ namespace Glamourer.Api private string GetCharacterCustomization() { CharacterSave save = new CharacterSave(); - save.LoadCharacter((Character)Glamourer.GetPlayer("self")!); + save.LoadCharacter(clientState.LocalPlayer!); return save.ToBase64(); } } diff --git a/Glamourer/Glamourer.cs b/Glamourer/Glamourer.cs index 4ce9552..97dc048 100644 --- a/Glamourer/Glamourer.cs +++ b/Glamourer/Glamourer.cs @@ -43,7 +43,7 @@ namespace Glamourer Designs = new DesignManager(); Penumbra = new PenumbraAttach(Config.AttachToPenumbra); PlayerWatcher = PlayerWatchFactory.Create(Dalamud.Framework, Dalamud.ClientState, Dalamud.Objects); - GlamourerIpc = new(Dalamud.Objects, pluginInterface); + GlamourerIpc = new GlamourerIpc(Dalamud.ClientState, Dalamud.Objects, Dalamud.PluginInterface); if (!Config.ApplyFixedDesigns) PlayerWatcher.Disable(); @@ -64,7 +64,7 @@ namespace Glamourer public void OnGlamourer(string command, string arguments) => _interface.ToggleVisibility(); - public static GameObject? GetPlayer(string name) + private static GameObject? GetPlayer(string name) { var lowerName = name.ToLowerInvariant(); return lowerName switch