avoid static where reasonable

This commit is contained in:
Stanley Dimant 2022-06-14 14:49:58 +02:00
parent 62a58663ff
commit 9ba9e049fb
2 changed files with 6 additions and 5 deletions

View file

@ -16,15 +16,16 @@ namespace Glamourer.Api
{ {
public const string LabelProviderGetCharacterCustomization = "Glamourer.GetCharacterCustomization"; public const string LabelProviderGetCharacterCustomization = "Glamourer.GetCharacterCustomization";
public const string LabelProviderApplyCharacterCustomization = "Glamourer.ApplyCharacterCustomization"; public const string LabelProviderApplyCharacterCustomization = "Glamourer.ApplyCharacterCustomization";
private readonly ClientState clientState;
private readonly ObjectTable objectTable; private readonly ObjectTable objectTable;
private readonly DalamudPluginInterface pi; private readonly DalamudPluginInterface pi;
internal ICallGateProvider<string>? ProviderGetCharacterCustomization; internal ICallGateProvider<string>? ProviderGetCharacterCustomization;
internal ICallGateProvider<string, string, object>? ProviderApplyCharacterCustomization; internal ICallGateProvider<string, string, object>? ProviderApplyCharacterCustomization;
public GlamourerIpc(ObjectTable objectTable, DalamudPluginInterface pi) public GlamourerIpc(ClientState clientState, ObjectTable objectTable, DalamudPluginInterface pi)
{ {
this.clientState = clientState;
this.objectTable = objectTable; this.objectTable = objectTable;
this.pi = pi; this.pi = pi;
@ -82,7 +83,7 @@ namespace Glamourer.Api
private string GetCharacterCustomization() private string GetCharacterCustomization()
{ {
CharacterSave save = new CharacterSave(); CharacterSave save = new CharacterSave();
save.LoadCharacter((Character)Glamourer.GetPlayer("self")!); save.LoadCharacter(clientState.LocalPlayer!);
return save.ToBase64(); return save.ToBase64();
} }
} }

View file

@ -43,7 +43,7 @@ namespace Glamourer
Designs = new DesignManager(); Designs = new DesignManager();
Penumbra = new PenumbraAttach(Config.AttachToPenumbra); Penumbra = new PenumbraAttach(Config.AttachToPenumbra);
PlayerWatcher = PlayerWatchFactory.Create(Dalamud.Framework, Dalamud.ClientState, Dalamud.Objects); 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) if (!Config.ApplyFixedDesigns)
PlayerWatcher.Disable(); PlayerWatcher.Disable();
@ -64,7 +64,7 @@ namespace Glamourer
public void OnGlamourer(string command, string arguments) public void OnGlamourer(string command, string arguments)
=> _interface.ToggleVisibility(); => _interface.ToggleVisibility();
public static GameObject? GetPlayer(string name) private static GameObject? GetPlayer(string name)
{ {
var lowerName = name.ToLowerInvariant(); var lowerName = name.ToLowerInvariant();
return lowerName switch return lowerName switch