Added check if in PVP/Gpose and check if you are targetting your own.
This commit is contained in:
@@ -147,7 +147,9 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
collection.AddSingleton<RedrawManager>();
|
collection.AddSingleton<RedrawManager>();
|
||||||
collection.AddSingleton<BroadcastService>();
|
collection.AddSingleton<BroadcastService>();
|
||||||
collection.AddSingleton(addonLifecycle);
|
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,
|
collection.AddSingleton((s) => new IpcCallerPenumbra(s.GetRequiredService<ILogger<IpcCallerPenumbra>>(), pluginInterface,
|
||||||
s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<RedrawManager>()));
|
s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<LightlessMediator>(), s.GetRequiredService<RedrawManager>()));
|
||||||
collection.AddSingleton((s) => new IpcCallerGlamourer(s.GetRequiredService<ILogger<IpcCallerGlamourer>>(), pluginInterface,
|
collection.AddSingleton((s) => new IpcCallerGlamourer(s.GetRequiredService<ILogger<IpcCallerGlamourer>>(), pluginInterface,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ internal class ContextMenu : IHostedService
|
|||||||
private readonly ILogger<ContextMenu> _logger;
|
private readonly ILogger<ContextMenu> _logger;
|
||||||
private readonly DalamudUtilService _dalamudUtil;
|
private readonly DalamudUtilService _dalamudUtil;
|
||||||
private readonly LightlessConfigService _configService;
|
private readonly LightlessConfigService _configService;
|
||||||
|
private readonly IClientState _clientState;
|
||||||
private readonly PairManager _pairManager;
|
private readonly PairManager _pairManager;
|
||||||
private readonly ApiController _apiController;
|
private readonly ApiController _apiController;
|
||||||
private readonly IObjectTable _objectTable;
|
private readonly IObjectTable _objectTable;
|
||||||
@@ -42,7 +43,8 @@ internal class ContextMenu : IHostedService
|
|||||||
ApiController apiController,
|
ApiController apiController,
|
||||||
IObjectTable objectTable,
|
IObjectTable objectTable,
|
||||||
LightlessConfigService configService,
|
LightlessConfigService configService,
|
||||||
PairManager pairManager)
|
PairManager pairManager,
|
||||||
|
IClientState clientState)
|
||||||
{
|
{
|
||||||
_contextMenu = contextMenu;
|
_contextMenu = contextMenu;
|
||||||
_pluginInterface = pluginInterface;
|
_pluginInterface = pluginInterface;
|
||||||
@@ -53,6 +55,7 @@ internal class ContextMenu : IHostedService
|
|||||||
_objectTable = objectTable;
|
_objectTable = objectTable;
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
_pairManager = pairManager;
|
_pairManager = pairManager;
|
||||||
|
_clientState = clientState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task StartAsync(CancellationToken cancellationToken)
|
public Task StartAsync(CancellationToken cancellationToken)
|
||||||
@@ -86,20 +89,29 @@ internal class ContextMenu : IHostedService
|
|||||||
|
|
||||||
if (!_validAddons.Contains(args.AddonName, StringComparer.Ordinal))
|
if (!_validAddons.Contains(args.AddonName, StringComparer.Ordinal))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//Check if target is not menutargetdefault.
|
||||||
if (args.Target is not MenuTargetDefault target)
|
if (args.Target is not MenuTargetDefault target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//Check if name or target id isnt null/zero
|
||||||
if (string.IsNullOrEmpty(target.TargetName) || target.TargetObjectId == 0 || target.TargetHomeWorld.RowId == 0)
|
if (string.IsNullOrEmpty(target.TargetName) || target.TargetObjectId == 0 || target.TargetHomeWorld.RowId == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//Check if it is a real target.
|
||||||
IPlayerCharacter? targetData = GetPlayerFromObjectTable(target);
|
IPlayerCharacter? targetData = GetPlayerFromObjectTable(target);
|
||||||
if (targetData == null || targetData.Address == IntPtr.Zero)
|
if (targetData == null || targetData.Address == IntPtr.Zero)
|
||||||
return;
|
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;
|
return;
|
||||||
|
|
||||||
|
//Check if in PVP or GPose
|
||||||
|
if (_clientState.IsPvPExcludingDen || _clientState.IsGPosing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Check for valid world.
|
||||||
var world = GetWorld(target.TargetHomeWorld.RowId);
|
var world = GetWorld(target.TargetHomeWorld.RowId);
|
||||||
if (!IsWorldValid(world))
|
if (!IsWorldValid(world))
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user