Added unban & unbanip commands (see #868)
This commit is contained in:
@@ -41,6 +41,16 @@ namespace Barotrauma.Networking
|
||||
|
||||
private List<BannedPlayer> bannedPlayers;
|
||||
|
||||
public IEnumerable<string> BannedNames
|
||||
{
|
||||
get { return bannedPlayers.Select(bp => bp.Name); }
|
||||
}
|
||||
|
||||
public IEnumerable<string> BannedIPs
|
||||
{
|
||||
get { return bannedPlayers.Select(bp => bp.IP); }
|
||||
}
|
||||
|
||||
public BanList()
|
||||
{
|
||||
bannedPlayers = new List<BannedPlayer>();
|
||||
@@ -106,6 +116,36 @@ namespace Barotrauma.Networking
|
||||
Save();
|
||||
}
|
||||
|
||||
public void UnbanPlayer(string name)
|
||||
{
|
||||
var player = bannedPlayers.Find(bp => bp.Name == name);
|
||||
if (player == null)
|
||||
{
|
||||
DebugConsole.Log("Could not unban player \""+name+"\". Matching player not found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.Log("Unbanned \"" + name + ".");
|
||||
bannedPlayers.Remove(player);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public void UnbanIP(string ip)
|
||||
{
|
||||
var player = bannedPlayers.Find(bp => bp.IP == ip);
|
||||
if (player == null)
|
||||
{
|
||||
DebugConsole.Log("Could not unban IP \"" + ip + "\". Matching player not found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.Log("Unbanned \"" + ip + ".");
|
||||
bannedPlayers.Remove(player);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsBanned(string IP)
|
||||
{
|
||||
bannedPlayers.RemoveAll(bp => bp.ExpirationTime.HasValue && DateTime.Now > bp.ExpirationTime.Value);
|
||||
|
||||
Reference in New Issue
Block a user