Some i18nifiying

This commit is contained in:
Janet Blackquill 2022-10-21 16:12:04 -04:00
parent 39576e3180
commit f63b26ac76
31 changed files with 538 additions and 455 deletions

View file

@ -78,8 +78,8 @@ namespace TShockAPI.DB
}
catch (DllNotFoundException)
{
System.Console.WriteLine("Possible problem with your database - is Sqlite3.dll present?");
throw new Exception("Could not find a database library (probably Sqlite3.dll)");
System.Console.WriteLine(GetString("Possible problem with your database - is Sqlite3.dll present?"));
throw new Exception(GetString("Could not find a database library (probably Sqlite3.dll)"));
}
EnsureBansCollection();
@ -205,12 +205,12 @@ namespace TShockAPI.DB
{
if (ban.ExpirationDateTime == DateTime.MaxValue)
{
player.Disconnect($"#{ban.TicketNumber} - You are banned: {ban.Reason}");
player.Disconnect(GetParticularString("{0} is ban number, {1} is ban reason", $"#{ban.TicketNumber} - You are banned: {ban.Reason}"));
return true;
}
TimeSpan ts = ban.ExpirationDateTime - DateTime.UtcNow;
player.Disconnect($"#{ban.TicketNumber} - You are banned: {ban.Reason} ({ban.GetPrettyExpirationString()} remaining)");
player.Disconnect(GetParticularString("{0} is ban number, {1} is ban reason, {2} is a timestamp", $"#{ban.TicketNumber} - You are banned: {ban.Reason} ({ban.GetPrettyExpirationString()} remaining)"));
return true;
}
@ -255,7 +255,7 @@ namespace TShockAPI.DB
//E.g., if a previous ban has expired, a new ban is valid.
//However, if a previous ban on the provided identifier is still in effect, a new ban is not valid
args.Valid = !Bans.Any(b => b.Value.Identifier == args.Identifier && b.Value.ExpirationDateTime > DateTime.UtcNow);
args.Message = args.Valid ? null : "a current ban for this identifier already exists.";
args.Message = args.Valid ? null : GetString("The ban is invalid because a current ban for this identifier already exists.");
}
}
@ -292,7 +292,7 @@ namespace TShockAPI.DB
if (!args.Valid)
{
string message = $"Ban was not valid: {(args.Message ?? "no further information provided.")}";
string message = args.Message ?? GetString("The ban was not valid for an unknown reason.");
return new AddBanResult { Message = message };
}
@ -311,7 +311,7 @@ namespace TShockAPI.DB
if (ticketId == 0)
{
return new AddBanResult { Message = "Database insert failed." };
return new AddBanResult { Message = GetString("Inserting the ban into the database failed.") };
}
Ban b = new Ban(ticketId, args.Identifier, args.Reason, args.BanningUser, args.BanDateTime, args.ExpirationDateTime);
@ -633,19 +633,19 @@ namespace TShockAPI.DB
/// <summary>
/// IP identifier
/// </summary>
public static Identifier IP = Register("ip:", $"An identifier for an IP Address in octet format. Eg., '{"127.0.0.1".Color(Utils.RedHighlight)}'.");
public static Identifier IP = Register("ip:", GetString($"An identifier for an IP Address in octet format. e.g., '{"127.0.0.1".Color(Utils.RedHighlight)}'."));
/// <summary>
/// UUID identifier
/// </summary>
public static Identifier UUID = Register("uuid:", "An identifier for a UUID.");
public static Identifier UUID = Register("uuid:", GetString("An identifier for a UUID."));
/// <summary>
/// Player name identifier
/// </summary>
public static Identifier Name = Register("name:", "An identifier for a character name.");
public static Identifier Name = Register("name:", GetString("An identifier for a character name."));
/// <summary>
/// User account identifier
/// </summary>
public static Identifier Account = Register("acc:", "An identifier for a TShock User Account name.");
public static Identifier Account = Register("acc:", GetString("An identifier for a TShock User Account name."));
private Identifier(string prefix, string description)
{

View file

@ -171,7 +171,7 @@ namespace TShockAPI.DB
if (player.HasPermission(Permissions.bypassssc) && !fromCommand)
{
TShock.Log.ConsoleInfo("Skipping SSC save (due to tshock.ignore.ssc) for " + player.Account.Name);
TShock.Log.ConsoleInfo(GetParticularString("{0} is a player name", $"Skipping SSC save (due to tshock.ignore.ssc) for {player.Account.Name}"));
return false;
}
@ -241,7 +241,7 @@ namespace TShockAPI.DB
if (player.HasPermission(Permissions.bypassssc))
{
TShock.Log.ConsoleInfo("Skipping SSC save (due to tshock.ignore.ssc) for " + player.Account.Name);
TShock.Log.ConsoleInfo(GetParticularString("{0} is a player name", "Skipping SSC save (due to tshock.ignore.ssc) for {player.Account.Name}"));
return true;
}

View file

@ -208,14 +208,14 @@ namespace TShockAPI.DB
{
if (!GroupExists(TShock.Config.Settings.DefaultGuestGroupName))
{
TShock.Log.ConsoleError("The guest group could not be found. This may indicate a typo in the configuration file, or that the group was renamed or deleted.");
throw new Exception("The guest group could not be found.");
TShock.Log.ConsoleError(GetString("The guest group could not be found. This may indicate a typo in the configuration file, or that the group was renamed or deleted."));
throw new Exception(GetString("The guest group could not be found."));
}
if (!GroupExists(TShock.Config.Settings.DefaultRegistrationGroupName))
{
TShock.Log.ConsoleError("The default usergroup could not be found. This may indicate a typo in the configuration file, or that the group was renamed or deleted.");
throw new Exception("The default usergroup could not be found.");
TShock.Log.ConsoleError(GetString("The default usergroup could not be found. This may indicate a typo in the configuration file, or that the group was renamed or deleted."));
throw new Exception(GetString("The default usergroup could not be found."));
}
}
@ -232,9 +232,9 @@ namespace TShockAPI.DB
if (group == null)
{
if (kick)
player.Disconnect("Your account's group could not be loaded. Please contact server administrators about this.");
player.Disconnect(GetString("Your account's group could not be loaded. Please contact server administrators about this."));
else
player.SendErrorMessage("Your account's group could not be loaded. Please contact server administrators about this.");
player.SendErrorMessage(GetString("Your account's group could not be loaded. Please contact server administrators about this."));
return false;
}
@ -306,7 +306,7 @@ namespace TShockAPI.DB
var parent = groups.FirstOrDefault(gp => gp.Name == parentname);
if (parent == null || name == parentname)
{
var error = "Invalid parent {0} for group {1}".SFormat(parentname, group.Name);
var error = GetString($"Invalid parent group {parentname} for group {group.Name}");
TShock.Log.ConsoleError(error);
throw new GroupManagerException(error);
}
@ -321,7 +321,7 @@ namespace TShockAPI.DB
groups.Add(group);
}
else
throw new GroupManagerException("Failed to add group '" + name + ".'");
throw new GroupManagerException(GetString($"Failed to add group {name}."));
}
/// <summary>
@ -344,7 +344,7 @@ namespace TShockAPI.DB
{
parent = GetGroupByName(parentname);
if (parent == null || parent == group)
throw new GroupManagerException("Invalid parent \"{0}\" for group \"{1}\".".SFormat(parentname, name));
throw new GroupManagerException(GetString($"Invalid parent group {parentname} for group {name}."));
// Check if the new parent would cause loops.
List<Group> groupChain = new List<Group> { group, parent };
@ -353,7 +353,7 @@ namespace TShockAPI.DB
{
if (groupChain.Contains(checkingGroup))
throw new GroupManagerException(
string.Format("Invalid parent \"{0}\" for group \"{1}\" would cause loops in the parent chain.", parentname, name));
GetString($"Parenting group {group} to {parentname} would cause loops in the parent chain."));
groupChain.Add(checkingGroup);
checkingGroup = checkingGroup.Parent;
@ -366,7 +366,7 @@ namespace TShockAPI.DB
newGroup.Suffix = suffix;
string query = "UPDATE GroupList SET Parent=@0, Commands=@1, ChatColor=@2, Suffix=@3, Prefix=@4 WHERE GroupName=@5";
if (database.Query(query, parentname, newGroup.Permissions, newGroup.ChatColor, suffix, prefix, name) != 1)
throw new GroupManagerException(string.Format("Failed to update group \"{0}\".", name));
throw new GroupManagerException(GetString($"Failed to update group \"{name}\"."));
group.ChatColor = chatcolor;
group.Permissions = permissions;
@ -417,7 +417,7 @@ namespace TShockAPI.DB
groups.Remove(oldGroup);
groups.Add(newGroup);
// We need to check if the old group has been referenced as a parent and update those references accordingly
// We need to check if the old group has been referenced as a parent and update those references accordingly
using (var command = db.CreateCommand())
{
command.CommandText = "UPDATE GroupList SET Parent = @0 WHERE Parent = @1";
@ -460,24 +460,24 @@ namespace TShockAPI.DB
}
transaction.Commit();
return $"Group \"{name}\" has been renamed to \"{newName}\".";
return GetString($"Group {name} has been renamed to {newName}.");
}
catch (Exception ex)
{
TShock.Log.Error($"An exception has occurred during database transaction: {ex.Message}");
TShock.Log.Error(GetString($"An exception has occurred during database transaction: {ex.Message}"));
try
{
transaction.Rollback();
}
catch (Exception rollbackEx)
{
TShock.Log.Error($"An exception has occurred during database rollback: {rollbackEx.Message}");
TShock.Log.Error(GetString($"An exception has occurred during database rollback: {rollbackEx.Message}"));
}
}
}
}
throw new GroupManagerException($"Failed to rename group \"{name}\".");
throw new GroupManagerException(GetString($"Failed to rename group {name}."));
}
/// <summary>
@ -492,25 +492,25 @@ namespace TShockAPI.DB
{
if (exceptions)
throw new GroupNotExistException(name);
return "Error: Group doesn't exist.";
return GetString($"Group {name} doesn't exist.");
}
if (name == Group.DefaultGroup.Name)
{
if (exceptions)
throw new GroupManagerException("Unable to remove default guest group.");
return "Error: Unable to remove the default guest group.";
throw new GroupManagerException(GetString("You can't remove the default guest group."));
return GetString("You can't remove the default guest group.");
}
if (database.Query("DELETE FROM GroupList WHERE GroupName=@0", name) == 1)
{
groups.Remove(TShock.Groups.GetGroupByName(name));
return "Group " + name + " has been deleted successfully.";
return GetString($"Group {name} has been deleted successfully.");
}
if (exceptions)
throw new GroupManagerException("Failed to delete group '" + name + ".'");
return "Failed to delete group '" + name + ".'";
throw new GroupManagerException(GetString($"Failed to delete group {name}."));
return GetString($"Failed to delete group {name}.");
}
/// <summary>
@ -522,7 +522,7 @@ namespace TShockAPI.DB
public String AddPermissions(String name, List<String> permissions)
{
if (!GroupExists(name))
return "Error: Group doesn't exist.";
return GetString($"Group {name} doesn't exist.");
var group = TShock.Groups.GetGroupByName(name);
var oldperms = group.Permissions; // Store old permissions in case of error
@ -545,7 +545,7 @@ namespace TShockAPI.DB
public String DeletePermissions(String name, List<String> permissions)
{
if (!GroupExists(name))
return "Error: Group doesn't exist.";
return GetString($"Group {name} doesn't exist.");
var group = TShock.Groups.GetGroupByName(name);
var oldperms = group.Permissions; // Store old permissions in case of error
@ -575,7 +575,7 @@ namespace TShockAPI.DB
string groupName = reader.Get<string>("GroupName");
if (groupName == "superadmin")
{
TShock.Log.ConsoleInfo("WARNING: Group \"superadmin\" is defined in the database even though it's a reserved group name.");
TShock.Log.ConsoleWarn(GetString("Group \"superadmin\" is defined in the database even though it's a reserved group name."));
continue;
}
@ -592,7 +592,7 @@ namespace TShockAPI.DB
catch (ArgumentException)
{
// Just in case somebody messed with the unique primary key.
TShock.Log.ConsoleError("ERROR: Group name \"{0}\" occurs more than once. Keeping current group settings.");
TShock.Log.ConsoleError(GetString($"The group {groupName} appeared more than once. Keeping current group settings."));
return;
}
}
@ -628,14 +628,13 @@ namespace TShockAPI.DB
if (group.Parent == null)
{
TShock.Log.ConsoleError(
"ERROR: Group \"{0}\" is referencing non existent parent group \"{1}\", parent reference was removed.",
group.Name, parentGroupName);
GetString($"Group {group.Name} is referencing a non existent parent group {parentGroupName}, parent reference was removed."));
}
else
{
if (group.Parent == group)
TShock.Log.ConsoleInfo(
"WARNING: Group \"{0}\" is referencing itself as parent group, parent reference was removed.", group.Name);
TShock.Log.ConsoleWarn(
GetString($"Group {group.Name} is referencing itself as parent group; parent reference was removed."));
List<Group> groupChain = new List<Group> { group };
Group checkingGroup = group;
@ -644,8 +643,7 @@ namespace TShockAPI.DB
if (groupChain.Contains(checkingGroup.Parent))
{
TShock.Log.ConsoleError(
"ERROR: Group \"{0}\" is referencing parent group \"{1}\" which is already part of the parent chain. Parent reference removed.",
checkingGroup.Name, checkingGroup.Parent.Name);
GetString($"Group \"{checkingGroup.Name}\" is referencing parent group {checkingGroup.Parent.Name} which is already part of the parent chain. Parent reference removed."));
checkingGroup.Parent = null;
break;
@ -664,7 +662,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
TShock.Log.ConsoleError("Error on reloading groups: " + ex);
TShock.Log.ConsoleError(GetString($"Error on reloading groups: {ex}"));
}
}
}
@ -707,7 +705,7 @@ namespace TShockAPI.DB
/// </summary>
/// <param name="name">The group name.</param>
public GroupExistsException(string name)
: base("Group '" + name + "' already exists")
: base(GetString($"Group {name} already exists"))
{
}
}
@ -724,7 +722,7 @@ namespace TShockAPI.DB
/// </summary>
/// <param name="name">The group name.</param>
public GroupNotExistException(string name)
: base("Group '" + name + "' does not exist")
: base(GetString($"Group {name} does not exist"))
{
}
}

View file

@ -316,8 +316,7 @@ namespace TShockAPI.DB
{
if (x.DefaultCurrentTimestamp && x.Type != MySqlDbType.DateTime)
{
throw new SqlColumnException("Can't set to true SqlColumn.DefaultCurrentTimestamp " +
"when the MySqlDbType is not DateTime");
throw new SqlColumnException(GetString("Can't set to true SqlColumn.DefaultCurrentTimestamp when the MySqlDbType is not DateTime"));
}
});
}
@ -343,7 +342,7 @@ namespace TShockAPI.DB
public string UpdateValue(string table, List<SqlValue> values, List<SqlValue> wheres)
{
if (0 == values.Count)
throw new ArgumentException("No values supplied");
throw new ArgumentException(GetString("No values supplied"));
return "UPDATE {0} SET {1} {2}".SFormat(EscapeTableName(table), string.Join(", ", values.Select(v => v.Name + " = " + v.Value)), BuildWhere(wheres));
}

View file

@ -220,7 +220,7 @@ namespace TShockAPI.DB
}
if (traversed.Contains(cur))
{
throw new InvalidOperationException("Infinite group parenting ({0})".SFormat(cur.Name));
throw new InvalidOperationException(GetString($"Infinite group parenting ({cur.Name})"));
}
traversed.Add(cur);
cur = cur.Parent;
@ -255,4 +255,4 @@ namespace TShockAPI.DB
return ID + (AllowedGroups.Count > 0 ? " (" + String.Join(",", AllowedGroups) + ")" : "");
}
}
}
}

View file

@ -99,13 +99,13 @@ namespace TShockAPI.DB
if (Int32.TryParse(splitids[i], out userid)) // if unparsable, it's not an int, so silently skip
r.AllowedIDs.Add(userid);
else
TShock.Log.Warn("One of your UserIDs is not a usable integer: " + splitids[i]);
TShock.Log.Warn(GetString($"One of your UserIDs is not a usable integer: {splitids[i]}"));
}
}
catch (Exception e)
{
TShock.Log.Error("Your database contains invalid UserIDs (they should be ints).");
TShock.Log.Error("A lot of things will fail because of this. You must manually delete and re-create the allowed field.");
TShock.Log.Error(GetString("Your database contains invalid UserIDs (they should be integers)."));
TShock.Log.Error(GetString("A lot of things will fail because of this. You must manually delete and re-create the allowed field."));
TShock.Log.Error(e.ToString());
TShock.Log.Error(e.StackTrace);
}
@ -283,7 +283,7 @@ namespace TShockAPI.DB
if (region.InArea(x, y))
{
if (top == null || region.Z > top.Z)
top = region;
top = region;
}
}
return top == null || top.HasPermissionToBuildInRegion(ply);
@ -313,7 +313,7 @@ namespace TShockAPI.DB
}
/// <summary>
/// Checks if any regions exist at the given (x, y) coordinate
/// Checks if any regions exist at the given (x, y) coordinate
/// and returns an IEnumerable containing their IDs
/// </summary>
/// <param name="x">X coordinate</param>
@ -390,7 +390,7 @@ namespace TShockAPI.DB
default:
return false;
}
foreach (var region in Regions.Where(r => r.Name == regionName))
region.Area = new Rectangle(X, Y, width, height);
int q = database.Query("UPDATE Regions SET X1 = @0, Y1 = @1, width = @2, height = @3 WHERE RegionName = @4 AND WorldID=@5", X, Y, width,
@ -404,7 +404,7 @@ namespace TShockAPI.DB
}
return false;
}
/// <summary>
/// Renames a region
/// </summary>
@ -438,7 +438,7 @@ namespace TShockAPI.DB
return result;
}
/// <summary>
/// Removes an allowed user from a region
/// </summary>
@ -769,7 +769,7 @@ namespace TShockAPI.DB
*/
return x >= Area.X && x <= Area.X + Area.Width && y >= Area.Y && y <= Area.Y + Area.Height;
}
/// <summary>
/// Checks if a given player has permission to build in the region
/// </summary>
@ -785,7 +785,7 @@ namespace TShockAPI.DB
{
if (!ply.HasBeenNaggedAboutLoggingIn)
{
ply.SendMessage("You must be logged in to take advantage of protected regions.", Color.Red);
ply.SendMessage(GetString("You must be logged in to take advantage of protected regions."), Color.Red);
ply.HasBeenNaggedAboutLoggingIn = true;
}
return false;

View file

@ -50,8 +50,8 @@ namespace TShockAPI.DB
}
catch (DllNotFoundException)
{
Console.WriteLine("Possible problem with your database - is Sqlite3.dll present?");
throw new Exception("Could not find a database library (probably Sqlite3.dll)");
TShock.Log.ConsoleWarn(GetString("Possible problem with your database - is Sqlite3.dll present?"));
throw new Exception(GetString("Could not find a database library (probably Sqlite3.dll)"));
}
}
@ -84,7 +84,7 @@ namespace TShockAPI.DB
where WorldId = @0
group by itemId";
try {
try {
using (var reader = database.QueryReader(sql, Main.worldID))
{
while (reader.Read())

View file

@ -220,7 +220,7 @@ namespace TShockAPI.DB
}
if (traversed.Contains(cur))
{
throw new InvalidOperationException("Infinite group parenting ({0})".SFormat(cur.Name));
throw new InvalidOperationException(GetString($"Infinite group parenting ({cur.Name})"));
}
traversed.Add(cur);
cur = cur.Parent;
@ -255,4 +255,4 @@ namespace TShockAPI.DB
return ID + (AllowedGroups.Count > 0 ? " (" + String.Join(",", AllowedGroups) + ")" : "");
}
}
}
}

View file

@ -78,7 +78,7 @@ namespace TShockAPI.DB
// Detect duplicate user using a regexp as Sqlite doesn't have well structured exceptions
if (Regex.IsMatch(ex.Message, "Username.*not unique|UNIQUE constraint failed: Users\\.Username"))
throw new UserAccountExistsException(account.Name);
throw new UserAccountManagerException("AddUser SQL returned an error (" + ex.Message + ")", ex);
throw new UserAccountManagerException(GetString($"AddUser SQL returned an error ({ex.Message})"), ex);
}
if (1 > ret)
@ -109,7 +109,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
throw new UserAccountManagerException("RemoveUser SQL returned an error", ex);
throw new UserAccountManagerException(GetString("RemoveUser SQL returned an error"), ex);
}
}
@ -131,7 +131,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
throw new UserAccountManagerException("SetUserPassword SQL returned an error", ex);
throw new UserAccountManagerException(GetString("SetUserPassword SQL returned an error"), ex);
}
}
@ -151,7 +151,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
throw new UserAccountManagerException("SetUserUUID SQL returned an error", ex);
throw new UserAccountManagerException(GetString("SetUserUUID SQL returned an error"), ex);
}
}
@ -168,7 +168,7 @@ namespace TShockAPI.DB
if (_database.Query("UPDATE Users SET UserGroup = @0 WHERE Username = @1;", group, account.Name) == 0)
throw new UserAccountNotExistException(account.Name);
try
{
// Update player group reference for any logged in player
@ -179,7 +179,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
throw new UserAccountManagerException("SetUserGroup SQL returned an error", ex);
throw new UserAccountManagerException(GetString("SetUserGroup SQL returned an error"), ex);
}
}
@ -194,7 +194,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
throw new UserAccountManagerException("UpdateLogin SQL returned an error", ex);
throw new UserAccountManagerException(GetString("UpdateLogin SQL returned an error"), ex);
}
}
@ -215,7 +215,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
TShock.Log.ConsoleError("FetchHashedPasswordAndGroup SQL returned an error: " + ex);
TShock.Log.ConsoleError(GetString($"FetchHashedPasswordAndGroup SQL returned an error: {ex}"));
}
return -1;
}
@ -288,10 +288,10 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
throw new UserAccountManagerException("GetUser SQL returned an error (" + ex.Message + ")", ex);
throw new UserAccountManagerException(GetString($"GetUser SQL returned an error {ex.Message}"), ex);
}
if (multiple)
throw new UserAccountManagerException(String.Format("Multiple user accounts found for {0} '{1}'", type, arg));
throw new UserAccountManagerException(GetString($"Multiple user accounts found for {type} '{arg}'"));
throw new UserAccountNotExistException(account.Name);
}
@ -447,7 +447,7 @@ namespace TShockAPI.DB
}
catch (SaltParseException)
{
TShock.Log.ConsoleError("Error: Unable to verify the password hash for user {0} ({1})", Name, ID);
TShock.Log.ConsoleError(GetString($"Unable to verify the password hash for user {Name} ({ID})"));
return false;
}
return false;
@ -465,7 +465,7 @@ namespace TShockAPI.DB
}
catch (FormatException)
{
TShock.Log.ConsoleError("Warning: Not upgrading work factor because bcrypt hash in an invalid format.");
TShock.Log.ConsoleWarn(GetString("Not upgrading work factor because bcrypt hash in an invalid format."));
return;
}
@ -488,7 +488,8 @@ namespace TShockAPI.DB
{
if (password.Trim().Length < Math.Max(4, TShock.Config.Settings.MinimumPasswordLength))
{
throw new ArgumentOutOfRangeException("password", "Password must be > " + TShock.Config.Settings.MinimumPasswordLength + " characters.");
int minLength = TShock.Config.Settings.MinimumPasswordLength;
throw new ArgumentOutOfRangeException("password", GetString($"Password must be at least {minLength} characters."));
}
try
{
@ -496,7 +497,7 @@ namespace TShockAPI.DB
}
catch (ArgumentOutOfRangeException)
{
TShock.Log.ConsoleError("Invalid BCrypt work factor in config file! Creating new hash using default work factor.");
TShock.Log.ConsoleError(GetString("Invalid BCrypt work factor in config file! Creating new hash using default work factor."));
Password = BCrypt.Net.BCrypt.HashPassword(password.Trim());
}
}
@ -508,7 +509,8 @@ namespace TShockAPI.DB
{
if (password.Trim().Length < Math.Max(4, TShock.Config.Settings.MinimumPasswordLength))
{
throw new ArgumentOutOfRangeException("password", "Password must be > " + TShock.Config.Settings.MinimumPasswordLength + " characters.");
int minLength = TShock.Config.Settings.MinimumPasswordLength;
throw new ArgumentOutOfRangeException("password", GetString($"Password must be at least {minLength} characters."));
}
Password = BCrypt.Net.BCrypt.HashPassword(password.Trim(), workFactor);
}
@ -607,7 +609,7 @@ namespace TShockAPI.DB
/// <param name="name">The name of the user account that already exists.</param>
/// <returns>A UserAccountExistsException object with the user's name passed in the message.</returns>
public UserAccountExistsException(string name)
: base("User account '" + name + "' already exists")
: base(GetString($"User account {name} already exists"))
{
}
}
@ -620,7 +622,7 @@ namespace TShockAPI.DB
/// <param name="name">The user account name to be pasesd in the message.</param>
/// <returns>A new UserAccountNotExistException object with a message containing the user account name that does not exist.</returns>
public UserAccountNotExistException(string name)
: base("User account '" + name + "' does not exist")
: base(GetString($"User account {name} does not exist"))
{
}
}
@ -633,7 +635,7 @@ namespace TShockAPI.DB
/// <param name="group">The group name.</param>
/// <returns>A new GroupNotExistsException with the group that does not exist's name in the message.</returns>
public GroupNotExistsException(string group)
: base("Group '" + group + "' does not exist")
: base(GetString($"Group {group} does not exist"))
{
}
}