diff --git a/TShockAPI/DB/BanManager.cs b/TShockAPI/DB/BanManager.cs
index 4ffa7566..1e09dbfa 100644
--- a/TShockAPI/DB/BanManager.cs
+++ b/TShockAPI/DB/BanManager.cs
@@ -24,34 +24,34 @@ using MySql.Data.MySqlClient;
namespace TShockAPI.DB
{
- ///
- /// Class that manages bans.
- ///
+ ///
+ /// Class that manages bans.
+ ///
public class BanManager
{
private IDbConnection database;
- ///
- /// Initializes a new instance of the class.
- ///
- /// A valid connection to the TShock database
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// A valid connection to the TShock database
public BanManager(IDbConnection db)
{
database = db;
var table = new SqlTable("Bans",
- new SqlColumn("IP", MySqlDbType.String, 16) {Primary = true},
- new SqlColumn("Name", MySqlDbType.Text),
- new SqlColumn("UUID", MySqlDbType.Text),
- new SqlColumn("Reason", MySqlDbType.Text),
- new SqlColumn("BanningUser", MySqlDbType.Text),
- new SqlColumn("Date", MySqlDbType.Text),
- new SqlColumn("Expiration", MySqlDbType.Text)
+ new SqlColumn("IP", MySqlDbType.String, 16) { Primary = true },
+ new SqlColumn("Name", MySqlDbType.Text),
+ new SqlColumn("UUID", MySqlDbType.Text),
+ new SqlColumn("Reason", MySqlDbType.Text),
+ new SqlColumn("BanningUser", MySqlDbType.Text),
+ new SqlColumn("Date", MySqlDbType.Text),
+ new SqlColumn("Expiration", MySqlDbType.Text)
);
var creator = new SqlTableCreator(db,
- db.GetSqlType() == SqlType.Sqlite
- ? (IQueryBuilder) new SqliteQueryCreator()
- : new MysqlQueryCreator());
+ db.GetSqlType() == SqlType.Sqlite
+ ? (IQueryBuilder)new SqliteQueryCreator()
+ : new MysqlQueryCreator());
try
{
creator.EnsureTableStructure(table);
@@ -185,33 +185,33 @@ namespace TShockAPI.DB
return null;
}
- ///
- /// Adds a ban.
- ///
- /// true, if ban was added, false otherwise.
- /// Ip.
- /// Name.
- /// UUID.
- /// Reason.
- /// If set to true enable throwing exceptions.
- /// Banner.
- /// Expiration date.
+ ///
+ /// Adds a ban.
+ ///
+ /// true, if ban was added, false otherwise.
+ /// Ip.
+ /// Name.
+ /// UUID.
+ /// Reason.
+ /// If set to true enable throwing exceptions.
+ /// Banner.
+ /// Expiration date.
public bool AddBan(string ip, string name = "", string uuid = "", string reason = "", bool exceptions = false, string banner = "", string expiration = "")
{
try
{
- /*
- * If the ban already exists, update its entry with the new date
- * and expiration details.
- */
- if (GetBanByIp(ip) != null)
- {
- return database.Query("UPDATE Bans SET Date = @0, Expiration = @1 WHERE IP = @2", DateTime.UtcNow.ToString("s"), expiration, ip) == 1;
- }
- else
- {
- return database.Query("INSERT INTO Bans (IP, Name, UUID, Reason, BanningUser, Date, Expiration) VALUES (@0, @1, @2, @3, @4, @5, @6);", ip, name, uuid, reason, banner, DateTime.UtcNow.ToString("s"), expiration) != 0;
- }
+ /*
+ * If the ban already exists, update its entry with the new date
+ * and expiration details.
+ */
+ if (GetBanByIp(ip) != null)
+ {
+ return database.Query("UPDATE Bans SET Date = @0, Expiration = @1 WHERE IP = @2", DateTime.UtcNow.ToString("s"), expiration, ip) == 1;
+ }
+ else
+ {
+ return database.Query("INSERT INTO Bans (IP, Name, UUID, Reason, BanningUser, Date, Expiration) VALUES (@0, @1, @2, @3, @4, @5, @6);", ip, name, uuid, reason, banner, DateTime.UtcNow.ToString("s"), expiration) != 0;
+ }
}
catch (Exception ex)
{
@@ -222,14 +222,14 @@ namespace TShockAPI.DB
return false;
}
- ///
- /// Removes a ban.
- ///
- /// true, if ban was removed, false otherwise.
- /// Match.
- /// If set to true by name.
- /// If set to true casesensitive.
- /// If set to true exceptions.
+ ///
+ /// Removes a ban.
+ ///
+ /// true, if ban was removed, false otherwise.
+ /// Match.
+ /// If set to true by name.
+ /// If set to true casesensitive.
+ /// If set to true exceptions.
public bool RemoveBan(string match, bool byName = false, bool casesensitive = true, bool exceptions = false)
{
try
@@ -249,10 +249,10 @@ namespace TShockAPI.DB
return false;
}
- ///
- /// Clears bans.
- ///
- /// true, if bans were cleared, false otherwise.
+ ///
+ /// Clears bans.
+ ///
+ /// true, if bans were cleared, false otherwise.
public bool ClearBans()
{
try
@@ -290,96 +290,96 @@ namespace TShockAPI.DB
AddedOldestToNewest
}
- ///
- /// Model class that represents a ban entry in the TShock database.
- ///
+ ///
+ /// Model class that represents a ban entry in the TShock database.
+ ///
public class Ban
{
- ///
- /// Gets or sets the IP address of the ban entry.
- ///
- /// The IP Address
+ ///
+ /// Gets or sets the IP address of the ban entry.
+ ///
+ /// The IP Address
public string IP { get; set; }
- ///
- /// Gets or sets the name.
- ///
- /// The name.
+ ///
+ /// Gets or sets the name.
+ ///
+ /// The name.
public string Name { get; set; }
- ///
- /// Gets or sets the Client UUID of the ban
- ///
- /// The UUID
+ ///
+ /// Gets or sets the Client UUID of the ban
+ ///
+ /// The UUID
public string UUID { get; set; }
- ///
- /// Gets or sets the ban reason.
- ///
- /// The ban reason.
+ ///
+ /// Gets or sets the ban reason.
+ ///
+ /// The ban reason.
public string Reason { get; set; }
- ///
- /// Gets or sets the name of the user who added this ban entry.
- ///
- /// The banning user.
- public string BanningUser { get; set; }
+ ///
+ /// Gets or sets the name of the user who added this ban entry.
+ ///
+ /// The banning user.
+ public string BanningUser { get; set; }
- ///
- /// Gets or sets the UTC date of when the ban is to take effect
- ///
- /// The date, which must be in UTC
- public string Date { get; set; }
+ ///
+ /// Gets or sets the UTC date of when the ban is to take effect
+ ///
+ /// The date, which must be in UTC
+ public string Date { get; set; }
///
/// Gets the object representation of the string.
///
public DateTime DateTime { get; }
- ///
- /// Gets or sets the expiration date, in which the ban shall be lifted
- ///
- /// The expiration.
- public string Expiration { get; set; }
+ ///
+ /// Gets or sets the expiration date, in which the ban shall be lifted
+ ///
+ /// The expiration.
+ public string Expiration { get; set; }
///
/// Gets the object representation of the string.
///
public DateTime ExpirationDateTime { get; }
- ///
- /// Initializes a new instance of the class.
- ///
- /// Ip.
- /// Name.
- /// UUID.
- /// Reason.
- /// Banner.
- /// UTC ban date.
- /// Expiration time
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Ip.
+ /// Name.
+ /// UUID.
+ /// Reason.
+ /// Banner.
+ /// UTC ban date.
+ /// Expiration time
public Ban(string ip, string name, string uuid, string reason, string banner, string date, string exp)
{
IP = ip;
Name = name;
UUID = uuid;
Reason = reason;
- BanningUser = banner;
- Date = date;
- Expiration = exp;
+ BanningUser = banner;
+ Date = date;
+ Expiration = exp;
}
- ///
- /// Initializes a new instance of the class.
- ///
+ ///
+ /// Initializes a new instance of the class.
+ ///
public Ban()
{
IP = string.Empty;
Name = string.Empty;
UUID = string.Empty;
Reason = string.Empty;
- BanningUser = "";
- Date = "";
- Expiration = "";
+ BanningUser = "";
+ Date = "";
+ Expiration = "";
}
}
}