From d59616527fa7e5125713472dc627947ba6eac2fa Mon Sep 17 00:00:00 2001 From: Taurenkey Date: Fri, 29 Sep 2023 12:05:11 +0100 Subject: [PATCH] API9 Fixes --- XIVSlothCombo/Combos/JobHelpers/AST.cs | 3 +- XIVSlothCombo/Core/IconReplacer.cs | 4 +-- XIVSlothCombo/Core/PluginAddressResolver.cs | 4 +-- XIVSlothCombo/CustomCombo/Functions/Party.cs | 3 +- .../CustomCombo/Functions/PlayerCharacter.cs | 4 +-- XIVSlothCombo/CustomCombo/Functions/Target.cs | 2 +- XIVSlothCombo/Data/ActionWatching.cs | 4 +-- XIVSlothCombo/Data/CustomComboCache.cs | 3 +- XIVSlothCombo/Services/Service.cs | 30 +++++++++++-------- XIVSlothCombo/Window/ConfigWindow.cs | 3 +- XIVSlothCombo/Window/InfoBox.cs | 1 + XIVSlothCombo/Window/Tabs/AboutUs.cs | 9 ++++-- XIVSlothCombo/Window/Tabs/PvEFeatures.cs | 1 + XIVSlothCombo/Window/Tabs/PvPFeatures.cs | 1 + XIVSlothCombo/XIVSlothCombo.cs | 12 ++++---- XIVSlothCombo/XIVSlothCombo.json | 2 +- 16 files changed, 51 insertions(+), 35 deletions(-) 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/Core/IconReplacer.cs b/XIVSlothCombo/Core/IconReplacer.cs index a0e4178e8..e75fc8e51 100644 --- a/XIVSlothCombo/Core/IconReplacer.cs +++ b/XIVSlothCombo/Core/IconReplacer.cs @@ -29,8 +29,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(Service.Address.GetAdjustedActionId, GetIconDetour); + isIconReplaceableHook = Service.GameInteropProvider.HookFromAddress(Service.Address.IsActionIdReplaceable, IsIconReplaceableDetour); getIconHook.Enable(); isIconReplaceableHook.Enable(); diff --git a/XIVSlothCombo/Core/PluginAddressResolver.cs b/XIVSlothCombo/Core/PluginAddressResolver.cs index 812069a2b..8f6a5be26 100644 --- a/XIVSlothCombo/Core/PluginAddressResolver.cs +++ b/XIVSlothCombo/Core/PluginAddressResolver.cs @@ -6,7 +6,7 @@ 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; } @@ -21,7 +21,7 @@ internal class PluginAddressResolver : BaseAddressResolver 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); 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..cb9a7b749 100644 --- a/XIVSlothCombo/Data/ActionWatching.cs +++ b/XIVSlothCombo/Data/ActionWatching.cs @@ -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..71b7c23a0 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 { @@ -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..c9de4099a 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,17 @@ 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!; } } 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/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..114477b7f 100644 --- a/XIVSlothCombo/Window/Tabs/AboutUs.cs +++ b/XIVSlothCombo/Window/Tabs/AboutUs.cs @@ -1,5 +1,6 @@ using Dalamud.Interface; using Dalamud.Interface.Colors; +using Dalamud.Interface.Utility; using Dalamud.Plugin; using Dalamud.Utility; using ECommons.ImGuiMethods; @@ -8,6 +9,8 @@ using System; using System.Collections.Generic; using System.Numerics; +using System.Reflection; +using XIVSlothCombo.Services; namespace XIVSlothCombo.Window.Tabs { @@ -16,9 +19,9 @@ internal class AboutUs : ConfigWindow public static Version version = null!; private static Dictionary Images = new(); - internal static void Draw(IDalamudPlugin P) + internal static void Draw() { - version ??= P.GetType().Assembly.GetName().Version!; + version ??= Assembly.GetExecutingAssembly().GetName().Version!; PvEFeatures.HasToOpenJob = true; @@ -26,7 +29,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..8afcd439f 100644 --- a/XIVSlothCombo/Window/Tabs/PvEFeatures.cs +++ b/XIVSlothCombo/Window/Tabs/PvEFeatures.cs @@ -9,6 +9,7 @@ using XIVSlothCombo.Services; using XIVSlothCombo.Window.Functions; using XIVSlothCombo.Window.MessagesNS; +using Dalamud.Interface.Utility; namespace XIVSlothCombo.Window.Tabs { 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..ab1089b04 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; @@ -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 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",