From 64273cb914047a819cc6be35d03ab8f9e2d89723 Mon Sep 17 00:00:00 2001 From: to4no_fix <156101927+chavonadelal@users.noreply.github.com> Date: Sat, 3 Aug 2024 06:59:20 +0300 Subject: [PATCH] Display the administrator's title in ahelp and ahelp relay (#30075) * Adding the admin prefix to the ahelp * Updating the admin prefix * The second update of the admin prefix * Configuration correction --- .../Administration/Managers/AdminManager.cs | 2 +- .../Administration/Systems/BwoinkSystem.cs | 22 ++++++++++++--- Content.Shared/CCVar/CCVars.cs | 27 +++++++++++++++++++ .../ConfigPresets/WizardsDen/wizardsDen.toml | 4 +++ 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/Content.Server/Administration/Managers/AdminManager.cs b/Content.Server/Administration/Managers/AdminManager.cs index af950e9fc20715..36cea4c156e9a3 100644 --- a/Content.Server/Administration/Managers/AdminManager.cs +++ b/Content.Server/Administration/Managers/AdminManager.cs @@ -458,7 +458,7 @@ private async void LoginAdminMaybe(ICommonSession session) Flags = flags }; - if (dbData.Title != null) + if (dbData.Title != null && _cfg.GetCVar(CCVars.AdminUseCustomNamesAdminRank)) { data.Title = dbData.Title; } diff --git a/Content.Server/Administration/Systems/BwoinkSystem.cs b/Content.Server/Administration/Systems/BwoinkSystem.cs index 670940317799f8..893de4aba5b7c2 100644 --- a/Content.Server/Administration/Systems/BwoinkSystem.cs +++ b/Content.Server/Administration/Systems/BwoinkSystem.cs @@ -565,16 +565,23 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes var escapedText = FormattedMessage.EscapeText(message.Text); string bwoinkText; + string adminPrefix = ""; + + //Getting an administrator position + if (_config.GetCVar(CCVars.AhelpAdminPrefix) && senderAdmin is not null && senderAdmin.Title is not null) + { + adminPrefix = $"[bold]\\[{senderAdmin.Title}\\][/bold] "; + } if (senderAdmin is not null && senderAdmin.Flags == AdminFlags.Adminhelp) // Mentor. Not full admin. That's why it's colored differently. { - bwoinkText = $"[color=purple]{senderSession.Name}[/color]"; + bwoinkText = $"[color=purple]{adminPrefix}{senderSession.Name}[/color]"; } else if (senderAdmin is not null && senderAdmin.HasFlag(AdminFlags.Adminhelp)) { - bwoinkText = $"[color=red]{senderSession.Name}[/color]"; + bwoinkText = $"[color=red]{adminPrefix}{senderSession.Name}[/color]"; } else { @@ -597,6 +604,13 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes RaiseNetworkEvent(msg, channel); } + string adminPrefixWebhook = ""; + + if (_config.GetCVar(CCVars.AhelpAdminPrefixWebhook) && senderAdmin is not null && senderAdmin.Title is not null) + { + adminPrefixWebhook = $"[bold]\\[{senderAdmin.Title}\\][/bold] "; + } + // Notify player if (_playerManager.TryGetSessionById(message.UserId, out var session)) { @@ -611,11 +625,11 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes senderAdmin.Flags == AdminFlags.Adminhelp) // Mentor. Not full admin. That's why it's colored differently. { - overrideMsgText = $"[color=purple]{_overrideClientName}[/color]"; + overrideMsgText = $"[color=purple]{adminPrefixWebhook}{_overrideClientName}[/color]"; } else if (senderAdmin is not null && senderAdmin.HasFlag(AdminFlags.Adminhelp)) { - overrideMsgText = $"[color=red]{_overrideClientName}[/color]"; + overrideMsgText = $"[color=red]{adminPrefixWebhook}{_overrideClientName}[/color]"; } else { diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 082d9c80338beb..9f8a02cbb731f9 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -902,6 +902,15 @@ public static readonly CVarDef public static readonly CVarDef AdminBypassMaxPlayers = CVarDef.Create("admin.bypass_max_players", true, CVar.SERVERONLY); + /// + /// Determine if custom rank names are used. + /// If it is false, it'd use the actual rank name regardless of the individual's title. + /// + /// + /// + public static readonly CVarDef AdminUseCustomNamesAdminRank = + CVarDef.Create("admin.use_custom_names_admin_rank", true, CVar.SERVERONLY); + /* * AHELP */ @@ -921,6 +930,24 @@ public static readonly CVarDef public static readonly CVarDef AhelpRateLimitCount = CVarDef.Create("ahelp.rate_limit_count", 10, CVar.SERVERONLY); + /// + /// Should the administrator's position be displayed in ahelp. + /// If it is is false, only the admin's ckey will be displayed in the ahelp. + /// + /// + /// + public static readonly CVarDef AhelpAdminPrefix = + CVarDef.Create("ahelp.admin_prefix", true, CVar.SERVERONLY); + + /// + /// Should the administrator's position be displayed in the webhook. + /// If it is is false, only the admin's ckey will be displayed in webhook. + /// + /// + /// + public static readonly CVarDef AhelpAdminPrefixWebhook = + CVarDef.Create("ahelp.admin_prefix_webhook", true, CVar.SERVERONLY); + /* * Explosions */ diff --git a/Resources/ConfigPresets/WizardsDen/wizardsDen.toml b/Resources/ConfigPresets/WizardsDen/wizardsDen.toml index 4f1b616fb256a3..96656c911bb27f 100644 --- a/Resources/ConfigPresets/WizardsDen/wizardsDen.toml +++ b/Resources/ConfigPresets/WizardsDen/wizardsDen.toml @@ -39,5 +39,9 @@ deadmin_on_join = true new_player_threshold = 600 alert.min_players_sharing_connection = 2 +[ahelp] +admin_prefix = false +admin_prefix_webhook = false + [worldgen] enabled = true