Added check if in PVP/Gpose and check if you are targetting your own.

This commit is contained in:
CakeAndBanana
2025-10-01 03:15:11 +02:00
parent e91d163763
commit 49d138049e
2 changed files with 18 additions and 4 deletions

View File

@@ -147,7 +147,9 @@ public sealed class Plugin : IDalamudPlugin
collection.AddSingleton<RedrawManager>();
collection.AddSingleton<BroadcastService>();
collection.AddSingleton(addonLifecycle);
collection.AddSingleton(p => new ContextMenu(contextMenu, pluginInterface, gameData, p.GetRequiredService<ILogger<ContextMenu>>(), p.GetRequiredService<DalamudUtilService>(), p.GetRequiredService<ApiController>(), objectTable, p.GetRequiredService<LightlessConfigService>(), p.GetRequiredService<PairManager>()));
collection.AddSingleton(p => new ContextMenu(contextMenu, pluginInterface, gameData,
p.GetRequiredService<ILogger<ContextMenu>>(), p.GetRequiredService<DalamudUtilService>(), p.GetRequiredService<ApiController>(), objectTable,
p.GetRequiredService<LightlessConfigService>(), p.GetRequiredService<PairManager>(), clientState));
collection.AddSingleton((s) => new IpcCallerPenumbra(s.GetRequiredService<ILogger<IpcCallerPenumbra>>(), pluginInterface,
s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<RedrawManager>()));
collection.AddSingleton((s) => new IpcCallerGlamourer(s.GetRequiredService<ILogger<IpcCallerGlamourer>>(), pluginInterface,

View File

@@ -21,6 +21,7 @@ internal class ContextMenu : IHostedService
private readonly ILogger<ContextMenu> _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;