diff --git a/.gitmodules b/.gitmodules index d92146500..208167663 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,6 @@ [submodule "lib/FFXIVClientStructs"] path = lib/FFXIVClientStructs url = https://github.com/aers/FFXIVClientStructs.git +[submodule "ECommons"] + path = ECommons + url = https://github.com/NightmareXIV/ECommons.git diff --git a/ECommons b/ECommons new file mode 160000 index 000000000..1ad0decf6 --- /dev/null +++ b/ECommons @@ -0,0 +1 @@ +Subproject commit 1ad0decf6d6a169dc0d5779b1c40a5ca733a51d0 diff --git a/XIVSlothCombo.sln b/XIVSlothCombo.sln index 0eca0ecc7..99cae0a86 100644 --- a/XIVSlothCombo.sln +++ b/XIVSlothCombo.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.32228.343 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34112.27 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XIVSlothCombo", "XIVSlothCombo\XIVSlothCombo.csproj", "{619DF476-7225-4783-95A5-D29A8816EE66}" EndProject @@ -17,6 +17,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github Actions", "Github Ac .github\workflows\build.yml = .github\workflows\build.yml EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ECommons", "ECommons\ECommons\ECommons.csproj", "{3E8E720E-9990-4202-9035-12F54C78CF47}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -30,6 +32,12 @@ Global {619DF476-7225-4783-95A5-D29A8816EE66}.GitBuild|x64.Build.0 = GitBuild|x64 {619DF476-7225-4783-95A5-D29A8816EE66}.Release|x64.ActiveCfg = Release|x64 {619DF476-7225-4783-95A5-D29A8816EE66}.Release|x64.Build.0 = Release|x64 + {3E8E720E-9990-4202-9035-12F54C78CF47}.Debug|x64.ActiveCfg = Debug|x64 + {3E8E720E-9990-4202-9035-12F54C78CF47}.Debug|x64.Build.0 = Debug|x64 + {3E8E720E-9990-4202-9035-12F54C78CF47}.GitBuild|x64.ActiveCfg = Debug|x64 + {3E8E720E-9990-4202-9035-12F54C78CF47}.GitBuild|x64.Build.0 = Debug|x64 + {3E8E720E-9990-4202-9035-12F54C78CF47}.Release|x64.ActiveCfg = Release|x64 + {3E8E720E-9990-4202-9035-12F54C78CF47}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/XIVSlothCombo/Combos/JobHelpers/AST.cs b/XIVSlothCombo/Combos/JobHelpers/AST.cs index 50c663e36..1e087b87a 100644 --- a/XIVSlothCombo/Combos/JobHelpers/AST.cs +++ b/XIVSlothCombo/Combos/JobHelpers/AST.cs @@ -1,6 +1,7 @@ using Dalamud.Game; using Dalamud.Game.ClientState.JobGauge.Enums; using Dalamud.Game.ClientState.Objects.Types; +using Dalamud.Plugin.Services; using System; using System.Collections.Generic; using System.Linq; @@ -20,7 +21,7 @@ internal static void Init() Service.Framework.Update += CheckCards; } - private static void CheckCards(Framework framework) + private static void CheckCards(IFramework framework) { if (Service.ClientState.LocalPlayer is null || Service.ClientState.LocalPlayer.ClassJob.Id != 33) return; diff --git a/XIVSlothCombo/Combos/PvE/BLU.cs b/XIVSlothCombo/Combos/PvE/BLU.cs index ef161298a..1b50922c7 100644 --- a/XIVSlothCombo/Combos/PvE/BLU.cs +++ b/XIVSlothCombo/Combos/PvE/BLU.cs @@ -401,8 +401,7 @@ protected override uint Invoke(uint actionID, uint lastComboActionID, float comb internal class BLU_NewMoonFluteOpener : CustomCombo { protected internal override CustomComboPreset Preset { get; } = CustomComboPreset.BLU_NewMoonFluteOpener; - private static bool surpanakhaReady = false; - + protected override uint Invoke(uint actionID, uint lastComboActionID, float comboTime, byte level) { if (actionID is MoonFlute) diff --git a/XIVSlothCombo/Core/IconReplacer.cs b/XIVSlothCombo/Core/IconReplacer.cs index a0e4178e8..cee07552a 100644 --- a/XIVSlothCombo/Core/IconReplacer.cs +++ b/XIVSlothCombo/Core/IconReplacer.cs @@ -4,6 +4,7 @@ using System.Reflection; using Dalamud.Hooking; using Dalamud.Logging; +using FFXIVClientStructs.FFXIV.Client.Game; using XIVSlothCombo.CustomComboNS; using XIVSlothCombo.Services; @@ -29,8 +30,8 @@ public IconReplacer() .OrderByDescending(x => x.Preset) .ToList(); - getIconHook = Hook.FromAddress(Service.Address.GetAdjustedActionId, GetIconDetour); - isIconReplaceableHook = Hook.FromAddress(Service.Address.IsActionIdReplaceable, IsIconReplaceableDetour); + getIconHook = Service.GameInteropProvider.HookFromAddress((nint)ActionManager.Addresses.GetAdjustedActionId.Value, GetIconDetour); + isIconReplaceableHook = Service.GameInteropProvider.HookFromAddress(Service.Address.IsActionIdReplaceable, IsIconReplaceableDetour); getIconHook.Enable(); isIconReplaceableHook.Enable(); @@ -80,7 +81,7 @@ private unsafe uint GetIconDetour(IntPtr actionManager, uint actionID) catch (Exception ex) { - PluginLog.Error(ex, "Preset error"); + Service.PluginLog.Error(ex, "Preset error"); return OriginalHook(actionID); } } diff --git a/XIVSlothCombo/Core/PluginAddressResolver.cs b/XIVSlothCombo/Core/PluginAddressResolver.cs index 812069a2b..38e576288 100644 --- a/XIVSlothCombo/Core/PluginAddressResolver.cs +++ b/XIVSlothCombo/Core/PluginAddressResolver.cs @@ -2,11 +2,12 @@ using Dalamud.Game; using Dalamud.Logging; using FFXIVClientStructs.FFXIV.Client.Game; +using XIVSlothCombo.Services; namespace XIVSlothCombo.Core { /// Plugin address resolver. - internal class PluginAddressResolver : BaseAddressResolver + internal class PluginAddressResolver { /// Gets the address of the member ComboTimer. public IntPtr ComboTimer { get; private set; } @@ -14,26 +15,20 @@ internal class PluginAddressResolver : BaseAddressResolver /// Gets the address of the member LastComboMove. public IntPtr LastComboMove => ComboTimer + 0x4; - /// Gets the address of fpGetAdjustedActionId. - public IntPtr GetAdjustedActionId { get; private set; } - /// Gets the address of fpIsIconReplacable. public IntPtr IsActionIdReplaceable { get; private set; } /// - protected unsafe override void Setup64Bit(SigScanner scanner) + public unsafe void Setup(ISigScanner scanner) { ComboTimer = new IntPtr(&ActionManager.Instance()->Combo.Timer); - GetAdjustedActionId = scanner.ScanText("E8 ?? ?? ?? ?? 89 03 8B 03"); // Client::Game::ActionManager.GetAdjustedActionId - IsActionIdReplaceable = scanner.ScanText("E8 ?? ?? ?? ?? 84 C0 74 4C 8B D3"); - PluginLog.Verbose("===== X I V S L O T H C O M B O ====="); - PluginLog.Verbose($"{nameof(GetAdjustedActionId)} 0x{GetAdjustedActionId:X}"); - PluginLog.Verbose($"{nameof(IsActionIdReplaceable)} 0x{IsActionIdReplaceable:X}"); - PluginLog.Verbose($"{nameof(ComboTimer)} 0x{ComboTimer:X}"); - PluginLog.Verbose($"{nameof(LastComboMove)} 0x{LastComboMove:X}"); + Service.PluginLog.Verbose("===== X I V S L O T H C O M B O ====="); + Service.PluginLog.Verbose($"{nameof(IsActionIdReplaceable)} 0x{IsActionIdReplaceable:X}"); + Service.PluginLog.Verbose($"{nameof(ComboTimer)} 0x{ComboTimer:X}"); + Service.PluginLog.Verbose($"{nameof(LastComboMove)} 0x{LastComboMove:X}"); } } } diff --git a/XIVSlothCombo/Core/PluginConfiguration.cs b/XIVSlothCombo/Core/PluginConfiguration.cs index 70307153e..5b906c6e3 100644 --- a/XIVSlothCombo/Core/PluginConfiguration.cs +++ b/XIVSlothCombo/Core/PluginConfiguration.cs @@ -265,7 +265,7 @@ private void SetResetValues(string config, bool value) public void ResetFeatures(string config, int[] values) { - Dalamud.Logging.PluginLog.Debug($"{config} {GetResetValues(config)}"); + Service.PluginLog.Debug($"{config} {GetResetValues(config)}"); if (!GetResetValues(config)) { bool needToResetMessagePrinted = false; @@ -274,7 +274,7 @@ public void ResetFeatures(string config, int[] values) foreach (int value in values) { - Dalamud.Logging.PluginLog.Debug(value.ToString()); + Service.PluginLog.Debug(value.ToString()); if (presets.Contains(value)) { var preset = Enum.GetValues() diff --git a/XIVSlothCombo/CustomCombo/Functions/Cooldown.cs b/XIVSlothCombo/CustomCombo/Functions/Cooldown.cs index 896d5c99e..a87140378 100644 --- a/XIVSlothCombo/CustomCombo/Functions/Cooldown.cs +++ b/XIVSlothCombo/CustomCombo/Functions/Cooldown.cs @@ -59,6 +59,6 @@ internal abstract partial class CustomComboFunctions /// Get if an action is enabled. /// Action ID to check /// If the action is currently enabled. - public unsafe static bool IsEnabled(uint actionID) => ActionManager.Instance()->GetActionStatus(ActionType.Spell, actionID) == 0; + public unsafe static bool IsEnabled(uint actionID) => ActionManager.Instance()->GetActionStatus(ActionType.Action, actionID) == 0; } } diff --git a/XIVSlothCombo/CustomCombo/Functions/Party.cs b/XIVSlothCombo/CustomCombo/Functions/Party.cs index 2eaa7c393..b4c2cd0b3 100644 --- a/XIVSlothCombo/CustomCombo/Functions/Party.cs +++ b/XIVSlothCombo/CustomCombo/Functions/Party.cs @@ -1,6 +1,7 @@ using System.Linq; using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Game.ClientState.Party; +using Dalamud.Plugin.Services; using XIVSlothCombo.Services; namespace XIVSlothCombo.CustomComboNS.Functions @@ -12,7 +13,7 @@ internal abstract partial class CustomComboFunctions /// Gets the party list /// Current party list. - public static PartyList GetPartyMembers() => Service.PartyList; + public static IPartyList GetPartyMembers() => Service.PartyList; public unsafe static GameObject? GetPartySlot(int slot) { diff --git a/XIVSlothCombo/CustomCombo/Functions/PlayerCharacter.cs b/XIVSlothCombo/CustomCombo/Functions/PlayerCharacter.cs index 0b6070eb4..a0e39ae3d 100644 --- a/XIVSlothCombo/CustomCombo/Functions/PlayerCharacter.cs +++ b/XIVSlothCombo/CustomCombo/Functions/PlayerCharacter.cs @@ -21,11 +21,11 @@ internal abstract partial class CustomComboFunctions /// Find if the player has a pet present. /// A value indicating whether the player has a pet (fairy/carbuncle) present. - public static bool HasPetPresent() => Service.BuddyList.PetBuddyPresent; + public static bool HasPetPresent() => Service.BuddyList.PetBuddy != null; /// Find if the player has a companion (chocobo) present. /// A value indicating whether the player has a companion (chocobo). - public static bool HasCompanionPresent() => Service.BuddyList.CompanionBuddyPresent; + public static bool HasCompanionPresent() => Service.BuddyList.CompanionBuddy != null; /// Checks if the player is in a PVP enabled zone. /// A value indicating whether the player is in a PVP enabled zone. diff --git a/XIVSlothCombo/CustomCombo/Functions/Target.cs b/XIVSlothCombo/CustomCombo/Functions/Target.cs index fe5fddc64..341c3014b 100644 --- a/XIVSlothCombo/CustomCombo/Functions/Target.cs +++ b/XIVSlothCombo/CustomCombo/Functions/Target.cs @@ -120,7 +120,7 @@ public static bool HasFriendlyTarget(GameObject? OurTarget = null) public static unsafe GameObject? GetHealTarget(bool checkMOPartyUI = false, bool restrictToMouseover = false) { GameObject? healTarget = null; - TargetManager tm = Service.TargetManager; + ITargetManager tm = Service.TargetManager; if (HasFriendlyTarget(tm.SoftTarget)) healTarget = tm.SoftTarget; if (healTarget is null && HasFriendlyTarget(CurrentTarget) && !restrictToMouseover) healTarget = CurrentTarget; diff --git a/XIVSlothCombo/Data/ActionWatching.cs b/XIVSlothCombo/Data/ActionWatching.cs index 2290174e8..e21e6ee48 100644 --- a/XIVSlothCombo/Data/ActionWatching.cs +++ b/XIVSlothCombo/Data/ActionWatching.cs @@ -94,7 +94,7 @@ private unsafe static void SendActionDetour(long targetObjectId, byte actionType } catch (Exception ex) { - Dalamud.Logging.PluginLog.Error(ex, "SendActionDetour"); + Service.PluginLog.Error(ex, "SendActionDetour"); SendActionHook!.Original(targetObjectId, actionType, actionId, sequence, a5, a6, a7, a8, a9); } } @@ -204,8 +204,8 @@ public static void Dispose() static unsafe ActionWatching() { - ReceiveActionEffectHook ??= Hook.FromAddress(Service.SigScanner.ScanText("E8 ?? ?? ?? ?? 48 8B 8D F0 03 00 00"), ReceiveActionEffectDetour); - SendActionHook ??= Hook.FromAddress(Service.SigScanner.ScanText("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? F3 0F 10 3D ?? ?? ?? ?? 48 8D 4D BF"), SendActionDetour); + ReceiveActionEffectHook ??= Service.GameInteropProvider.HookFromSignature("E8 ?? ?? ?? ?? 48 8B 8D F0 03 00 00", ReceiveActionEffectDetour); + SendActionHook ??= Service.GameInteropProvider.HookFromSignature("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? F3 0F 10 3D ?? ?? ?? ?? 48 8D 4D BF", SendActionDetour); } diff --git a/XIVSlothCombo/Data/CustomComboCache.cs b/XIVSlothCombo/Data/CustomComboCache.cs index 847201b88..204864afd 100644 --- a/XIVSlothCombo/Data/CustomComboCache.cs +++ b/XIVSlothCombo/Data/CustomComboCache.cs @@ -7,6 +7,7 @@ using DalamudStatus = Dalamud.Game.ClientState.Statuses; // conflicts with structs if not defined using FFXIVClientStructs.FFXIV.Client.Game; using XIVSlothCombo.Services; +using Dalamud.Plugin.Services; namespace XIVSlothCombo.Data { @@ -129,7 +130,7 @@ internal static unsafe int GetResourceCost(uint actionID) if (actionManager == null) return 0; - int cost = ActionManager.GetActionCost(ActionType.Spell, actionID, 0, 0, 0, 0); + int cost = ActionManager.GetActionCost(ActionType.Action, actionID, 0, 0, 0, 0); return cost; } @@ -148,7 +149,7 @@ private byte GetCooldownGroup(uint actionID) } /// Triggers when the game framework updates. Clears cooldown and status caches. - private unsafe void Framework_Update(Framework framework) + private unsafe void Framework_Update(IFramework framework) { statusCache.Clear(); cooldownCache.Clear(); diff --git a/XIVSlothCombo/Services/Service.cs b/XIVSlothCombo/Services/Service.cs index 06af1e673..0352300e4 100644 --- a/XIVSlothCombo/Services/Service.cs +++ b/XIVSlothCombo/Services/Service.cs @@ -13,6 +13,7 @@ using Dalamud.Game.Gui; using Dalamud.IoC; using Dalamud.Plugin; +using Dalamud.Plugin.Services; using XIVSlothCombo.Core; using XIVSlothCombo.Data; @@ -26,44 +27,44 @@ internal class Service /// Gets the Dalamud buddy list. [PluginService] - internal static BuddyList BuddyList { get; private set; } = null!; + internal static IBuddyList BuddyList { get; private set; } = null!; /// Gets the Dalamud chat gui. [PluginService] - internal static ChatGui ChatGui { get; private set; } = null!; + internal static IChatGui ChatGui { get; private set; } = null!; /// Facilitates class-based locking. internal static bool ClassLocked { get; set; } = true; /// Gets the Dalamud client state. [PluginService] - internal static ClientState ClientState { get; private set; } = null!; + internal static IClientState ClientState { get; private set; } = null!; /// Gets or sets the plugin caching mechanism. internal static CustomComboCache ComboCache { get; set; } = null!; /// Gets the Dalamud command manager. [PluginService] - internal static CommandManager CommandManager { get; private set; } = null!; + internal static ICommandManager CommandManager { get; private set; } = null!; /// Gets the Dalamud condition. [PluginService] - internal static Condition Condition { get; private set; } = null!; + internal static ICondition Condition { get; private set; } = null!; /// Gets or sets the plugin configuration. internal static PluginConfiguration Configuration { get; set; } = null!; /// Gets the Dalamud data manager. [PluginService] - internal static DataManager DataManager { get; private set; } = null!; + internal static IDataManager DataManager { get; private set; } = null!; /// Gets the Dalamud framework manager. [PluginService] - internal static Framework Framework { get; private set; } = null!; + internal static IFramework Framework { get; private set; } = null!; /// Handles the in-game UI. [PluginService] - internal static GameGui GameGui { get; private set; } = null!; + internal static IGameGui GameGui { get; private set; } = null!; /// Gets or sets the plugin icon replacer. internal static IconReplacer IconReplacer { get; set; } = null!; @@ -74,11 +75,11 @@ internal class Service /// Gets the Dalamud job gauges. [PluginService] - internal static JobGauges JobGauges { get; private set; } = null!; + internal static IJobGauges JobGauges { get; private set; } = null!; /// Gets the Dalamud object table. [PluginService] - internal static ObjectTable ObjectTable { get; private set; } = null!; + internal static IObjectTable ObjectTable { get; private set; } = null!; /// Returns the Plugin Folder location public static string PluginFolder @@ -94,14 +95,20 @@ public static string PluginFolder /// Gets the Dalamud party list. [PluginService] - internal static PartyList PartyList { get; private set; } = null!; + internal static IPartyList PartyList { get; private set; } = null!; /// Facilitates searching for memory signatures. [PluginService] - internal static SigScanner SigScanner { get; private set; } = null!; + internal static ISigScanner SigScanner { get; private set; } = null!; /// Gets the Dalamud target manager. [PluginService] - internal static TargetManager TargetManager { get; private set; } = null!; + internal static ITargetManager TargetManager { get; private set; } = null!; + + [PluginService] + internal static IGameInteropProvider GameInteropProvider { get; private set; } = null!; + + [PluginService] + internal static IPluginLog PluginLog { get; private set; } = null!; } } diff --git a/XIVSlothCombo/Window/ConfigWindow.cs b/XIVSlothCombo/Window/ConfigWindow.cs index 3cc0cb7cb..d29badbf5 100644 --- a/XIVSlothCombo/Window/ConfigWindow.cs +++ b/XIVSlothCombo/Window/ConfigWindow.cs @@ -4,6 +4,7 @@ using System.Numerics; using System.Runtime.InteropServices; using Dalamud.Interface; +using Dalamud.Interface.Utility; using Dalamud.Plugin; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.UI; @@ -124,7 +125,7 @@ public void DrawConfig() if (ImGui.BeginTabItem("About XIVSlothCombo / Report an Issue")) { - AboutUs.Draw(Plugin); + AboutUs.Draw(); ImGui.EndTabItem(); } diff --git a/XIVSlothCombo/Window/IconTextButton.cs b/XIVSlothCombo/Window/IconTextButton.cs index 6b4de2052..b3ddd3aaa 100644 --- a/XIVSlothCombo/Window/IconTextButton.cs +++ b/XIVSlothCombo/Window/IconTextButton.cs @@ -1,4 +1,5 @@ using Dalamud.Interface; +using Dalamud.Interface.Internal; using ECommons.ImGuiMethods; using ImGuiNET; using ImGuiScene; @@ -16,7 +17,7 @@ private static Vector2 GetIconSize(FontAwesomeIcon icon) return iconSize; } - public static bool IconImageButton(TextureWrap texture, string text, Vector2 size = new(), bool imageOnRight = false, float imageScale = 0) + public static bool IconImageButton(IDalamudTextureWrap texture, string text, Vector2 size = new(), bool imageOnRight = false, float imageScale = 0) { var buttonClicked = false; diff --git a/XIVSlothCombo/Window/InfoBox.cs b/XIVSlothCombo/Window/InfoBox.cs index 5958e87ab..1a4c2963b 100644 --- a/XIVSlothCombo/Window/InfoBox.cs +++ b/XIVSlothCombo/Window/InfoBox.cs @@ -1,6 +1,7 @@ using System; using System.Numerics; using Dalamud.Interface; +using Dalamud.Interface.Utility; using ImGuiNET; namespace XIVSlothCombo.Window diff --git a/XIVSlothCombo/Window/Tabs/AboutUs.cs b/XIVSlothCombo/Window/Tabs/AboutUs.cs index 98dff53c6..737c23e32 100644 --- a/XIVSlothCombo/Window/Tabs/AboutUs.cs +++ b/XIVSlothCombo/Window/Tabs/AboutUs.cs @@ -1,5 +1,7 @@ using Dalamud.Interface; using Dalamud.Interface.Colors; +using Dalamud.Interface.Internal; +using Dalamud.Interface.Utility; using Dalamud.Plugin; using Dalamud.Utility; using ECommons.ImGuiMethods; @@ -8,6 +10,8 @@ using System; using System.Collections.Generic; using System.Numerics; +using System.Reflection; +using XIVSlothCombo.Services; namespace XIVSlothCombo.Window.Tabs { @@ -15,10 +19,10 @@ internal class AboutUs : ConfigWindow { public static Version version = null!; - private static Dictionary Images = new(); - internal static void Draw(IDalamudPlugin P) + private static Dictionary Images = new(); + internal static new void Draw() { - version ??= P.GetType().Assembly.GetName().Version!; + version ??= Assembly.GetExecutingAssembly().GetName().Version!; PvEFeatures.HasToOpenJob = true; @@ -26,7 +30,7 @@ internal static void Draw(IDalamudPlugin P) ImGuiEx.ImGuiLineCentered("Header", delegate { - ImGuiEx.TextUnderlined($"{P.Name} - v{version}"); + ImGuiEx.TextUnderlined($"XIVSlothCombo - v{version}"); }); ImGuiEx.ImGuiLineCentered("AboutHeader", delegate diff --git a/XIVSlothCombo/Window/Tabs/PvEFeatures.cs b/XIVSlothCombo/Window/Tabs/PvEFeatures.cs index f8b38d301..af4f5730a 100644 --- a/XIVSlothCombo/Window/Tabs/PvEFeatures.cs +++ b/XIVSlothCombo/Window/Tabs/PvEFeatures.cs @@ -9,6 +9,8 @@ using XIVSlothCombo.Services; using XIVSlothCombo.Window.Functions; using XIVSlothCombo.Window.MessagesNS; +using Dalamud.Interface.Utility; +using System.Reflection.Metadata.Ecma335; namespace XIVSlothCombo.Window.Tabs { @@ -170,6 +172,9 @@ private static void OpenJobAutomatically() if (id is >= 16 and <= 18) id = DOL.JobID; + if (id == DOH.JobID) + return; + if (id is not null) { var currentJob = CustomComboInfoAttribute.JobIDToName((byte)id); diff --git a/XIVSlothCombo/Window/Tabs/PvPFeatures.cs b/XIVSlothCombo/Window/Tabs/PvPFeatures.cs index 8c93e3121..8215d9dee 100644 --- a/XIVSlothCombo/Window/Tabs/PvPFeatures.cs +++ b/XIVSlothCombo/Window/Tabs/PvPFeatures.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Numerics; using Dalamud.Interface; +using Dalamud.Interface.Utility; using ImGuiNET; using XIVSlothCombo.Core; using XIVSlothCombo.Services; diff --git a/XIVSlothCombo/XIVSlothCombo.cs b/XIVSlothCombo/XIVSlothCombo.cs index 43cadea71..75ef99da6 100644 --- a/XIVSlothCombo/XIVSlothCombo.cs +++ b/XIVSlothCombo/XIVSlothCombo.cs @@ -20,6 +20,7 @@ using XIVSlothCombo.Window; using XIVSlothCombo.Window.Tabs; using ECommons; +using Dalamud.Plugin.Services; namespace XIVSlothCombo { @@ -29,6 +30,7 @@ public sealed partial class XIVSlothCombo : IDalamudPlugin private const string Command = "/scombo"; private readonly ConfigWindow configWindow; + private HttpClient httpClient = new(); private readonly TextPayload starterMotd = new("[Sloth Message of the Day] "); private static uint? jobID; @@ -40,7 +42,7 @@ public static uint? JobID { if (jobID != value) { - Dalamud.Logging.PluginLog.Debug($"Switched to job {value}"); + Service.PluginLog.Debug($"Switched to job {value}"); PvEFeatures.HasToOpenJob = true; } jobID = value; @@ -55,7 +57,7 @@ public XIVSlothCombo(DalamudPluginInterface pluginInterface) Service.Configuration = pluginInterface.GetPluginConfig() as PluginConfiguration ?? new PluginConfiguration(); Service.Address = new PluginAddressResolver(); - Service.Address.Setup(); + Service.Address.Setup(Service.SigScanner); if (Service.Configuration.Version == 4) UpgradeConfig4(); @@ -85,7 +87,7 @@ public XIVSlothCombo(DalamudPluginInterface pluginInterface) KillRedundantIDs(); } - private static void CheckCurrentJob(Framework framework) + private static void CheckCurrentJob(IFramework framework) { JobID = Service.ClientState.LocalPlayer?.ClassJob?.Id; } @@ -114,7 +116,7 @@ private static void ResetFeatures() private void DrawUI() => configWindow.Draw(); - private void PrintLoginMessage(object? sender, EventArgs e) + private void PrintLoginMessage() { Task.Delay(TimeSpan.FromSeconds(5)).ContinueWith(task => ResetFeatures()); @@ -126,7 +128,7 @@ private void PrintMotD() { try { - using HttpResponseMessage? motd = Dalamud.Utility.Util.HttpClient.GetAsync("https://raw.githubusercontent.com/Nik-Potokar/XIVSlothCombo/main/res/motd.txt").Result; + using HttpResponseMessage? motd = httpClient.GetAsync("https://raw.githubusercontent.com/Nik-Potokar/XIVSlothCombo/main/res/motd.txt").Result; motd.EnsureSuccessStatusCode(); string? data = motd.Content.ReadAsStringAsync().Result; List? payloads = new() @@ -137,7 +139,7 @@ private void PrintMotD() EmphasisItalicPayload.ItalicsOff }; - Service.ChatGui.PrintChat(new XivChatEntry + Service.ChatGui.Print(new XivChatEntry { Message = new SeString(payloads), Type = XivChatType.Echo @@ -146,7 +148,7 @@ private void PrintMotD() catch (Exception ex) { - Dalamud.Logging.PluginLog.Error(ex, "Unable to retrieve MotD"); + Service.PluginLog.Error(ex, "Unable to retrieve MotD"); } } @@ -505,7 +507,7 @@ private void OnCommand(string command, string arguments) catch (Exception ex) { - Dalamud.Logging.PluginLog.Error(ex, "Debug Log"); + Service.PluginLog.Error(ex, "Debug Log"); Service.ChatGui.Print("Unable to write Debug log."); break; } @@ -517,7 +519,7 @@ private void OnCommand(string command, string arguments) { var jobname = ConfigWindow.groupedPresets.Where(x => x.Value.Any(y => y.Info.JobShorthand.Equals(argumentsParts[0].ToLower(), StringComparison.CurrentCultureIgnoreCase))).FirstOrDefault().Key; var header = $"{jobname} - {argumentsParts[0].ToUpper()}"; - Dalamud.Logging.PluginLog.Debug($"{jobname}"); + Service.PluginLog.Debug($"{jobname}"); PvEFeatures.HeaderToOpen = header; } break; diff --git a/XIVSlothCombo/XIVSlothCombo.csproj b/XIVSlothCombo/XIVSlothCombo.csproj index f2baa61ff..6875ce0e7 100644 --- a/XIVSlothCombo/XIVSlothCombo.csproj +++ b/XIVSlothCombo/XIVSlothCombo.csproj @@ -67,10 +67,13 @@ - + + + + $(DalamudLibPath)Dalamud.dll diff --git a/XIVSlothCombo/XIVSlothCombo.json b/XIVSlothCombo/XIVSlothCombo.json index 4f1d77742..c53f75d42 100644 --- a/XIVSlothCombo/XIVSlothCombo.json +++ b/XIVSlothCombo/XIVSlothCombo.json @@ -2,7 +2,7 @@ "Author": "Team Sloth", "Name": "XIVSlothCombo", "InternalName": "XIVSlothCombo", - "DalamudApiLevel": 8, + "DalamudApiLevel": 9, "Punchline": "Condenses combos and mutually exclusive abilities onto a single button - and then some.", "Description": "Condenses combos and mutually exclusive abilities onto a single button - and then some.", "RepoUrl": "https://github.com/Nik-Potokar/XIVSlothCombo",