using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Core.Capabilities; using CounterStrikeSharp.API.Modules.Commands; using CounterStrikeSharp.API.Modules.Commands.Targeting; using CounterStrikeSharp.API.Modules.Entities; namespace CS2_SimpleAdminApi; public interface ICS2_SimpleAdminApi { public static readonly PluginCapability PluginCapability = new("simpleadmin:api"); public event Action? OnSimpleAdminReady; /// /// Gets player information associated with the specified player controller. /// /// The player controller. /// PlayerInfo object representing player data. public PlayerInfo GetPlayerInfo(CCSPlayerController player); /// /// Returns the database connection string used by the plugin. /// public string GetConnectionString(); /// /// Returns the configured server IP address with port. /// public string GetServerAddress(); /// /// Returns the internal server ID assigned in the plugin's database. /// public int? GetServerId(); /// /// Returns mute-related penalties for the specified player. /// /// The player controller. /// A dictionary mapping penalty types to lists of penalties with end date, duration, and pass state. public Dictionary> GetPlayerMuteStatus(CCSPlayerController player); /// /// Event fired when a player receives a penalty. /// public event Action? OnPlayerPenaltied; /// /// Event fired when a penalty is added to a player by SteamID. /// public event Action? OnPlayerPenaltiedAdded; /// /// Event to show admin activity messages. /// public event Action? OnAdminShowActivity; /// /// Event fired when an admin toggles silent mode. /// public event Action? OnAdminToggleSilent; /// /// Issues a penalty to a player controller with specified type, reason, and optional duration. /// public void IssuePenalty(CCSPlayerController player, CCSPlayerController? admin, PenaltyType penaltyType, string reason, int duration = -1); /// /// Issues a penalty to a player identified by SteamID with specified type, reason, and optional duration. /// public void IssuePenalty(SteamID steamid, CCSPlayerController? admin, PenaltyType penaltyType, string reason, int duration = -1); /// /// Logs a command invoked by a caller with the command string. /// public void LogCommand(CCSPlayerController? caller, string command); /// /// Logs a command invoked by a caller with the command info object. /// public void LogCommand(CCSPlayerController? caller, CommandInfo command); /// /// Shows an admin activity message, optionally suppressing broadcasting. /// public void ShowAdminActivity(string messageKey, string? callerName = null, bool dontPublish = false, params object[] messageArgs); /// /// Shows an admin activity message with a custom translated message (for modules with their own localizer). /// /// Already translated message to display to players. /// Name of the admin executing the action (optional). /// If true, won't trigger publish events. public void ShowAdminActivityTranslated(string translatedMessage, string? callerName = null, bool dontPublish = false); /// /// Shows an admin activity message using module's localizer for per-player language support. /// This method sends messages in each player's configured language. /// /// The module's IStringLocalizer instance. /// The translation key from the module's lang files. /// Name of the admin executing the action (optional). /// If true, won't trigger publish events. /// Arguments to format the localized message. public void ShowAdminActivityLocalized(object moduleLocalizer, string messageKey, string? callerName = null, bool dontPublish = false, params object[] messageArgs); /// /// Returns true if the specified admin player is in silent mode (not broadcasting activity). /// public bool IsAdminSilent(CCSPlayerController player); /// /// Returns a set of player slots representing admins currently in silent mode. /// public HashSet ListSilentAdminsSlots(); /// /// Registers a new command with the specified name, description, and callback. /// public void RegisterCommand(string name, string? description, CommandInfo.CommandCallback callback); /// /// Unregisters an existing command by its name. /// public void UnRegisterCommand(string name); /// /// Gets target players from command /// TargetResult? GetTarget(CommandInfo command); /// /// Returns the list of current valid players, available to call from other plugins. /// List GetValidPlayers(); /// /// Registers a menu category. /// void RegisterMenuCategory(string categoryId, string categoryName, string permission = "@css/generic"); /// /// Registers a menu category with per-player localization support for modules. /// 🆕 NEW: Supports per-player localization using module's IStringLocalizer! /// /// The category ID (unique identifier). /// Translation key from module's lang files. /// Required permission to access this category. /// Module's IStringLocalizer for per-player translation. void RegisterMenuCategory(string categoryId, string categoryNameKey, string permission, object moduleLocalizer); /// /// Registers a menu in a category. /// /// The category to add this menu to. /// Unique identifier for the menu. /// Display name of the menu. /// Factory function that creates the menu for a player. /// Required permission to access this menu (optional). /// Command name for permission override checking (optional, e.g., "css_god"). void RegisterMenu(string categoryId, string menuId, string menuName, Func menuFactory, string? permission = null, string? commandName = null); /// /// Registers a menu in a category with automatic context passing. /// RECOMMENDED: Use this overload to eliminate duplication of categoryId and menuName in factory methods. /// /// The category to add this menu to. /// Unique identifier for the menu. /// Display name of the menu. /// Factory function that receives player and menu context. /// Required permission to access this menu (optional). /// Command name for permission override checking (optional, e.g., "css_god"). void RegisterMenu(string categoryId, string menuId, string menuName, Func menuFactory, string? permission = null, string? commandName = null); /// /// Registers a menu with per-player localization support for modules. /// 🆕 NEW: Supports per-player localization using module's IStringLocalizer! /// /// The category to add this menu to. /// Unique identifier for the menu. /// Translation key from module's lang files. /// Factory function that receives player and menu context. /// Required permission to access this menu (optional). /// Command name for permission override checking (optional). /// Module's IStringLocalizer for per-player translation. void RegisterMenu(string categoryId, string menuId, string menuNameKey, Func menuFactory, string? permission, string? commandName, object moduleLocalizer); /// /// Unregisters a menu from a category. /// void UnregisterMenu(string categoryId, string menuId); /// /// Creates a menu with an automatic back button. /// object CreateMenuWithBack(string title, string categoryId, CCSPlayerController player); /// /// Creates a menu with an automatic back button using menu context. /// RECOMMENDED: Use this overload when calling from a context-aware menu factory to avoid title/category duplication. /// /// Menu context containing title and category information. /// The player who will see the menu. object CreateMenuWithBack(MenuContext context, CCSPlayerController player); /// /// Creates a menu with a list of players with filter and action. /// object CreateMenuWithPlayers(string title, string categoryId, CCSPlayerController admin, Func filter, Action onSelect); /// /// Creates a menu with a list of players using menu context. /// RECOMMENDED: Use this overload when calling from a context-aware menu factory to avoid title/category duplication. /// /// Menu context containing title and category information. /// The admin player opening the menu. /// Filter function to determine which players to show. /// Action to execute when a player is selected. object CreateMenuWithPlayers(MenuContext context, CCSPlayerController admin, Func filter, Action onSelect); /// /// Adds an option to the menu (extension method helper). /// void AddMenuOption(object menu, string name, Action action, bool disabled = false, string? permission = null); /// /// Adds a submenu to the menu (extension method helper). /// void AddSubMenu(object menu, string name, Func subMenuFactory, bool disabled = false, string? permission = null); /// /// Opens a menu for a player. /// void OpenMenu(object menu, CCSPlayerController player); }