Move Utils.Ban -> TSPlayer.Ban.
Arguably, this is one of the more controversial methods that's being kept. Because it kicks and bans a target player, it's more useful than removing it and requiring people to interface with the TShock Ban Manager directly (not a good move for the future). Whether or not this method sucks is up for debate, but right now I think it's totally fine to keep it around in a different location.
This commit is contained in:
parent
a5a3aae599
commit
152c67f27c
4 changed files with 30 additions and 31 deletions
|
|
@ -1574,6 +1574,32 @@ namespace TShockAPI
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bans and disconnects the player from the server.
|
||||
/// </summary>
|
||||
/// <param name="reason">The reason to be displayed to the server.</param>
|
||||
/// <param name="force">If the ban should bypass immunity to ban checks.</param>
|
||||
/// <param name="adminUserName">The player who initiated the ban.</param>
|
||||
public bool Ban(string reason, bool force = false, string adminUserName = null)
|
||||
{
|
||||
if (!ConnectionAlive)
|
||||
return true;
|
||||
if (force || !HasPermission(Permissions.immunetoban))
|
||||
{
|
||||
string ip = IP;
|
||||
string uuid = UUID;
|
||||
TShock.Bans.AddBan(ip, Name, uuid, "", reason, false, adminUserName);
|
||||
Disconnect(string.Format("Banned: {0}", reason));
|
||||
string verb = force ? "force " : "";
|
||||
if (string.IsNullOrWhiteSpace(adminUserName))
|
||||
TSPlayer.All.SendInfoMessage("{0} was {1}banned for '{2}'.", Name, verb, reason);
|
||||
else
|
||||
TSPlayer.All.SendInfoMessage("{0} {1}banned {2} for '{3}'.", adminUserName, verb, Name, reason);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
private void LogStackFrame()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue