Migrate AddBan2 calls to AddBan
No more deprecation warnings on this release #yolo
This commit is contained in:
parent
5362389e71
commit
903bd5bb75
5 changed files with 8 additions and 25 deletions
|
|
@ -1371,7 +1371,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
targetGeneralizedName = target.Name;
|
targetGeneralizedName = target.Name;
|
||||||
success = TShock.Bans.AddBan2(target.IP, target.Name, target.UUID, target.Account.Name, banReason, false, args.Player.Account.Name,
|
success = TShock.Bans.AddBan(target.IP, target.Name, target.UUID, target.Account.Name, banReason, false, args.Player.Account.Name,
|
||||||
banLengthInSeconds == 0 ? "" : DateTime.UtcNow.AddSeconds(banLengthInSeconds).ToString("s"));
|
banLengthInSeconds == 0 ? "" : DateTime.UtcNow.AddSeconds(banLengthInSeconds).ToString("s"));
|
||||||
|
|
||||||
// Since this is an online ban, we need to dc the player and tell them now.
|
// Since this is an online ban, we need to dc the player and tell them now.
|
||||||
|
|
@ -1401,7 +1401,7 @@ namespace TShockAPI
|
||||||
Regex r = new Regex(pattern, RegexOptions.IgnoreCase);
|
Regex r = new Regex(pattern, RegexOptions.IgnoreCase);
|
||||||
if (r.IsMatch(args.Parameters[1])) {
|
if (r.IsMatch(args.Parameters[1])) {
|
||||||
targetGeneralizedName = "IP: " + args.Parameters[1];
|
targetGeneralizedName = "IP: " + args.Parameters[1];
|
||||||
success = TShock.Bans.AddBan2(args.Parameters[1], "", "", "", banReason,
|
success = TShock.Bans.AddBan(args.Parameters[1], "", "", "", banReason,
|
||||||
false, args.Player.Account.Name, banLengthInSeconds == 0 ? "" : DateTime.UtcNow.AddSeconds(banLengthInSeconds).ToString("s"));
|
false, args.Player.Account.Name, banLengthInSeconds == 0 ? "" : DateTime.UtcNow.AddSeconds(banLengthInSeconds).ToString("s"));
|
||||||
if (success && offlineUserAccount != null)
|
if (success && offlineUserAccount != null)
|
||||||
{
|
{
|
||||||
|
|
@ -1449,7 +1449,7 @@ namespace TShockAPI
|
||||||
string lastIP = JsonConvert.DeserializeObject<List<string>>(offlineUserAccount.KnownIps).Last();
|
string lastIP = JsonConvert.DeserializeObject<List<string>>(offlineUserAccount.KnownIps).Last();
|
||||||
|
|
||||||
success =
|
success =
|
||||||
TShock.Bans.AddBan2(lastIP,
|
TShock.Bans.AddBan(lastIP,
|
||||||
"", offlineUserAccount.UUID, offlineUserAccount.Name, banReason, false, args.Player.Account.Name,
|
"", offlineUserAccount.UUID, offlineUserAccount.Name, banReason, false, args.Player.Account.Name,
|
||||||
banLengthInSeconds == 0 ? "" : DateTime.UtcNow.AddSeconds(banLengthInSeconds).ToString("s"));
|
banLengthInSeconds == 0 ? "" : DateTime.UtcNow.AddSeconds(banLengthInSeconds).ToString("s"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -205,24 +205,7 @@ namespace TShockAPI.DB
|
||||||
/// <param name="exceptions">If set to <c>true</c> enable throwing exceptions.</param>
|
/// <param name="exceptions">If set to <c>true</c> enable throwing exceptions.</param>
|
||||||
/// <param name="banner">Banner.</param>
|
/// <param name="banner">Banner.</param>
|
||||||
/// <param name="expiration">Expiration date.</param>
|
/// <param name="expiration">Expiration date.</param>
|
||||||
[Obsolete("Use AddBan2 instead of AddBan.", true)]
|
public bool AddBan(string ip, string name = "", string uuid = "", string accountName = "", string reason = "", bool exceptions = false, string banner = "", string expiration = "")
|
||||||
public bool AddBan(string ip, string name = "", string uuid = "", string reason = "", bool exceptions = false, string banner = "", string expiration = "")
|
|
||||||
{
|
|
||||||
return AddBan2(ip, name, uuid, "", reason, exceptions, banner, expiration);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a ban.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns><c>true</c>, if ban was added, <c>false</c> otherwise.</returns>
|
|
||||||
/// <param name="ip">Ip.</param>
|
|
||||||
/// <param name="name">Name.</param>
|
|
||||||
/// <param name="uuid">UUID.</param>
|
|
||||||
/// <param name="reason">Reason.</param>
|
|
||||||
/// <param name="exceptions">If set to <c>true</c> enable throwing exceptions.</param>
|
|
||||||
/// <param name="banner">Banner.</param>
|
|
||||||
/// <param name="expiration">Expiration date.</param>
|
|
||||||
public bool AddBan2(string ip, string name = "", string uuid = "", string accountName = "", string reason = "", bool exceptions = false, string banner = "", string expiration = "")
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -624,7 +624,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TShock.Bans.AddBan2(ip, name, "", "", args.Parameters["reason"], true, args.TokenData.Username);
|
TShock.Bans.AddBan(ip, name, "", "", args.Parameters["reason"], true, args.TokenData.Username);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -1001,7 +1001,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
TSPlayer player = (TSPlayer)ret;
|
TSPlayer player = (TSPlayer)ret;
|
||||||
var reason = null == args.Parameters["reason"] ? "Banned via web" : args.Parameters["reason"];
|
var reason = null == args.Parameters["reason"] ? "Banned via web" : args.Parameters["reason"];
|
||||||
TShock.Bans.AddBan2(player.IP, player.Name, "", "", reason);
|
TShock.Bans.AddBan(player.IP, player.Name, "", "", reason);
|
||||||
TShock.Utils.ForceKick(player, reason, false, true);
|
TShock.Utils.ForceKick(player, reason, false, true);
|
||||||
return RestResponse("Player " + player.Name + " was banned");
|
return RestResponse("Player " + player.Name + " was banned");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -475,7 +475,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
// A user just signed in successfully despite being banned by account name.
|
// A user just signed in successfully despite being banned by account name.
|
||||||
// We should fix the ban database so that all of their ban info is up to date.
|
// We should fix the ban database so that all of their ban info is up to date.
|
||||||
Bans.AddBan2(args.Player.IP, args.Player.Name, args.Player.UUID, args.Player.Account.Name,
|
Bans.AddBan(args.Player.IP, args.Player.Name, args.Player.UUID, args.Player.Account.Name,
|
||||||
potentialBan.Reason, false, potentialBan.BanningUser, potentialBan.Expiration);
|
potentialBan.Reason, false, potentialBan.BanningUser, potentialBan.Expiration);
|
||||||
|
|
||||||
// And then get rid of them.
|
// And then get rid of them.
|
||||||
|
|
|
||||||
|
|
@ -651,7 +651,7 @@ namespace TShockAPI
|
||||||
string ip = player.IP;
|
string ip = player.IP;
|
||||||
string uuid = player.UUID;
|
string uuid = player.UUID;
|
||||||
string playerName = player.Name;
|
string playerName = player.Name;
|
||||||
TShock.Bans.AddBan2(ip, playerName, uuid, "", reason, false, adminUserName);
|
TShock.Bans.AddBan(ip, playerName, uuid, "", reason, false, adminUserName);
|
||||||
player.Disconnect(string.Format("Banned: {0}", reason));
|
player.Disconnect(string.Format("Banned: {0}", reason));
|
||||||
string verb = force ? "force " : "";
|
string verb = force ? "force " : "";
|
||||||
if (string.IsNullOrWhiteSpace(adminUserName))
|
if (string.IsNullOrWhiteSpace(adminUserName))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue