From e91d163763c9bf44b40192b3091b095bb89e3b65 Mon Sep 17 00:00:00 2001 From: CakeAndBanana Date: Wed, 1 Oct 2025 02:47:11 +0200 Subject: [PATCH] Disabled the pair request on already paired users --- LightlessSync/Plugin.cs | 2 +- LightlessSync/Services/NameplateService.cs | 2 -- LightlessSync/UI/ContextMenu.cs | 22 ++++++++++++++++------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/LightlessSync/Plugin.cs b/LightlessSync/Plugin.cs index 24f1745..93e666a 100644 --- a/LightlessSync/Plugin.cs +++ b/LightlessSync/Plugin.cs @@ -147,7 +147,7 @@ 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())); + collection.AddSingleton(p => new ContextMenu(contextMenu, pluginInterface, gameData, p.GetRequiredService>(), p.GetRequiredService(), p.GetRequiredService(), objectTable, p.GetRequiredService(), p.GetRequiredService())); 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/Services/NameplateService.cs b/LightlessSync/Services/NameplateService.cs index 9de944e..6a94a53 100644 --- a/LightlessSync/Services/NameplateService.cs +++ b/LightlessSync/Services/NameplateService.cs @@ -40,7 +40,6 @@ public class NameplateService : DisposableMediatorSubscriberBase private void OnNamePlateUpdate(INamePlateUpdateContext context, IReadOnlyList handlers) { - if (!_configService.Current.IsNameplateColorsEnabled || (_configService.Current.IsNameplateColorsEnabled && _clientState.IsPvPExcludingDen)) return; @@ -78,7 +77,6 @@ public class NameplateService : DisposableMediatorSubscriberBase public void RequestRedraw() { - _namePlateGui.RequestRedraw(); } diff --git a/LightlessSync/UI/ContextMenu.cs b/LightlessSync/UI/ContextMenu.cs index b828cdd..e300f16 100644 --- a/LightlessSync/UI/ContextMenu.cs +++ b/LightlessSync/UI/ContextMenu.cs @@ -3,13 +3,13 @@ using Dalamud.Game.Gui.ContextMenu; using Dalamud.Plugin; using Dalamud.Plugin.Services; using LightlessSync.LightlessConfiguration; +using LightlessSync.PlayerData.Pairs; using LightlessSync.Services; using LightlessSync.Utils; using LightlessSync.WebAPI; using Lumina.Excel.Sheets; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using System.Linq; namespace LightlessSync.UI; @@ -21,16 +21,17 @@ internal class ContextMenu : IHostedService private readonly ILogger _logger; private readonly DalamudUtilService _dalamudUtil; private readonly LightlessConfigService _configService; + private readonly PairManager _pairManager; private readonly ApiController _apiController; private readonly IObjectTable _objectTable; - private static readonly string[] ValidAddons = new[] - { + private static readonly string[] _validAddons = + [ null, "PartyMemberList", "FriendList", "FreeCompany", "LinkShell", "CrossWorldLinkshell", "_PartyList", "ChatLog", "LookingForGroup", "BlackList", "ContentMemberList", "SocialList", "ContactList", "BeginnerChatList", "MuteList" - }; + ]; public ContextMenu( IContextMenu contextMenu, @@ -40,7 +41,8 @@ internal class ContextMenu : IHostedService DalamudUtilService dalamudUtil, ApiController apiController, IObjectTable objectTable, - LightlessConfigService configService) + LightlessConfigService configService, + PairManager pairManager) { _contextMenu = contextMenu; _pluginInterface = pluginInterface; @@ -50,6 +52,7 @@ internal class ContextMenu : IHostedService _apiController = apiController; _objectTable = objectTable; _configService = configService; + _pairManager = pairManager; } public Task StartAsync(CancellationToken cancellationToken) @@ -81,7 +84,7 @@ internal class ContextMenu : IHostedService if (!_pluginInterface.UiBuilder.ShouldModifyUi) return; - if (!ValidAddons.Contains(args.AddonName, StringComparer.Ordinal)) + if (!_validAddons.Contains(args.AddonName, StringComparer.Ordinal)) return; if (args.Target is not MenuTargetDefault target) @@ -94,6 +97,9 @@ internal class ContextMenu : IHostedService if (targetData == null || targetData.Address == IntPtr.Zero) return; + if (VisibleUserIds.Any(u => u == target.TargetObjectId)) + return; + var world = GetWorld(target.TargetHomeWorld.RowId); if (!IsWorldValid(world)) return; @@ -138,6 +144,10 @@ internal class ContextMenu : IHostedService _logger.LogError(ex, "Error sending pair request."); } } + private HashSet VisibleUserIds => _pairManager.GetOnlineUserPairs() + .Where(u => u.IsVisible && u.PlayerCharacterId != uint.MaxValue) + .Select(u => (ulong)u.PlayerCharacterId) + .ToHashSet(); private IPlayerCharacter? GetPlayerFromObjectTable(MenuTargetDefault target) {