From 49d138049e0b6ffcb3a03090d1a9241c68d540a5 Mon Sep 17 00:00:00 2001 From: CakeAndBanana Date: Wed, 1 Oct 2025 03:15:11 +0200 Subject: [PATCH] Added check if in PVP/Gpose and check if you are targetting your own. --- LightlessSync/Plugin.cs | 4 +++- LightlessSync/UI/ContextMenu.cs | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/LightlessSync/Plugin.cs b/LightlessSync/Plugin.cs index 93e666a..7490ebe 100644 --- a/LightlessSync/Plugin.cs +++ b/LightlessSync/Plugin.cs @@ -147,7 +147,9 @@ public sealed class Plugin : IDalamudPlugin collection.AddSingleton(); collection.AddSingleton(); collection.AddSingleton(addonLifecycle); - collection.AddSingleton(p => new ContextMenu(contextMenu, pluginInterface, gameData, p.GetRequiredService>(), p.GetRequiredService(), p.GetRequiredService(), objectTable, p.GetRequiredService(), p.GetRequiredService())); + collection.AddSingleton(p => new ContextMenu(contextMenu, pluginInterface, gameData, + p.GetRequiredService>(), p.GetRequiredService(), p.GetRequiredService(), objectTable, + p.GetRequiredService(), p.GetRequiredService(), clientState)); collection.AddSingleton((s) => new IpcCallerPenumbra(s.GetRequiredService>(), pluginInterface, s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService())); collection.AddSingleton((s) => new IpcCallerGlamourer(s.GetRequiredService>(), pluginInterface, diff --git a/LightlessSync/UI/ContextMenu.cs b/LightlessSync/UI/ContextMenu.cs index e300f16..efa9997 100644 --- a/LightlessSync/UI/ContextMenu.cs +++ b/LightlessSync/UI/ContextMenu.cs @@ -21,6 +21,7 @@ internal class ContextMenu : IHostedService private readonly ILogger _logger; private readonly DalamudUtilService _dalamudUtil; private readonly LightlessConfigService _configService; + private readonly IClientState _clientState; private readonly PairManager _pairManager; private readonly ApiController _apiController; private readonly IObjectTable _objectTable; @@ -42,7 +43,8 @@ internal class ContextMenu : IHostedService ApiController apiController, IObjectTable objectTable, LightlessConfigService configService, - PairManager pairManager) + PairManager pairManager, + IClientState clientState) { _contextMenu = contextMenu; _pluginInterface = pluginInterface; @@ -53,6 +55,7 @@ internal class ContextMenu : IHostedService _objectTable = objectTable; _configService = configService; _pairManager = pairManager; + _clientState = clientState; } public Task StartAsync(CancellationToken cancellationToken) @@ -86,20 +89,29 @@ internal class ContextMenu : IHostedService if (!_validAddons.Contains(args.AddonName, StringComparer.Ordinal)) return; - + + //Check if target is not menutargetdefault. if (args.Target is not MenuTargetDefault target) return; + //Check if name or target id isnt null/zero if (string.IsNullOrEmpty(target.TargetName) || target.TargetObjectId == 0 || target.TargetHomeWorld.RowId == 0) return; + //Check if it is a real target. IPlayerCharacter? targetData = GetPlayerFromObjectTable(target); if (targetData == null || targetData.Address == IntPtr.Zero) return; - if (VisibleUserIds.Any(u => u == target.TargetObjectId)) + //Check if user is paired or is own. + if (VisibleUserIds.Any(u => u == target.TargetObjectId) || _clientState.LocalPlayer.GameObjectId == target.TargetObjectId) return; + //Check if in PVP or GPose + if (_clientState.IsPvPExcludingDen || _clientState.IsGPosing) + return; + + //Check for valid world. var world = GetWorld(target.TargetHomeWorld.RowId); if (!IsWorldValid(world)) return;