Fix closure issues in menus and update dependencies

Captured player and duration variables in menu callbacks to prevent closure-related bugs. Updated package versions in project files and bumped plugin version to 1.7.8-beta-5. Improved player validation and message localization logic.
This commit is contained in:
Dawid Bepierszcz
2025-11-06 02:24:43 +01:00
parent 038641dbdf
commit 0dded66e5d
10 changed files with 113 additions and 88 deletions

View File

@@ -41,11 +41,12 @@ public static class PlayersMenu
continue;
var enabled = admin.CanTarget(player);
var capturedPlayer = player; // Capture in local variable to avoid closure issues
if (optionName != null)
menu?.AddMenuOption(optionName, (_, _) =>
menu?.AddMenuOption(optionName, (controller, option) =>
{
if (player != null) onSelectAction.Invoke(admin, player);
if (capturedPlayer != null) onSelectAction.Invoke(admin, capturedPlayer);
},
!enabled);
}