diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 2a9b4f1f..c9b840a0 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -787,7 +787,7 @@ namespace TShockAPI (usingUUID && user.UUID == args.Player.UUID && !TShock.Config.DisableUUIDLogin && !String.IsNullOrWhiteSpace(args.Player.UUID))) { - args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, TShock.Users.GetUserID(user.Name)); + args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, user.ID); var group = TShock.Utils.GetGroup(user.Group); @@ -4137,8 +4137,8 @@ namespace TShockAPI User user = TShock.Users.GetUserByID(userId); if (user != null) return user.Name; - else - return string.Concat("{ID: ", userId, "}"); + + return string.Concat("{ID: ", userId, "}"); }); List extraLines = PaginationTools.BuildLinesFromTerms(sharedUsersSelector.Distinct()); extraLines[0] = "Shared with: " + extraLines[0]; @@ -4201,10 +4201,8 @@ namespace TShockAPI if ((boundaryPoint.X + boundaryPoint.Y & 1) == 0) args.Player.SendTileSquare(boundaryPoint.X, boundaryPoint.Y, 1); - // ReSharper disable AccessToModifiedClosure Debug.Assert(boundaryHideTimer != null); boundaryHideTimer.Dispose(); - // ReSharper restore AccessToModifiedClosure }, null, 5000, Timeout.Infinite ); diff --git a/TShockAPI/DB/CharacterManager.cs b/TShockAPI/DB/CharacterManager.cs index 1c4f855b..3c772b3b 100755 --- a/TShockAPI/DB/CharacterManager.cs +++ b/TShockAPI/DB/CharacterManager.cs @@ -143,6 +143,11 @@ namespace TShockAPI.DB return false; } + /// + /// Inserts player data to the tsCharacter database table + /// + /// player to take data from + /// true if inserted successfully public bool InsertPlayerData(TSPlayer player) { PlayerData playerData = player.PlayerData; @@ -151,13 +156,13 @@ namespace TShockAPI.DB return false; - if (!GetPlayerData(player, player.UserID).exists) + if (!GetPlayerData(player, player.User.ID).exists) { try { database.Query( "INSERT INTO tsCharacter (Account, Health, MaxHealth, Mana, MaxMana, Inventory, spawnX, spawnY, hair, hairDye, hairColor, pantsColor, shirtColor, underShirtColor, shoeColor, hideVisuals, skinColor, eyeColor, questsCompleted) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18);", - player.UserID, playerData.health, playerData.maxHealth, playerData.mana, playerData.maxMana, NetItem.ToString(playerData.inventory), player.TPlayer.SpawnX, player.TPlayer.SpawnY, player.TPlayer.hair, player.TPlayer.hairDye, TShock.Utils.EncodeColor(player.TPlayer.hairColor), TShock.Utils.EncodeColor(player.TPlayer.pantsColor),TShock.Utils.EncodeColor(player.TPlayer.shirtColor), TShock.Utils.EncodeColor(player.TPlayer.underShirtColor), TShock.Utils.EncodeColor(player.TPlayer.shoeColor), TShock.Utils.EncodeBitsByte(player.TPlayer.hideVisual), TShock.Utils.EncodeColor(player.TPlayer.skinColor),TShock.Utils.EncodeColor(player.TPlayer.eyeColor), player.TPlayer.anglerQuestsFinished); + player.User.ID, playerData.health, playerData.maxHealth, playerData.mana, playerData.maxMana, NetItem.ToString(playerData.inventory), player.TPlayer.SpawnX, player.TPlayer.SpawnY, player.TPlayer.hair, player.TPlayer.hairDye, TShock.Utils.EncodeColor(player.TPlayer.hairColor), TShock.Utils.EncodeColor(player.TPlayer.pantsColor),TShock.Utils.EncodeColor(player.TPlayer.shirtColor), TShock.Utils.EncodeColor(player.TPlayer.underShirtColor), TShock.Utils.EncodeColor(player.TPlayer.shoeColor), TShock.Utils.EncodeBitsByte(player.TPlayer.hideVisual), TShock.Utils.EncodeColor(player.TPlayer.skinColor),TShock.Utils.EncodeColor(player.TPlayer.eyeColor), player.TPlayer.anglerQuestsFinished); return true; } catch (Exception ex) @@ -171,7 +176,7 @@ namespace TShockAPI.DB { database.Query( "UPDATE tsCharacter SET Health = @0, MaxHealth = @1, Mana = @2, MaxMana = @3, Inventory = @4, spawnX = @6, spawnY = @7, hair = @8, hairDye = @9, hairColor = @10, pantsColor = @11, shirtColor = @12, underShirtColor = @13, shoeColor = @14, hideVisuals = @15, skinColor = @16, eyeColor = @17, questsCompleted = @18 WHERE Account = @5;", - playerData.health, playerData.maxHealth, playerData.mana, playerData.maxMana, NetItem.ToString(playerData.inventory), player.UserID, player.TPlayer.SpawnX, player.TPlayer.SpawnY, player.TPlayer.hair, player.TPlayer.hairDye, TShock.Utils.EncodeColor(player.TPlayer.hairColor), TShock.Utils.EncodeColor(player.TPlayer.pantsColor), TShock.Utils.EncodeColor(player.TPlayer.shirtColor), TShock.Utils.EncodeColor(player.TPlayer.underShirtColor), TShock.Utils.EncodeColor(player.TPlayer.shoeColor), TShock.Utils.EncodeBitsByte(player.TPlayer.hideVisual), TShock.Utils.EncodeColor(player.TPlayer.skinColor), TShock.Utils.EncodeColor(player.TPlayer.eyeColor), player.TPlayer.anglerQuestsFinished); + playerData.health, playerData.maxHealth, playerData.mana, playerData.maxMana, NetItem.ToString(playerData.inventory), player.User.ID, player.TPlayer.SpawnX, player.TPlayer.SpawnY, player.TPlayer.hair, player.TPlayer.hairDye, TShock.Utils.EncodeColor(player.TPlayer.hairColor), TShock.Utils.EncodeColor(player.TPlayer.pantsColor), TShock.Utils.EncodeColor(player.TPlayer.shirtColor), TShock.Utils.EncodeColor(player.TPlayer.underShirtColor), TShock.Utils.EncodeColor(player.TPlayer.shoeColor), TShock.Utils.EncodeBitsByte(player.TPlayer.hideVisual), TShock.Utils.EncodeColor(player.TPlayer.skinColor), TShock.Utils.EncodeColor(player.TPlayer.eyeColor), player.TPlayer.anglerQuestsFinished); return true; } catch (Exception ex) @@ -182,6 +187,11 @@ namespace TShockAPI.DB return false; } + /// + /// Removes a player's data from the tsCharacter database table + /// + /// User ID of the player + /// true if removed successfully public bool RemovePlayer(int userid) { try diff --git a/TShockAPI/DB/RegionManager.cs b/TShockAPI/DB/RegionManager.cs index 03a3c004..9b444c3c 100755 --- a/TShockAPI/DB/RegionManager.cs +++ b/TShockAPI/DB/RegionManager.cs @@ -334,6 +334,12 @@ namespace TShockAPI.DB return false; } + /// + /// Removes an allowed user from a region + /// + /// Name of the region to modify + /// Username to remove + /// true if removed successfully public bool RemoveUser(string regionName, string userName) { Region r = GetRegionByName(regionName); @@ -349,6 +355,12 @@ namespace TShockAPI.DB return false; } + /// + /// Adds a user to a region's allowed user list + /// + /// Name of the region to modify + /// Username to add + /// true if added successfully public bool AddNewUser(string regionName, string userName) { try diff --git a/TShockAPI/DB/UserManager.cs b/TShockAPI/DB/UserManager.cs index d2514ef9..f44ca38b 100755 --- a/TShockAPI/DB/UserManager.cs +++ b/TShockAPI/DB/UserManager.cs @@ -17,7 +17,6 @@ along with this program. If not, see . */ using System; -using System.CodeDom.Compiler; using System.Data; using System.Collections.Generic; using System.Linq; @@ -33,14 +32,14 @@ namespace TShockAPI.DB public class UserManager { /// database - The database object to use for connections. - private IDbConnection database; + private IDbConnection _database; - /// UserManager - Creates a UserManager object. During instantiation, this method will verify the table structure against the format below. - /// db - The database to connect to. + /// Creates a UserManager object. During instantiation, this method will verify the table structure against the format below. + /// The database to connect to. /// A UserManager object. public UserManager(IDbConnection db) { - database = db; + _database = db; var table = new SqlTable("Users", new SqlColumn("ID", MySqlDbType.Int32) {Primary = true, AutoIncrement = true}, @@ -71,7 +70,7 @@ namespace TShockAPI.DB int ret; try { - ret = database.Query("INSERT INTO Users (Username, Password, UUID, UserGroup, Registered) VALUES (@0, @1, @2, @3, @4);", user.Name, + ret = _database.Query("INSERT INTO Users (Username, Password, UUID, UserGroup, Registered) VALUES (@0, @1, @2, @3, @4);", user.Name, user.Password, user.UUID, user.Group, DateTime.UtcNow.ToString("s")); } catch (Exception ex) @@ -97,7 +96,7 @@ namespace TShockAPI.DB try { var tempuser = GetUser(user); - int affected = database.Query("DELETE FROM Users WHERE Username=@0", user.Name); + int affected = _database.Query("DELETE FROM Users WHERE Username=@0", user.Name); if (affected < 1) throw new UserNotExistException(user.Name); @@ -120,7 +119,7 @@ namespace TShockAPI.DB try { if ( - database.Query("UPDATE Users SET Password = @0 WHERE Username = @1;", user.Password, + _database.Query("UPDATE Users SET Password = @0 WHERE Username = @1;", user.Password, user.Name) == 0) throw new UserNotExistException(user.Name); } @@ -140,7 +139,7 @@ namespace TShockAPI.DB try { if ( - database.Query("UPDATE Users SET UUID = @0 WHERE Username = @1;", uuid, + _database.Query("UPDATE Users SET UUID = @0 WHERE Username = @1;", uuid, user.Name) == 0) throw new UserNotExistException(user.Name); } @@ -163,7 +162,7 @@ namespace TShockAPI.DB if (null == grp) throw new GroupNotExistsException(group); - if (database.Query("UPDATE Users SET UserGroup = @0 WHERE Username = @1;", group, user.Name) == 0) + if (_database.Query("UPDATE Users SET UserGroup = @0 WHERE Username = @1;", group, user.Name) == 0) throw new UserNotExistException(user.Name); // Update player group reference for any logged in player @@ -178,13 +177,13 @@ namespace TShockAPI.DB } } - /// UpdateLogin - Updates the last accessed time for a database user to the current time. - /// user - The user object to modify. + /// Updates the last accessed time for a database user to the current time. + /// The user object to modify. public void UpdateLogin(User user) { try { - if (database.Query("UPDATE Users SET LastAccessed = @0, KnownIps = @1 WHERE Username = @2;", DateTime.UtcNow.ToString("s"), user.KnownIps, user.Name) == 0) + if (_database.Query("UPDATE Users SET LastAccessed = @0, KnownIps = @1 WHERE Username = @2;", DateTime.UtcNow.ToString("s"), user.KnownIps, user.Name) == 0) throw new UserNotExistException(user.Name); } catch (Exception ex) @@ -193,14 +192,14 @@ namespace TShockAPI.DB } } - /// GetUserID - Gets the database ID of a given user object from the database. - /// username - The username of the user to query for. - /// int - The user's ID + /// Gets the database ID of a given user object from the database. + /// The username of the user to query for. + /// The user's ID public int GetUserID(string username) { try { - using (var reader = database.QueryReader("SELECT * FROM Users WHERE Username=@0", username)) + using (var reader = _database.QueryReader("SELECT * FROM Users WHERE Username=@0", username)) { if (reader.Read()) { @@ -215,9 +214,9 @@ namespace TShockAPI.DB return -1; } - /// GetUserByName - Gets a user object by name. - /// name - The user's name. - /// User - The user object returned from the search. + /// Gets a user object by name. + /// The user's name. + /// The user object returned from the search. public User GetUserByName(string name) { try @@ -230,9 +229,9 @@ namespace TShockAPI.DB } } - /// GetUserByID - Gets a user object by their user ID. - /// id - The user's ID. - /// User - The user object returned from the search. + /// Gets a user object by their user ID. + /// The user's ID. + /// The user object returned from the search. public User GetUserByID(int id) { try @@ -245,9 +244,9 @@ namespace TShockAPI.DB } } - /// GetUser - Gets a user object by a user object. - /// user - The user object to search by. - /// User - The user object that is returned from the search. + /// Gets a user object by a user object. + /// The user object to search by. + /// The user object that is returned from the search. public User GetUser(User user) { bool multiple = false; @@ -269,7 +268,7 @@ namespace TShockAPI.DB try { - using (var result = database.QueryReader(query, arg)) + using (var result = _database.QueryReader(query, arg)) { if (result.Read()) { @@ -291,14 +290,14 @@ namespace TShockAPI.DB throw new UserNotExistException(user.Name); } - /// GetUsers - Gets all users from the database. - /// List - The users from the database. + /// Gets all users from the database. + /// The users from the database. public List GetUsers() { try { List users = new List(); - using (var reader = database.QueryReader("SELECT * FROM Users")) + using (var reader = _database.QueryReader("SELECT * FROM Users")) { while (reader.Read()) { @@ -315,18 +314,18 @@ namespace TShockAPI.DB } /// - /// GetUsersByName - Gets all users from the database with a username that starts with or contains + /// Gets all users from the database with a username that starts with or contains /// - /// String - Rough username search. "n" will match "n", "na", "nam", "name", etc - /// Boolean - If is not the first part of the username. If true then "name" would match "name", "username", "wordsnamewords", etc - /// List or null - Matching users or null if exception is thrown + /// Rough username search. "n" will match "n", "na", "nam", "name", etc + /// If is not the first part of the username. If true then "name" would match "name", "username", "wordsnamewords", etc + /// Matching users or null if exception is thrown public List GetUsersByName(string username, bool notAtStart = false) { try { List users = new List(); string search = notAtStart ? string.Format("%{0}%", username) : string.Format("{0}%", username); - using (var reader = database.QueryReader("SELECT * FROM Users WHERE Username LIKE @0", + using (var reader = _database.QueryReader("SELECT * FROM Users WHERE Username LIKE @0", search)) { while (reader.Read()) @@ -343,10 +342,10 @@ namespace TShockAPI.DB return null; } - /// LoadUserFromResult - Fills out the fields of a User object with the results from a QueryResult object. - /// user - The user to add data to. - /// result - The QueryResult object to add data from. - /// User - The 'filled out' user object. + /// Fills out the fields of a User object with the results from a QueryResult object. + /// The user to add data to. + /// The QueryResult object to add data from. + /// The 'filled out' user object. private User LoadUserFromResult(User user, QueryResult result) { user.ID = result.Get("ID"); @@ -361,41 +360,41 @@ namespace TShockAPI.DB } } - /// User - A database user. + /// A database user. public class User { - /// ID - The database ID of the user. + /// The database ID of the user. public int ID { get; set; } - /// Name - The user's name. + /// The user's name. public string Name { get; set; } - /// Password - The hashed password for the user. + /// The hashed password for the user. public string Password { get; internal set; } - /// UUID - The user's saved Univerally Unique Identifier token. + /// The user's saved Univerally Unique Identifier token. public string UUID { get; set; } - /// Group - The group object that the user is a part of. + /// The group object that the user is a part of. public string Group { get; set; } - /// Registered - The unix epoch corresponding to the registration date of the user. + /// The unix epoch corresponding to the registration date of the user. public string Registered { get; set; } - /// LastAccessed - The unix epoch corresponding to the last access date of the user. + /// The unix epoch corresponding to the last access date of the user. public string LastAccessed { get; set; } - /// KnownIps - A JSON serialized list of known IP addresses for a user. + /// A JSON serialized list of known IP addresses for a user. public string KnownIps { get; set; } - /// User - Constructor for the user object, assuming you define everything yourself. - /// name - The user's name. - /// pass - The user's password hash. - /// uuid - The user's UUID. - /// group - The user's group name. - /// registered - The unix epoch for the registration date. - /// last - The unix epoch for the last access date. - /// known - The known IPs for the user, serialized as a JSON object + /// Constructor for the user object, assuming you define everything yourself. + /// The user's name. + /// The user's password hash. + /// The user's UUID. + /// The user's group name. + /// The unix epoch for the registration date. + /// The unix epoch for the last access date. + /// The known IPs for the user, serialized as a JSON object /// A completed user object. public User(string name, string pass, string uuid, string group, string registered, string last, string known) { @@ -408,7 +407,7 @@ namespace TShockAPI.DB KnownIps = known; } - /// User - Default constructor for a user object; holds no data. + /// Default constructor for a user object; holds no data. /// A user object. public User() { @@ -427,13 +426,13 @@ namespace TShockAPI.DB /// If the password is stored using BCrypt, it will be re-saved if the work factor in the config /// is greater than the existing work factor with the new work factor. /// - /// string password - The password to check against the user object. + /// The password to check against the user object. /// bool true, if the password matched, or false, if it didn't. public bool VerifyPassword(string password) { try { - if (BCrypt.Net.BCrypt.Verify(password, this.Password)) + if (BCrypt.Net.BCrypt.Verify(password, Password)) { // If necessary, perform an upgrade to the highest work factor. UpgradePasswordWorkFactor(password); @@ -442,10 +441,10 @@ namespace TShockAPI.DB } catch (SaltParseException) { - if (HashPassword(password).ToUpper() == this.Password.ToUpper()) + if (HashPassword(password).ToUpper() == Password.ToUpper()) { // Return true to keep blank passwords working but don't convert them to bcrypt. - if (this.Password == "non-existant password") { + if (Password == "non-existant password") { return true; } // The password is not stored using BCrypt; upgrade it to BCrypt immediately @@ -458,43 +457,43 @@ namespace TShockAPI.DB } /// Upgrades a password to BCrypt, from an insecure hashing algorithm. - /// string password - the raw user password (unhashed) to upgrade + /// The raw user password (unhashed) to upgrade protected void UpgradePasswordToBCrypt(string password) { // Save the old password, in the event that we have to revert changes. - string oldpassword = this.Password; + string oldpassword = Password; // Convert the password to BCrypt, and save it. try { - this.Password = BCrypt.Net.BCrypt.HashPassword(password, TShock.Config.BCryptWorkFactor); + Password = BCrypt.Net.BCrypt.HashPassword(password, TShock.Config.BCryptWorkFactor); } catch (ArgumentOutOfRangeException) { TShock.Log.ConsoleError("Invalid BCrypt work factor in config file! Upgrading user password to BCrypt using default work factor."); - this.Password = BCrypt.Net.BCrypt.HashPassword(password); + Password = BCrypt.Net.BCrypt.HashPassword(password); } try { - TShock.Users.SetUserPassword(this, this.Password); + TShock.Users.SetUserPassword(this, Password); } catch (UserManagerException e) { TShock.Log.ConsoleError(e.ToString()); - this.Password = oldpassword; // Revert changes + Password = oldpassword; // Revert changes } } /// Upgrades a password to the highest work factor available in the config. - /// string password - the raw user password (unhashed) to upgrade + /// The raw user password (unhashed) to upgrade protected void UpgradePasswordWorkFactor(string password) { // If the destination work factor is not greater, we won't upgrade it or re-hash it - int currentWorkFactor = 0; + int currentWorkFactor; try { - currentWorkFactor = Int32.Parse((this.Password.Split('$')[2])); + currentWorkFactor = Int32.Parse((Password.Split('$')[2])); } catch (FormatException) { @@ -506,7 +505,7 @@ namespace TShockAPI.DB { try { - this.Password = BCrypt.Net.BCrypt.HashPassword(password, TShock.Config.BCryptWorkFactor); + Password = BCrypt.Net.BCrypt.HashPassword(password, TShock.Config.BCryptWorkFactor); } catch (ArgumentOutOfRangeException) { @@ -515,7 +514,7 @@ namespace TShockAPI.DB try { - TShock.Users.SetUserPassword(this, this.Password); + TShock.Users.SetUserPassword(this, Password); } catch (UserManagerException e) { @@ -525,7 +524,7 @@ namespace TShockAPI.DB } /// Creates a BCrypt hash for a user and stores it in this object. - /// string password - the plain text password to hash + /// The plain text password to hash public void CreateBCryptHash(string password) { if (password.Trim().Length < Math.Max(4, TShock.Config.MinimumPasswordLength)) @@ -534,25 +533,25 @@ namespace TShockAPI.DB } try { - this.Password = BCrypt.Net.BCrypt.HashPassword(password.Trim(), TShock.Config.BCryptWorkFactor); + Password = BCrypt.Net.BCrypt.HashPassword(password.Trim(), TShock.Config.BCryptWorkFactor); } catch (ArgumentOutOfRangeException) { TShock.Log.ConsoleError("Invalid BCrypt work factor in config file! Creating new hash using default work factor."); - this.Password = BCrypt.Net.BCrypt.HashPassword(password.Trim()); + Password = BCrypt.Net.BCrypt.HashPassword(password.Trim()); } } /// Creates a BCrypt hash for a user and stores it in this object. - /// string password - the plain text password to hash - /// int workFactor - the work factor to use in generating the password hash + /// The plain text password to hash + /// The work factor to use in generating the password hash public void CreateBCryptHash(string password, int workFactor) { if (password.Trim().Length < Math.Max(4, TShock.Config.MinimumPasswordLength)) { throw new ArgumentOutOfRangeException("password", "Password must be > " + TShock.Config.MinimumPasswordLength + " characters."); } - this.Password = BCrypt.Net.BCrypt.HashPassword(password.Trim(), workFactor); + Password = BCrypt.Net.BCrypt.HashPassword(password.Trim(), workFactor); } /// @@ -595,7 +594,7 @@ namespace TShockAPI.DB /// string hash protected string HashPassword(string password) { - if (string.IsNullOrEmpty(password) && this.Password == "non-existant password") + if (string.IsNullOrEmpty(password) && Password == "non-existant password") return "non-existant password"; return HashPassword(Encoding.UTF8.GetBytes(password)); } @@ -606,57 +605,57 @@ namespace TShockAPI.DB [Serializable] public class UserManagerException : Exception { - /// UserManagerException - Creates a new UserManagerException object. - /// message - The message for the object. - /// public - a new UserManagerException object. + /// Creates a new UserManagerException object. + /// The message for the object. + /// A new UserManagerException object. public UserManagerException(string message) : base(message) { } - /// UserManagerException - Creates a new UserManagerObject with an internal exception. - /// message - The message for the object. - /// inner - The inner exception for the object. - /// public - a nwe UserManagerException with a defined inner exception. + /// Creates a new UserManagerObject with an internal exception. + /// The message for the object. + /// The inner exception for the object. + /// A new UserManagerException with a defined inner exception. public UserManagerException(string message, Exception inner) : base(message, inner) { } } - /// UserExistsException - A UserExistsException object, used when a user already exists when attempting to create a new one. + /// A UserExistsException object, used when a user already exists when attempting to create a new one. [Serializable] public class UserExistsException : UserManagerException { - /// UserExistsException - Creates a new UserExistsException object. - /// name - The name of the user that already exists. - /// public - a UserExistsException object with the user's name passed in the message. + /// Creates a new UserExistsException object. + /// The name of the user that already exists. + /// A UserExistsException object with the user's name passed in the message. public UserExistsException(string name) : base("User '" + name + "' already exists") { } } - /// UserNotExistException - A UserNotExistException, used when a user does not exist and a query failed as a result of it. + /// A UserNotExistException, used when a user does not exist and a query failed as a result of it. [Serializable] public class UserNotExistException : UserManagerException { - /// UserNotExistException - Creates a new UserNotExistException object, with the user's name in the message. - /// name - The user's name to be pasesd in the message. - /// public - a new UserNotExistException object with a message containing the user's name that does not exist. + /// Creates a new UserNotExistException object, with the user's name in the message. + /// The user's name to be pasesd in the message. + /// A new UserNotExistException object with a message containing the user's name that does not exist. public UserNotExistException(string name) : base("User '" + name + "' does not exist") { } } - /// GroupNotExistsException - A GroupNotExistsException, used when a group does not exist. + /// A GroupNotExistsException, used when a group does not exist. [Serializable] public class GroupNotExistsException : UserManagerException { - /// GroupNotExistsException - Creates a new GroupNotExistsException object with the group's name in the message. - /// group - The group name. - /// public - a new GroupNotExistsException with the group that does not exist's name in the message. + /// Creates a new GroupNotExistsException object with the group's name in the message. + /// The group name. + /// A new GroupNotExistsException with the group that does not exist's name in the message. public GroupNotExistsException(string group) : base("Group '" + group + "' does not exist") { diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 76a33811..2d3f8444 100755 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1438,7 +1438,7 @@ namespace TShockAPI { if(user.UUID == args.Player.UUID) { - args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, TShock.Users.GetUserID(args.Player.Name)); + args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, user.ID); if (args.Player.State == 1) args.Player.State = 2; @@ -1514,7 +1514,7 @@ namespace TShockAPI if (user.VerifyPassword(password)) { args.Player.RequiresPassword = false; - args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, TShock.Users.GetUserID(args.Player.Name)); + args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, user.ID); if (args.Player.State == 1) args.Player.State = 2; diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index cad13756..c3f01be3 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -85,7 +85,7 @@ namespace TShockAPI { if (includeIDs) { - players.Add(ply.Name + " (IX: " + ply.Index + ", ID: " + ply.UserID + ")"); + players.Add(ply.Name + " (IX: " + ply.Index + ", ID: " + ply.User.ID + ")"); } else {