From 73db581ac31f3edbb9c2e2ce8d4e1e47d2b8ee35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Mon, 2 Oct 2023 22:31:09 +0800 Subject: [PATCH] fix: api 9. --- FakeName/Hooker.cs | 16 +++++++--------- FakeName/Plugin.cs | 3 ++- FakeName/Service.cs | 24 ++++++++++++------------ 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/FakeName/Hooker.cs b/FakeName/Hooker.cs index f5b23f7..dfa9b81 100644 --- a/FakeName/Hooker.cs +++ b/FakeName/Hooker.cs @@ -3,13 +3,11 @@ using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Hooking; -using Dalamud.Logging; using Dalamud.Memory; +using Dalamud.Plugin.Services; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI.Info; -using FFXIVClientStructs.FFXIV.Component.GUI; -using Lumina.Excel.GeneratedSheets; using System; using System.Collections.Generic; using System.Diagnostics; @@ -42,7 +40,7 @@ private delegate void SetNamePlateDelegate(IntPtr addon, bool isPrefixTitle, internal unsafe Hooker() { - SignatureHelper.Initialise(this); + Service.Hook.InitializeFromAttributes(this); AtkTextNodeSetTextHook.Enable(); SetNamePlateHook.Enable(); @@ -59,7 +57,7 @@ public unsafe void Dispose() Service.ClientState.Login -= ClientState_Login; } - private void ClientState_Login(object sender, EventArgs e) + private void ClientState_Login() { var player = Service.ClientState.LocalPlayer; if (player == null) return; @@ -83,7 +81,7 @@ private void ClientState_Login(object sender, EventArgs e) { "XSplit", }; - private unsafe void Framework_Update(Dalamud.Game.Framework framework) + private unsafe void Framework_Update(IFramework framework) { if (IsRunning) return; IsRunning = true; @@ -196,7 +194,7 @@ private unsafe void SetNamePlateDetour(IntPtr namePlateObjectPtr, bool isPrefixT } catch (Exception ex) { - PluginLog.Error(ex, "Failed to change name plate"); + Service.Log.Error(ex, "Failed to change name plate"); } SetNamePlateHook.Original(namePlateObjectPtr, isPrefixTitle, displayTitle, @@ -239,7 +237,7 @@ public static IntPtr ChangeName(IntPtr seStringPtr) } catch (Exception ex) { - PluginLog.Error(ex, "Something wrong with change name!"); + Service.Log.Error(ex, "Something wrong with change name!"); return seStringPtr; } } @@ -275,7 +273,7 @@ public static bool ChangeSeString(SeString seString) } catch (Exception ex) { - PluginLog.Error(ex, "Something wrong with replacement!"); + Service.Log.Error(ex, "Something wrong with replacement!"); return false; } } diff --git a/FakeName/Plugin.cs b/FakeName/Plugin.cs index c398872..8b0caa7 100644 --- a/FakeName/Plugin.cs +++ b/FakeName/Plugin.cs @@ -1,5 +1,6 @@ using Dalamud.Game.Command; using Dalamud.Plugin; +using Dalamud.Plugin.Services; using FakeName.Windows; namespace FakeName; @@ -12,7 +13,7 @@ public class Plugin : IDalamudPlugin internal WindowManager WindowManager { get; } - public Plugin(DalamudPluginInterface pluginInterface, CommandManager commandManager) + public Plugin(DalamudPluginInterface pluginInterface, ICommandManager commandManager) { pluginInterface.Create(); Service.Config = Service.Interface.GetPluginConfig() as Configuration ?? new Configuration(); diff --git a/FakeName/Service.cs b/FakeName/Service.cs index 143d6f7..0c8d337 100644 --- a/FakeName/Service.cs +++ b/FakeName/Service.cs @@ -1,11 +1,6 @@ -using Dalamud.Game; -using Dalamud.Game.ClientState; -using Dalamud.Game.ClientState.Conditions; -using Dalamud.Game.ClientState.Objects; -using Dalamud.Game.Command; -using Dalamud.Game.Gui; using Dalamud.IoC; using Dalamud.Plugin; +using Dalamud.Plugin.Services; namespace FakeName; @@ -17,21 +12,26 @@ internal class Service internal static DalamudPluginInterface Interface { get; private set; } [PluginService] - internal static ClientState ClientState { get; private set; } + internal static IClientState ClientState { get; private set; } [PluginService] - internal static CommandManager CommandManager { get; private set; } + internal static ICommandManager CommandManager { get; private set; } [PluginService] - internal static ObjectTable ObjectTable { get; private set; } + internal static IObjectTable ObjectTable { get; private set; } [PluginService] - public static Framework Framework { get; private set; } + public static IFramework Framework { get; private set; } [PluginService] - public static Condition Condition { get; private set; } + public static ICondition Condition { get; private set; } [PluginService] - public static GameGui GameGui { get; private set; } + public static IGameGui GameGui { get; private set; } + [PluginService] + public static IGameInteropProvider Hook { get; private set; } + + [PluginService] + public static IPluginLog Log { get; private set; } }