Fixed how ban logic works so it matches the description of the variables EnableBanOnUsernames & EnableIPBans

Now it doesn't prevent bans being created or found but it only actions kicks on join based on the relavent config options.

Changed /unban <player> to only work on names and /unbanip <ip> to only work on ip's to avoid user confusion

Changed error message returned when no bans are found when actioning /unban <player> & /unbanip <ip> to be more appropriate

Fixed formatting of -maxplayers / -players block
This commit is contained in:
stevenh 2012-02-16 10:58:53 +00:00
parent 2c8c5dc7b9
commit 2f3bfca082
2 changed files with 21 additions and 24 deletions

View file

@ -870,25 +870,14 @@ namespace TShockAPI
var ban = TShock.Bans.GetBanByName(plStr);
if (ban != null)
{
if (TShock.Bans.RemoveBan(ban.IP))
args.Player.SendMessage(string.Format("Unbanned {0} ({1})!", ban.Name, ban.IP), Color.Red);
else
args.Player.SendMessage(string.Format("Failed to unban {0} ({1})!", ban.Name, ban.IP), Color.Red);
}
else if (!TShock.Config.EnableBanOnUsernames)
{
ban = TShock.Bans.GetBanByIp(plStr);
if (ban == null)
args.Player.SendMessage(string.Format("Failed to unban {0}, not found.", args.Parameters[0]), Color.Red);
else if (TShock.Bans.RemoveBan(ban.IP))
if (TShock.Bans.RemoveBan(ban.IP, true))
args.Player.SendMessage(string.Format("Unbanned {0} ({1})!", ban.Name, ban.IP), Color.Red);
else
args.Player.SendMessage(string.Format("Failed to unban {0} ({1})!", ban.Name, ban.IP), Color.Red);
}
else
{
args.Player.SendMessage("Invalid player!", Color.Red);
args.Player.SendMessage(string.Format("No bans for player {0} exist", plStr), Color.Red);
}
}
@ -947,8 +936,8 @@ namespace TShockAPI
return;
}
string plStr = args.Parameters[0];
var ban = TShock.Bans.GetBanByIp(plStr);
var ip = args.Parameters[0];
var ban = TShock.Bans.GetBanByIp(ip);
if (ban != null)
{
if (TShock.Bans.RemoveBan(ban.IP))
@ -958,7 +947,7 @@ namespace TShockAPI
}
else
{
args.Player.SendMessage("Invalid player!", Color.Red);
args.Player.SendMessage(string.Format("No bans for ip {0} exist", ip), Color.Red);
}
}

View file

@ -659,10 +659,18 @@ namespace TShockAPI
return;
}
var nameban = Bans.GetBanByName(player.Name);
Ban ban = null;
if (nameban != null && Config.EnableBanOnUsernames)
ban = nameban;
if (Config.EnableBanOnUsernames)
{
var newban = Bans.GetBanByName(player.Name);
if (null != newban)
ban = newban;
}
if (Config.EnableIPBans && null == ban)
{
ban = Bans.GetBanByIp(player.IP);
}
if (ban != null)
{