Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying the administrator's position in ahelp and webhook #30075

Merged
merged 4 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Content.Server/Administration/Managers/AdminManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
22 changes: 18 additions & 4 deletions Content.Server/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,21 @@ 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
{
Expand All @@ -451,6 +458,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))
{
Expand All @@ -463,11 +477,11 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes
// Doing the same thing as above, but with the override name. Theres probably a better way to do this.
if (senderAdmin is not null && 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
{
Expand Down
27 changes: 27 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,15 @@ public static readonly CVarDef<bool>
public static readonly CVarDef<bool> AdminBypassMaxPlayers =
CVarDef.Create("admin.bypass_max_players", true, CVar.SERVERONLY);

/// <summary>
/// Determine if custom rank names are used.
/// If it is false, it'd use the actual rank name regardless of the individual's title.
/// </summary>
/// <seealso cref="AhelpAdminPrefix"/>
/// <seealso cref="AhelpAdminPrefixWebhook"/>
public static readonly CVarDef<bool> AdminUseCustomNamesAdminRank =
CVarDef.Create("admin.use_custom_names_admin_rank", true, CVar.SERVERONLY);

/*
* AHELP
*/
Expand All @@ -921,6 +930,24 @@ public static readonly CVarDef<bool>
public static readonly CVarDef<int> AhelpRateLimitCount =
CVarDef.Create("ahelp.rate_limit_count", 10, CVar.SERVERONLY);

/// <summary>
/// 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.
/// </summary>
/// <seealso cref="AdminUseCustomNamesAdminRank"/>
/// <seealso cref="AhelpAdminPrefixWebhook"/>
public static readonly CVarDef<bool> AhelpAdminPrefix =
CVarDef.Create("ahelp.admin_prefix", true, CVar.SERVERONLY);

/// <summary>
/// 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.
/// </summary>
/// <seealso cref="AdminUseCustomNamesAdminRank"/>
/// <seealso cref="AhelpAdminPrefix"/>
public static readonly CVarDef<bool> AhelpAdminPrefixWebhook =
CVarDef.Create("ahelp.admin_prefix_webhook", true, CVar.SERVERONLY);

/*
* Explosions
*/
Expand Down
4 changes: 4 additions & 0 deletions Resources/ConfigPresets/WizardsDen/wizardsDen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading