commit 0371be95804fc50f896f5830d62a9e7b3c1fe52b Author: Liza Carvelli Date: Tue Oct 3 10:19:08 2023 +0200 API 9 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..05dc549 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.idea +*.user diff --git a/RetainerShutUp.sln b/RetainerShutUp.sln new file mode 100644 index 0000000..7516d52 --- /dev/null +++ b/RetainerShutUp.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RetainerShutUp", "RetainerShutUp\RetainerShutUp.csproj", "{40A7D1C5-536E-411E-B24D-3AA490FBDE7E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {40A7D1C5-536E-411E-B24D-3AA490FBDE7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40A7D1C5-536E-411E-B24D-3AA490FBDE7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40A7D1C5-536E-411E-B24D-3AA490FBDE7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40A7D1C5-536E-411E-B24D-3AA490FBDE7E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/RetainerShutUp/.gitignore b/RetainerShutUp/.gitignore new file mode 100644 index 0000000..958518b --- /dev/null +++ b/RetainerShutUp/.gitignore @@ -0,0 +1,3 @@ +/dist +/obj +/bin diff --git a/RetainerShutUp/DalamudPackager.targets b/RetainerShutUp/DalamudPackager.targets new file mode 100644 index 0000000..37c782a --- /dev/null +++ b/RetainerShutUp/DalamudPackager.targets @@ -0,0 +1,20 @@ + + + + + + + + + + diff --git a/RetainerShutUp/Plogon.cs b/RetainerShutUp/Plogon.cs new file mode 100644 index 0000000..1e6e3c4 --- /dev/null +++ b/RetainerShutUp/Plogon.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using Dalamud.Game.ClientState.Conditions; +using Dalamud.Game.Text; +using Dalamud.Game.Text.SeStringHandling; +using Dalamud.Logging; +using Dalamud.Memory; +using Dalamud.Plugin; +using Dalamud.Plugin.Services; +using FFXIVClientStructs.FFXIV.Client.Game; + +namespace RetainerShutUp; + +public class Plogon : IDalamudPlugin +{ + private readonly IChatGui _chatGui; + private readonly IClientState _clientState; + private readonly ICondition _condition; + private readonly IPluginLog _pluginLog; + + private List? _retainerNames = null; + + public Plogon(IChatGui chatGui, IClientState clientState, ICondition condition, IPluginLog pluginLog) + { + _chatGui = chatGui; + _clientState = clientState; + _condition = condition; + _pluginLog = pluginLog; + + _clientState.Logout += LogOut; + _chatGui.CheckMessageHandled += CheckMessageHandled; + } + + private void LogOut() + { + _retainerNames = null; + } + + private void CheckMessageHandled(XivChatType type, uint senderId, ref SeString sender, ref SeString message, + ref bool isHandled) + { + if (isHandled || type != XivChatType.NPCDialogue || senderId != 0 || + !_condition[ConditionFlag.OccupiedSummoningBell]) + return; + + if (_retainerNames == null) + { + try + { + List newNames = new() { "Feo Ul" }; + unsafe + { + RetainerManager* retainerManager = RetainerManager.Instance(); + if (retainerManager == null || retainerManager->Ready != 1) + return; + + foreach (var retainer in retainerManager->RetainersSpan) + { + if (!retainer.Available) + continue; + + newNames.Add(MemoryHelper.ReadSeStringNullTerminated((IntPtr)retainer.Name).ToString()); + } + } + _retainerNames = newNames; + + } + catch (Exception e) + { + _pluginLog.Error(e, "Could not fetch retainers"); + _chatGui.PrintError(e.ToString()); + } + } + + if (_retainerNames != null && _retainerNames.Contains(sender.ToString())) + isHandled = true; + } + + public void Dispose() + { + _chatGui.CheckMessageHandled -= CheckMessageHandled; + _clientState.Logout -= LogOut; + } +} diff --git a/RetainerShutUp/RetainerShutUp.csproj b/RetainerShutUp/RetainerShutUp.csproj new file mode 100644 index 0000000..b5d3c2d --- /dev/null +++ b/RetainerShutUp/RetainerShutUp.csproj @@ -0,0 +1,58 @@ + + + net7.0-windows + 1.0 + 11.0 + enable + true + false + false + dist + true + true + portable + + + + $(appdata)\XIVLauncher\addon\Hooks\dev\ + + + + $(DALAMUD_HOME)/ + + + + + + + + + $(DalamudLibPath)Dalamud.dll + false + + + $(DalamudLibPath)ImGui.NET.dll + false + + + $(DalamudLibPath)Lumina.dll + false + + + $(DalamudLibPath)Lumina.Excel.dll + false + + + $(DalamudLibPath)Newtonsoft.Json.dll + false + + + $(DalamudLibPath)FFXIVClientStructs.dll + false + + + + + + + diff --git a/RetainerShutUp/RetainerShutUp.json b/RetainerShutUp/RetainerShutUp.json new file mode 100644 index 0000000..447205e --- /dev/null +++ b/RetainerShutUp/RetainerShutUp.json @@ -0,0 +1,7 @@ +{ + "Name": "RetainerShutUp", + "Author": "Liza Carvelli", + "Punchline": "", + "Description": "", + "RepoUrl": "https://git.carvel.li/liza/Influx" +} diff --git a/RetainerShutUp/packages.lock.json b/RetainerShutUp/packages.lock.json new file mode 100644 index 0000000..6cf1c73 --- /dev/null +++ b/RetainerShutUp/packages.lock.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "dependencies": { + "net7.0-windows7.0": { + "DalamudPackager": { + "type": "Direct", + "requested": "[2.1.12, )", + "resolved": "2.1.12", + "contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg==" + } + } + } +} \ No newline at end of file