Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
updated for MultiplayerManager changes
  • Loading branch information
jimmble committed Sep 23, 2017
commit 464c6f96ddc26e6e973a56000b9d0aeedb2142d2
14 changes: 10 additions & 4 deletions Essentials/Commands/PlayerModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public void Kick(string playerName)
[Permission(MyPromoteLevel.Moderator)]
public void Ban(string playerName)
{
var multiplayerManager = Context.Torch.CurrentSession?.Managers?.GetManager<IMultiplayerManagerServer>();
if (multiplayerManager == null)
return;
var player = Utilities.GetPlayerByNameOrId(playerName);
var steamUserId = 0ul;
if (player == null)
Expand All @@ -115,27 +118,30 @@ public void Ban(string playerName)
}
else
steamUserId = player.SteamUserId;
if (Context.Torch.Multiplayer.BannedPlayers.Contains(steamUserId))
if (multiplayerManager.BannedPlayers.Contains(steamUserId))
{
Context.Respond("Player is already banned.");
return;
}
Context.Torch.CurrentSession?.Managers?.GetManager<IMultiplayerManagerServer>()?.BanPlayer(steamUserId);
multiplayerManager.BanPlayer(steamUserId);
Context.Respond($"Player '{player?.DisplayName ?? steamUserId.ToString()}' banned.");
}

[Command("unban", "Unban a player from the game.")]
[Permission(MyPromoteLevel.Moderator)]
public void Unban(string steamIdStr)
{
var multiplayerManager = Context.Torch.CurrentSession?.Managers?.GetManager<IMultiplayerManagerServer>();
if (multiplayerManager == null)
return;
if (!ulong.TryParse(steamIdStr, out var steamUserId) || steamIdStr.Length != 17)
{
Context.Respond($"Usage: !unban <steamID>");
return;
}
if (Context.Torch.CurrentSession?.Managers?.GetManager<IMultiplayerManagerServer>()?.BannedPlayers.Contains(steamUserId))
if (multiplayerManager.BannedPlayers.Contains(steamUserId))
{
Context.Torch.CurrentSession?.Managers?.GetManager<IMultiplayerManagerServer>()?.BanPlayer(steamUserId, false);
multiplayerManager.BanPlayer(steamUserId, false);
Context.Respond($"Player '{steamUserId}' unbanned.");
}
else
Expand Down