Skip to content

Commit 3273658

Browse files
committed
feat: highlight server owner in admin list
Display the configured server owner at the top of the admin list using a dedicated label and gold color.
1 parent e441ce0 commit 3273658

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/Application/Players/Accounts/Roles/AdminListSystem.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
public class AdminListSystem(
44
IDialogService dialogService,
5-
IEntityManager entityManager) : ISystem
5+
IEntityManager entityManager,
6+
ServerOwnerSettings serverOwnerSettings) : ISystem
67
{
78
[PlayerCommand("admins")]
89
public void Show(Player player)
@@ -11,7 +12,8 @@ public void Show(Player player)
1112
.GetComponents<Player>()
1213
.Select(player => player.GetRequiredInfo())
1314
.Where(info => info.RoleId >= RoleId.Moderator)
14-
.OrderByDescending(info => info.RoleId)
15+
.OrderByDescending(IsServerOwner)
16+
.ThenByDescending(info => info.RoleId)
1517
.ToList();
1618

1719
if (admins.Count == 0)
@@ -21,9 +23,16 @@ public void Show(Player player)
2123
}
2224

2325
var content = new StringBuilder();
26+
Color ownerColor = Color.Gold;
2427

2528
foreach (PlayerInfo admin in admins)
2629
{
30+
if (IsServerOwner(admin))
31+
{
32+
content.AppendLine($"{ownerColor}[Server Owner] {Color.White}{admin.Name}");
33+
continue;
34+
}
35+
2736
Color color = admin.RoleId switch
2837
{
2938
>= RoleId.Admin => Color.Red,
@@ -42,4 +51,7 @@ public void Show(Player player)
4251

4352
dialogService.ShowAsync(player, dialog);
4453
}
54+
55+
private bool IsServerOwner(PlayerInfo playerInfo)
56+
=> playerInfo.Name.Equals(serverOwnerSettings.Name, StringComparison.OrdinalIgnoreCase);
4557
}

0 commit comments

Comments
 (0)