Skip to content

Commit 618f1e2

Browse files
committed
Ban/unban by steam ID
1 parent aa2d1d2 commit 618f1e2

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎Essentials/Commands/PlayerModule.cs‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,18 @@ public void Kick(string playerName)
102102
[Permission(MyPromoteLevel.Moderator)]
103103
public void Ban(string playerName)
104104
{
105+
var man = Context.Torch.CurrentSession?.Managers?.GetManager<IMultiplayerManagerServer>();
106+
if (ulong.TryParse(playerName, out ulong steamId))
107+
{
108+
man.BanPlayer(steamId);
109+
Context.Respond($"Player '{steamId}' banned.");
110+
return;
111+
}
112+
105113
var player = Utilities.GetPlayerByNameOrId(playerName);
106114
if (player != null)
107115
{
108-
Context.Torch.CurrentSession?.Managers?.GetManager<IMultiplayerManagerServer>()?.BanPlayer(player.SteamUserId);
116+
man.BanPlayer(player.SteamUserId);
109117
Context.Respond($"Player '{player.DisplayName}' banned.");
110118
}
111119
else
@@ -116,18 +124,10 @@ public void Ban(string playerName)
116124

117125
[Command("unban", "Unban a player from the game.")]
118126
[Permission(MyPromoteLevel.Moderator)]
119-
public void Unban(string playerName)
127+
public void Unban(ulong steamId)
120128
{
121-
var player = Utilities.GetPlayerByNameOrId(Context.Args.FirstOrDefault());
122-
if (player != null)
123-
{
124-
Context.Torch.CurrentSession?.Managers?.GetManager<IMultiplayerManagerServer>()?.BanPlayer(player.SteamUserId, false);
125-
Context.Respond($"Player '{player.DisplayName}' unbanned.");
126-
}
127-
else
128-
{
129-
Context.Respond("Player not found.");
130-
}
129+
Context.Torch.CurrentSession?.Managers?.GetManager<IMultiplayerManagerServer>()?.BanPlayer(steamId, false);
130+
Context.Respond($"User {steamId} unbanned.");
131131
}
132132

133133
[Command("motd", "Show the server's Message of the Day.")]

0 commit comments

Comments
 (0)