Rename unique ID -> ticket number

Also get ban conversion to execute cleanly and clean up after itself
This commit is contained in:
Chris 2020-11-29 15:17:49 +10:30
parent 3e6cdb3c71
commit 29170e62a6
4 changed files with 121 additions and 101 deletions

View file

@ -1346,7 +1346,7 @@ namespace TShockAPI
void DisplayBanDetails(Ban ban) void DisplayBanDetails(Ban ban)
{ {
args.Player.SendMessage($"{"Ban Details".Color(Utils.BoldHighlight)} - Unique ID: {ban.UniqueId.Color(Utils.GreenHighlight)}", Color.White); args.Player.SendMessage($"{"Ban Details".Color(Utils.BoldHighlight)} - Ticket Number: {ban.TicketNumber.Color(Utils.GreenHighlight)}", Color.White);
args.Player.SendMessage($"{"Identifier:".Color(Utils.BoldHighlight)} {ban.Identifier}", Color.White); args.Player.SendMessage($"{"Identifier:".Color(Utils.BoldHighlight)} {ban.Identifier}", Color.White);
args.Player.SendMessage($"{"Reason:".Color(Utils.BoldHighlight)} {ban.Reason}", Color.White); args.Player.SendMessage($"{"Reason:".Color(Utils.BoldHighlight)} {ban.Reason}", Color.White);
args.Player.SendMessage($"{"Banned by:".Color(Utils.BoldHighlight)} {ban.BanningUser.Color(Utils.GreenHighlight)} on {ban.BanDateTime.ToString("yyyy/MM/dd").Color(Utils.RedHighlight)} ({ban.GetPrettyTimeSinceBanString().Color(Utils.YellowHighlight)} ago)", Color.White); args.Player.SendMessage($"{"Banned by:".Color(Utils.BoldHighlight)} {ban.BanningUser.Color(Utils.GreenHighlight)} on {ban.BanDateTime.ToString("yyyy/MM/dd").Color(Utils.RedHighlight)} ({ban.GetPrettyTimeSinceBanString().Color(Utils.YellowHighlight)} ago)", Color.White);
@ -1426,7 +1426,7 @@ namespace TShockAPI
banResult = TShock.Bans.InsertBan(target, reason ?? "Banned", args.Player.Account.Name, DateTime.UtcNow, expiration); banResult = TShock.Bans.InsertBan(target, reason ?? "Banned", args.Player.Account.Name, DateTime.UtcNow, expiration);
if (banResult.Ban != null) if (banResult.Ban != null)
{ {
args.Player.SendSuccessMessage($"Ban ID {banResult.Ban.UniqueId} added."); args.Player.SendSuccessMessage($"Ban added. Ticket Number: {banResult.Ban.TicketNumber}.");
DisplayBanDetails(banResult.Ban); DisplayBanDetails(banResult.Ban);
} }
else else
@ -1458,7 +1458,7 @@ namespace TShockAPI
banResult = TShock.Bans.InsertBan(ident, reason, args.Player.Account.Name, DateTime.UtcNow, expiration); banResult = TShock.Bans.InsertBan(ident, reason, args.Player.Account.Name, DateTime.UtcNow, expiration);
if (banResult.Ban != null) if (banResult.Ban != null)
{ {
args.Player.SendSuccessMessage($"Ban ID {banResult.Ban.UniqueId} added for identifier {ident}."); args.Player.SendSuccessMessage($"Ban Ticket Number {banResult.Ban.TicketNumber.Color(Utils.GreenHighlight)} created for identifier {ident}.");
banReason = banResult.Ban.Reason; banReason = banResult.Ban.Reason;
} }
else else
@ -1587,7 +1587,7 @@ namespace TShockAPI
args.Player.SendWarningMessage($"If you are sure you wish to proceed, please execute {"ban-convert-confirm".Color(Utils.WhiteHighlight)} to continue."); args.Player.SendWarningMessage($"If you are sure you wish to proceed, please execute {"ban-convert-confirm".Color(Utils.WhiteHighlight)} to continue.");
args.Player.AddResponse("ban-convert-confirm", (obj) => args.Player.AddResponse("ban-convert-confirm", (obj) =>
{ {
TShock.Bans.ConvertBans(); TShock.Bans.TryConvertBans();
var cmdArgs = (CommandArgs)obj; var cmdArgs = (CommandArgs)obj;
cmdArgs.Player.SendSuccessMessage("Bans have been converted."); cmdArgs.Player.SendSuccessMessage("Bans have been converted.");

View file

@ -34,7 +34,7 @@ namespace TShockAPI.DB
private Dictionary<int, Ban> _bans; private Dictionary<int, Ban> _bans;
/// <summary> /// <summary>
/// Dictionary of Bans, keyed on unique ban ID /// Dictionary of Bans, keyed on ban ticket number
/// </summary> /// </summary>
public Dictionary<int, Ban> Bans public Dictionary<int, Ban> Bans
{ {
@ -42,7 +42,7 @@ namespace TShockAPI.DB
{ {
if (_bans == null) if (_bans == null)
{ {
_bans = RetrieveAllBans().ToDictionary(b => b.UniqueId); _bans = RetrieveAllBans().ToDictionary(b => b.TicketNumber);
} }
return _bans; return _bans;
@ -92,6 +92,8 @@ namespace TShockAPI.DB
throw new Exception("Could not find a database library (probably Sqlite3.dll)"); throw new Exception("Could not find a database library (probably Sqlite3.dll)");
} }
TryConvertBans();
OnBanValidate += BanValidateCheck; OnBanValidate += BanValidateCheck;
OnBanPreAdd += BanAddedCheck; OnBanPreAdd += BanAddedCheck;
} }
@ -99,7 +101,19 @@ namespace TShockAPI.DB
/// <summary> /// <summary>
/// Converts bans from the old ban system to the new. /// Converts bans from the old ban system to the new.
/// </summary> /// </summary>
public void ConvertBans() public void TryConvertBans()
{
int res;
if (database.GetSqlType() == SqlType.Mysql)
{
res = database.QueryScalar<int>("SELECT COUNT(name) FROM information_schema.tables WHERE table_schema = @0 and table_name = 'Bans'", TShock.Config.MySqlDbName);
}
else
{
res = database.QueryScalar<int>("SELECT COUNT(name) FROM sqlite_master WHERE type='table' AND name = 'Bans'");
}
if (res != 0)
{ {
using (var reader = database.QueryReader("SELECT * FROM Bans")) using (var reader = database.QueryReader("SELECT * FROM Bans"))
{ {
@ -139,6 +153,9 @@ namespace TShockAPI.DB
} }
} }
} }
database.Query("DROP TABLE 'Bans'");
}
} }
/// <summary> /// <summary>
@ -222,15 +239,15 @@ namespace TShockAPI.DB
query += "SELECT CAST(last_insert_rowid() as INT);"; query += "SELECT CAST(last_insert_rowid() as INT);";
} }
int uniqueId = database.QueryScalar<int>(query, identifier, reason, banningUser, fromDate.Ticks, toDate.Ticks); int ticketId = database.QueryScalar<int>(query, identifier, reason, banningUser, fromDate.Ticks, toDate.Ticks);
if (uniqueId == 0) if (ticketId == 0)
{ {
return new AddBanResult { Message = "Database insert failed." }; return new AddBanResult { Message = "Database insert failed." };
} }
Ban b = new Ban(uniqueId, identifier, reason, banningUser, fromDate, toDate); Ban b = new Ban(ticketId, identifier, reason, banningUser, fromDate, toDate);
_bans.Add(uniqueId, b); _bans.Add(ticketId, b);
OnBanPostAdd?.Invoke(this, new BanEventArgs { Ban = b }); OnBanPostAdd?.Invoke(this, new BanEventArgs { Ban = b });
@ -240,28 +257,28 @@ namespace TShockAPI.DB
/// <summary> /// <summary>
/// Attempts to remove a ban. Returns true if the ban was removed or expired. False if the ban could not be removed or expired /// Attempts to remove a ban. Returns true if the ban was removed or expired. False if the ban could not be removed or expired
/// </summary> /// </summary>
/// <param name="uniqueId">The unique ID of the ban to change</param> /// <param name="ticketNumber">The ticket number of the ban to change</param>
/// <param name="fullDelete">If true, deletes the ban from the database. If false, marks the expiration time as now, rendering the ban expired. Defaults to false</param> /// <param name="fullDelete">If true, deletes the ban from the database. If false, marks the expiration time as now, rendering the ban expired. Defaults to false</param>
/// <returns></returns> /// <returns></returns>
public bool RemoveBan(int uniqueId, bool fullDelete = false) public bool RemoveBan(int ticketNumber, bool fullDelete = false)
{ {
int rowsModified; int rowsModified;
if (fullDelete) if (fullDelete)
{ {
rowsModified = database.Query("DELETE FROM PlayerBans WHERE TicketNumber=@0", uniqueId); rowsModified = database.Query("DELETE FROM PlayerBans WHERE TicketNumber=@0", ticketNumber);
_bans.Remove(uniqueId); _bans.Remove(ticketNumber);
} }
else else
{ {
rowsModified = database.Query("UPDATE PlayerBans SET Expiration=@0 WHERE TicketNumber=@1", DateTime.UtcNow.Ticks, uniqueId); rowsModified = database.Query("UPDATE PlayerBans SET Expiration=@0 WHERE TicketNumber=@1", DateTime.UtcNow.Ticks, ticketNumber);
_bans[uniqueId].ExpirationDateTime = DateTime.UtcNow; _bans[ticketNumber].ExpirationDateTime = DateTime.UtcNow;
} }
return rowsModified > 0; return rowsModified > 0;
} }
/// <summary> /// <summary>
/// Retrieves a single ban from a unique ban ID /// Retrieves a single ban from a ban's ticket number
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
@ -276,14 +293,14 @@ namespace TShockAPI.DB
{ {
if (reader.Read()) if (reader.Read())
{ {
var uniqueId = reader.Get<int>("TicketNumber"); var ticketNumber = reader.Get<int>("TicketNumber");
var identifier = reader.Get<string>("Identifier"); var identifier = reader.Get<string>("Identifier");
var reason = reader.Get<string>("Reason"); var reason = reader.Get<string>("Reason");
var banningUser = reader.Get<string>("BanningUser"); var banningUser = reader.Get<string>("BanningUser");
var date = reader.Get<long>("Date"); var date = reader.Get<long>("Date");
var expiration = reader.Get<long>("Expiration"); var expiration = reader.Get<long>("Expiration");
return new Ban(uniqueId, identifier, reason, banningUser, date, expiration); return new Ban(ticketNumber, identifier, reason, banningUser, date, expiration);
} }
} }
@ -308,7 +325,7 @@ namespace TShockAPI.DB
{ {
while (reader.Read()) while (reader.Read())
{ {
var uniqueId = reader.Get<int>("TicketNumber"); var ticketNumber = reader.Get<int>("TicketNumber");
var ident = reader.Get<string>("Identifier"); var ident = reader.Get<string>("Identifier");
var id = reader.Get<string>("Identifier"); var id = reader.Get<string>("Identifier");
var reason = reader.Get<string>("Reason"); var reason = reader.Get<string>("Reason");
@ -316,7 +333,7 @@ namespace TShockAPI.DB
var date = reader.Get<long>("Date"); var date = reader.Get<long>("Date");
var expiration = reader.Get<long>("Expiration"); var expiration = reader.Get<long>("Expiration");
yield return new Ban(uniqueId, ident, reason, banningUser, date, expiration); yield return new Ban(ticketNumber, ident, reason, banningUser, date, expiration);
} }
} }
} }
@ -342,14 +359,14 @@ namespace TShockAPI.DB
{ {
while (reader.Read()) while (reader.Read())
{ {
var uniqueId = reader.Get<int>("TicketNumber"); var ticketNumber = reader.Get<int>("TicketNumber");
var identifier = reader.Get<string>("Identifier"); var identifier = reader.Get<string>("Identifier");
var reason = reader.Get<string>("Reason"); var reason = reader.Get<string>("Reason");
var banningUser = reader.Get<string>("BanningUser"); var banningUser = reader.Get<string>("BanningUser");
var date = reader.Get<long>("Date"); var date = reader.Get<long>("Date");
var expiration = reader.Get<long>("Expiration"); var expiration = reader.Get<long>("Expiration");
yield return new Ban(uniqueId, identifier, reason, banningUser, date, expiration); yield return new Ban(ticketNumber, identifier, reason, banningUser, date, expiration);
} }
} }
} }
@ -374,14 +391,14 @@ namespace TShockAPI.DB
{ {
while (reader.Read()) while (reader.Read())
{ {
var uniqueId = reader.Get<int>("TicketNumber"); var ticketNumber = reader.Get<int>("TicketNumber");
var identifier = reader.Get<string>("Identifier"); var identifier = reader.Get<string>("Identifier");
var reason = reader.Get<string>("Reason"); var reason = reader.Get<string>("Reason");
var banningUser = reader.Get<string>("BanningUser"); var banningUser = reader.Get<string>("BanningUser");
var date = reader.Get<long>("Date"); var date = reader.Get<long>("Date");
var expiration = reader.Get<long>("Expiration"); var expiration = reader.Get<long>("Expiration");
var ban = new Ban(uniqueId, identifier, reason, banningUser, date, expiration); var ban = new Ban(ticketNumber, identifier, reason, banningUser, date, expiration);
banlist.Add(ban); banlist.Add(ban);
} }
} }
@ -443,9 +460,9 @@ namespace TShockAPI.DB
/// </summary> /// </summary>
AddedOldestToNewest, AddedOldestToNewest,
/// <summary> /// <summary>
/// Bans will be sorted by their unique ID /// Bans will be sorted by their ticket number
/// </summary> /// </summary>
UniqueId TicketNumber
} }
/// <summary> /// <summary>
@ -600,7 +617,7 @@ namespace TShockAPI.DB
/// <summary> /// <summary>
/// A unique ID assigned to this ban /// A unique ID assigned to this ban
/// </summary> /// </summary>
public int UniqueId { get; set; } public int TicketNumber { get; set; }
/// <summary> /// <summary>
/// An identifiable piece of information to ban /// An identifiable piece of information to ban
@ -658,14 +675,14 @@ namespace TShockAPI.DB
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TShockAPI.DB.Ban"/> class. /// Initializes a new instance of the <see cref="TShockAPI.DB.Ban"/> class.
/// </summary> /// </summary>
/// <param name="uniqueId">Unique ID assigned to the ban</param> /// <param name="ticketNumber">Unique ID assigned to the ban</param>
/// <param name="identifier">Identifier to apply the ban to</param> /// <param name="identifier">Identifier to apply the ban to</param>
/// <param name="reason">Reason for the ban</param> /// <param name="reason">Reason for the ban</param>
/// <param name="banningUser">Account name that executed the ban</param> /// <param name="banningUser">Account name that executed the ban</param>
/// <param name="start">System ticks at which the ban began</param> /// <param name="start">System ticks at which the ban began</param>
/// <param name="end">System ticks at which the ban will end</param> /// <param name="end">System ticks at which the ban will end</param>
public Ban(int uniqueId, string identifier, string reason, string banningUser, long start, long end) public Ban(int ticketNumber, string identifier, string reason, string banningUser, long start, long end)
: this(uniqueId, identifier, reason, banningUser, new DateTime(start), new DateTime(end)) : this(ticketNumber, identifier, reason, banningUser, new DateTime(start), new DateTime(end))
{ {
} }
@ -673,15 +690,15 @@ namespace TShockAPI.DB
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TShockAPI.DB.Ban"/> class. /// Initializes a new instance of the <see cref="TShockAPI.DB.Ban"/> class.
/// </summary> /// </summary>
/// <param name="uniqueId">Unique ID assigned to the ban</param> /// <param name="ticketNumber">Unique ID assigned to the ban</param>
/// <param name="identifier">Identifier to apply the ban to</param> /// <param name="identifier">Identifier to apply the ban to</param>
/// <param name="reason">Reason for the ban</param> /// <param name="reason">Reason for the ban</param>
/// <param name="banningUser">Account name that executed the ban</param> /// <param name="banningUser">Account name that executed the ban</param>
/// <param name="start">DateTime at which the ban will start</param> /// <param name="start">DateTime at which the ban will start</param>
/// <param name="end">DateTime at which the ban will end</param> /// <param name="end">DateTime at which the ban will end</param>
public Ban(int uniqueId, string identifier, string reason, string banningUser, DateTime start, DateTime end) public Ban(int ticketNumber, string identifier, string reason, string banningUser, DateTime start, DateTime end)
{ {
UniqueId = uniqueId; TicketNumber = ticketNumber;
Identifier = identifier; Identifier = identifier;
Reason = reason; Reason = reason;
BanningUser = banningUser; BanningUser = banningUser;

View file

@ -635,28 +635,29 @@ namespace TShockAPI
if (!DateTime.TryParse(args.Parameters["end"], out DateTime endDate)) if (!DateTime.TryParse(args.Parameters["end"], out DateTime endDate))
endDate = DateTime.MaxValue; endDate = DateTime.MaxValue;
if (TShock.Bans.InsertBan(identifier, reason, args.TokenData.Username, startDate, endDate) != null) AddBanResult banResult = TShock.Bans.InsertBan(identifier, reason, args.TokenData.Username, startDate, endDate);
if (banResult.Ban != null)
{ {
TSPlayer player = null; TSPlayer player = null;
if (identifier.StartsWith(Identifiers.IP)) if (identifier.StartsWith(Identifier.IP.Prefix))
{ {
player = TShock.Players.FirstOrDefault(p => p.IP == identifier.Substring(Identifiers.IP.Length)); player = TShock.Players.FirstOrDefault(p => p.IP == identifier.Substring(Identifier.IP.Prefix.Length));
} }
else if (identifier.StartsWith(Identifiers.Name)) else if (identifier.StartsWith(Identifier.Name.Prefix))
{ {
//Character names may not necessarily be unique, so kick all matches //Character names may not necessarily be unique, so kick all matches
foreach (var ply in TShock.Players.Where(p => p.Name == identifier.Substring(Identifiers.Name.Length))) foreach (var ply in TShock.Players.Where(p => p.Name == identifier.Substring(Identifier.Name.Prefix.Length)))
{ {
ply.Kick(reason, true); ply.Kick(reason, true);
} }
} }
else if (identifier.StartsWith(Identifiers.Account)) else if (identifier.StartsWith(Identifier.Account.Prefix))
{ {
player = TShock.Players.FirstOrDefault(p => p.Account?.Name == identifier.Substring(Identifiers.Account.Length)); player = TShock.Players.FirstOrDefault(p => p.Account?.Name == identifier.Substring(Identifier.Account.Prefix.Length));
} }
else if (identifier.StartsWith(Identifiers.UUID)) else if (identifier.StartsWith(Identifier.UUID.Prefix))
{ {
player = TShock.Players.FirstOrDefault(p => p.UUID == identifier.Substring(Identifiers.UUID.Length)); player = TShock.Players.FirstOrDefault(p => p.UUID == identifier.Substring(Identifier.UUID.Prefix.Length));
} }
if (player != null) if (player != null)
@ -664,32 +665,32 @@ namespace TShockAPI
player.Kick(reason, true); player.Kick(reason, true);
} }
return RestResponse("Ban added."); return RestResponse($"Ban added. Ticket number: {banResult.Ban.TicketNumber}");
} }
return RestError("Failed to add ban.", status: "500"); return RestError($"Failed to add ban. {banResult.Message}", status: "500");
} }
[Description("Delete an existing ban entry.")] [Description("Delete an existing ban entry.")]
[Route("/v3/bans/destroy")] [Route("/v3/bans/destroy")]
[Permission(RestPermissions.restmanagebans)] [Permission(RestPermissions.restmanagebans)]
[Noun("uniqueId", true, "The unique ID of the ban to delete.", typeof(String))] [Noun("ticketNumber", true, "The ticket number of the ban to delete.", typeof(String))]
[Noun("fullDelete", false, "Whether or not to completely remove the ban from the system.", typeof(bool))] [Noun("fullDelete", false, "Whether or not to completely remove the ban from the system.", typeof(bool))]
[Token] [Token]
private object BanDestroyV3(RestRequestArgs args) private object BanDestroyV3(RestRequestArgs args)
{ {
string id = args.Parameters["uniqueId"]; string id = args.Parameters["ticketNumber"];
if (string.IsNullOrWhiteSpace(id)) if (string.IsNullOrWhiteSpace(id))
return RestMissingParam("uniqueId"); return RestMissingParam("ticketNumber");
if (!int.TryParse(id, out int uniqueId)) if (!int.TryParse(id, out int ticketNumber))
{ {
return RestInvalidParam("uniqueId"); return RestInvalidParam("ticketNumber");
} }
bool.TryParse(args.Parameters["fullDelete"], out bool fullDelete); bool.TryParse(args.Parameters["fullDelete"], out bool fullDelete);
if (TShock.Bans.RemoveBan(uniqueId, fullDelete)) if (TShock.Bans.RemoveBan(ticketNumber, fullDelete))
{ {
return RestResponse("Ban removed."); return RestResponse("Ban removed.");
} }
@ -700,20 +701,20 @@ namespace TShockAPI
[Description("View the details of a specific ban.")] [Description("View the details of a specific ban.")]
[Route("/v3/bans/read")] [Route("/v3/bans/read")]
[Permission(RestPermissions.restviewbans)] [Permission(RestPermissions.restviewbans)]
[Noun("uniqueId", true, "The unique ID to search for.", typeof(String))] [Noun("ticketNumber", true, "The ticket number to search for.", typeof(String))]
[Token] [Token]
private object BanInfoV3(RestRequestArgs args) private object BanInfoV3(RestRequestArgs args)
{ {
string id = args.Parameters["uniqueId"]; string id = args.Parameters["ticketNumber"];
if (string.IsNullOrWhiteSpace(id)) if (string.IsNullOrWhiteSpace(id))
return RestMissingParam("uniqueId"); return RestMissingParam("ticketNumber");
if (!int.TryParse(id, out int uniqueId)) if (!int.TryParse(id, out int ticketNumber))
{ {
return RestInvalidParam("uniqueId"); return RestInvalidParam("ticketNumber");
} }
Ban ban = TShock.Bans.GetBanById(uniqueId); Ban ban = TShock.Bans.GetBanById(ticketNumber);
if (ban == null) if (ban == null)
{ {
@ -722,11 +723,12 @@ namespace TShockAPI
return new RestObject return new RestObject
{ {
{"identifier", ban.Identifier }, { "ticket_number", ban.TicketNumber },
{"reason", ban.Reason }, { "identifier", ban.Identifier },
{"banning_user", ban.BanningUser }, { "reason", ban.Reason },
{"fromDate", ban.BanDateTime.ToString("s") }, { "banning_user", ban.BanningUser },
{"toDate", ban.ExpirationDateTime.ToString("s") }, { "start_date_ticks", ban.BanDateTime.Ticks },
{ "end_date_ticks", ban.ExpirationDateTime.Ticks },
}; };
} }
@ -742,13 +744,14 @@ namespace TShockAPI
foreach (var ban in bans) foreach (var ban in bans)
{ {
banList.Add( banList.Add(
new Dictionary<string, string> new Dictionary<string, object>
{ {
{"identifier", ban.Identifier }, { "ticket_number", ban.TicketNumber },
{"reason", ban.Reason }, { "identifier", ban.Identifier },
{"banning_user", ban.BanningUser }, { "reason", ban.Reason },
{"fromDate", ban.BanDateTime.ToString("s") }, { "banning_user", ban.BanningUser },
{"toDate", ban.ExpirationDateTime.ToString("s") }, { "start_date_ticks", ban.BanDateTime.Ticks },
{ "end_date_ticks", ban.ExpirationDateTime.Ticks },
} }
); );
} }

View file

@ -479,7 +479,7 @@ namespace TShockAPI
UserAccounts.UpdateLogin(args.Player.Account); UserAccounts.UpdateLogin(args.Player.Account);
//Check if this user has a recorded ban on their account //Check if this user has a recorded ban on their account
var ban = Bans.Bans.FirstOrDefault(b => b.Value.Identifier == $"{Identifiers.Account}{args.Player.Account.Name}" && Bans.IsValidBan(b.Value, args.Player)).Value; var ban = Bans.Bans.FirstOrDefault(b => b.Value.Identifier == $"{Identifier.Account}{args.Player.Account.Name}" && Bans.IsValidBan(b.Value, args.Player)).Value;
//If they do and the ban is still valid, kick them //If they do and the ban is still valid, kick them
if (ban != null && !args.Player.HasPermission(Permissions.immunetoban)) if (ban != null && !args.Player.HasPermission(Permissions.immunetoban))
@ -1206,9 +1206,9 @@ namespace TShockAPI
List<string> identifiers = new List<string> List<string> identifiers = new List<string>
{ {
$"{Identifiers.UUID}{player.UUID}", $"{Identifier.UUID}{player.UUID}",
$"{Identifiers.Name}{player.Name}", $"{Identifier.Name}{player.Name}",
$"{Identifiers.IP}{player.IP}" $"{Identifier.IP}{player.IP}"
}; };
Ban ban = Bans.Bans.FirstOrDefault(b => identifiers.Contains(b.Value.Identifier) && Bans.IsValidBan(b.Value, player)).Value; Ban ban = Bans.Bans.FirstOrDefault(b => identifiers.Contains(b.Value.Identifier) && Bans.IsValidBan(b.Value, player)).Value;