/// <summary> /// Retrieves the figure details of the Habbo matching the specified Habbo ID. /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool GetFigureFromHabboId(int habboId, out string figureString, out bool gender, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `figure`, `gender` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteReader(parameters)) { if (!reader.HasRows) { figureString = ""; gender = true; return(false); } while (reader.Read()) { figureString = reader["figure"] as string; gender = (bool)reader["gender"]; return(true); } } } // Should never even be reached... but it is needed... figureString = ""; gender = true; return(false); }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static Dictionary <string, PermissionState> GetHabboPermissionsFromHabboId(int habboId, WrappedMySqlConnection connection = null) { Dictionary <string, PermissionState> permissions = new Dictionary <string, PermissionState>(); Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `permission_name`, `permission_state` FROM `permission_habbo_permissions` WHERE `habbo_id` = @habbo_id").ExecuteReader(parameters)) { while (reader.Read()) { if ((sbyte)reader["permission_state"] == 1) { permissions.Add((string)reader["permission_name"], PermissionState.Allow); } else { permissions.Add((string)reader["permission_name"], PermissionState.Deny); } } return(permissions); } } ; }
/// <summary> /// SUMMARY /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool GetSubscriptionData(int habboId, string subscriptionType, out int totalBought, out int skippedLength, out int pausedStart, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@subscription_type", subscriptionType); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `total_bought`, `skipped_length`, `paused_start` FROM `subscriptions` WHERE `habbo_id` = @habbo_id AND `subscription_type` = @subscription_type LIMIT 1").ExecuteReader(parameters)) { if (!reader.HasRows) { totalBought = 0; skippedLength = 0; pausedStart = 0; return false; } reader.Read(); totalBought = (int)reader["total_bought"]; skippedLength = (int)reader["skipped_length"]; pausedStart = (int)reader["paused_start"]; return true; } } }
/// <summary> /// SUMMARY /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool GetSubscriptionData(int habboId, string subscriptionType, out int totalBought, out int skippedLength, out int pausedStart, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@subscription_type", subscriptionType); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `total_bought`, `skipped_length`, `paused_start` FROM `subscriptions` WHERE `habbo_id` = @habbo_id AND `subscription_type` = @subscription_type LIMIT 1").ExecuteReader(parameters)) { if (!reader.HasRows) { totalBought = 0; skippedLength = 0; pausedStart = 0; return(false); } reader.Read(); totalBought = (int)reader["total_bought"]; skippedLength = (int)reader["skipped_length"]; pausedStart = (int)reader["paused_start"]; return(true); } } }
/// <summary> /// Sets a persistent value. /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetPersistentValue(string typeName, long instanceId, string variableName, byte[] value, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@type_name", typeName); parameters.Add("@instance_id", instanceId); parameters.Add("@variable_name", variableName); parameters.Add("@value", value); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { if (value != null) { return(connection.GetCachedCommand("INSERT INTO `persistent_storage` (`type_name`, `instance_id`, `variable_name`, `value`) VALUES (@type_name, @instance_id, @variable_name, @value) ON DUPLICATE KEY UPDATE `value` = @value").ExecuteNonQuery(parameters) > 0); } return(connection.GetCachedCommand("DELETE FROM `persistent_storage` WHERE `type_name` = @type_name AND `instance_id` = @instance_id AND `variable_name` = @variable_name").ExecuteNonQuery(parameters) > 0); } }
/// <summary> /// /// </summary> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool DoesHabboIdExist(int habboId, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return connection.GetCachedCommand("SELECT 1 FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteScalar(parameters) != null; } }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool AddHabboPermissionGroups(int habboId, string groupName, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@group_name", groupName); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return connection.GetCachedCommand("INSERT INTO `permission_habbo_groups` SET `habbo_id` = @habbo_id, `group_name` = @group_name").ExecuteNonQuery(parameters) > 0; } }
/// <summary> /// /// </summary> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool DoesHabboIdExist(int habboId, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return(connection.GetCachedCommand("SELECT 1 FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteScalar(parameters) != null); } }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetHabboPermissionsFromId(int habboId, string permissionName, PermissionState permissionState, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@permission_name", permissionName); if (permissionState == PermissionState.Undefined) { using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return(connection.GetCachedCommand("DELETE FROM `permission_habbo_permissions` WHERE `habbo_id` = @habbo_id AND `permission_name`= @permission_name").ExecuteNonQuery(parameters) > 0); } } parameters.Add("@permission_state", (int)permissionState); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return(connection.GetCachedCommand("INSERT INTO `permission_habbo_permissions` SET `habbo_id` = @habbo_id, `permission_name` = @permission_name, `permission_state` = @permission_state ON DUPLICATE KEY UPDATE `permission_state` = @permission_state").ExecuteNonQuery(parameters) > 0); } }
/// <summary> /// Updates the SSO ticket of the Habbo matching the specified Habbo ID. /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetSSOTicketFromHabboId(int habboId, string ssoTicket, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@sso_ticket", ssoTicket); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return(connection.GetCachedCommand("UPDATE `habbos` SET `sso_ticket` = @sso_ticket WHERE `habbo_id` = @habbo_id").ExecuteNonQuery(parameters) > 0); } }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool RemoveHabboPermissionGroups(int habboId, string groupName, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@group_name", groupName); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return(connection.GetCachedCommand("DELETE FROM `permission_habbo_groups` WHERE `habbo_id` = @habbo_id AND `group_name` = @group_name").ExecuteNonQuery(parameters) > 0); } }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetRoomDescriptionFromRoomId(int roomId, string description, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@room_id", roomId); parameters.Add("@description", description); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { // Get the value from the database and return it. return(connection.GetCachedCommand("UPDATE `rooms` SET `description` = @description WHERE `room_id` = @room_id").ExecuteNonQuery(parameters) > 0); } }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetMottoFromHabboId(int habboId, string motto, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@motto", motto); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { // Get the value from the database and return it. return(connection.GetCachedCommand("UPDATE `habbos` SET `motto` = @motto WHERE `habbo_id` = @habbo_id").ExecuteNonQuery(parameters) > 0); } }
/// <summary> /// Updates the last access date of the Habbo matching the specified Habbo ID. /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetLastAccessDateFromHabboId(int habboId, DateTime lastAccessDate, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@last_access", lastAccessDate); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { // Get the value from the database and return it. return(connection.GetCachedCommand("UPDATE `habbos` SET `last_access` = @last_access WHERE `habbo_id` = @habbo_id").ExecuteNonQuery(parameters) > 0); } }
/// <summary> /// Retrieves a persistent value. /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static byte[] GetPersistentValue(string typeName, long instanceId, string variableName, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@type_name", typeName); parameters.Add("@instance_id", instanceId); parameters.Add("@variable_name", variableName); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return(connection.GetCachedCommand("SELECT `value` FROM `persistent_storage` WHERE `type_name` = @type_name AND `instance_id` = @instance_id AND `variable_name` LIMIT 1").ExecuteScalar(parameters) as byte[]); } }
/// <summary> /// SUMMARY /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetSubscriptionData(int habboId, string subscriptionType, int totalBought, int skippedLength, int pausedStart, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@subscription_type", subscriptionType); parameters.Add("@total_bought", totalBought); parameters.Add("@skipped_length", skippedLength); parameters.Add("@paused_start", pausedStart); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return connection.GetCachedCommand("INSERT INTO `subscriptions` (`habbo_id`, `subscription_type`, `total_bought`, `skipped_length`, `paused_start`) VALUES (@habbo_id, @subscription_type, @total_bought, @skipped_length, @paused_start) ON DUPLICATE KEY UPDATE `total_bought` = @total_bought, `skipped_length` = @skipped_length, `paused_start` = @paused_start").ExecuteNonQuery(parameters) >= 1; } }
/// <summary> /// /// </summary> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static string GetRoomDescriptionFromRoomId(int roomId, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@room_id", roomId); string returnValue; using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { returnValue = connection.GetCachedCommand("SELECT `description` FROM `rooms` WHERE `room_id` = @room_id").ExecuteScalar(parameters) as string; } if (returnValue != null) return returnValue; throw new NoResultsException(); }
/// <summary> /// SUMMARY /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetSubscriptionData(int habboId, string subscriptionType, int totalBought, int skippedLength, int pausedStart, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@subscription_type", subscriptionType); parameters.Add("@total_bought", totalBought); parameters.Add("@skipped_length", skippedLength); parameters.Add("@paused_start", pausedStart); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return(connection.GetCachedCommand("INSERT INTO `subscriptions` (`habbo_id`, `subscription_type`, `total_bought`, `skipped_length`, `paused_start`) VALUES (@habbo_id, @subscription_type, @total_bought, @skipped_length, @paused_start) ON DUPLICATE KEY UPDATE `total_bought` = @total_bought, `skipped_length` = @skipped_length, `paused_start` = @paused_start").ExecuteNonQuery(parameters) >= 1); } }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static int GetCreditsFromHabboId(int habboId, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); object returnValue; using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { // Get the value from the database. returnValue = connection.GetCachedCommand("SELECT `last_access` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteScalar(parameters); } if (returnValue != null) return (int)returnValue; throw new NoResultsException(); }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static ICollection<PermissionsGroupPermissionData> GetAllPermissionGroupPermissions(WrappedMySqlConnection connection = null) { List<PermissionsGroupPermissionData> groupPermissions = new List<PermissionsGroupPermissionData>(); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `group_name`, `permission_name`, `permission_state` FROM `permission_group_permissions`").ExecuteReader()) { while (reader.Read()) { groupPermissions.Add(new PermissionsGroupPermissionData((string)reader["group_name"], (string)reader["permission_name"], (PermissionState)reader["permission_state"])); // TODO: Test if a direct cast to PermissionState is possible. } return groupPermissions; } } }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static ICollection <PermissionsGroupPermissionData> GetAllPermissionGroupPermissions(WrappedMySqlConnection connection = null) { List <PermissionsGroupPermissionData> groupPermissions = new List <PermissionsGroupPermissionData>(); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `group_name`, `permission_name`, `permission_state` FROM `permission_group_permissions`").ExecuteReader()) { while (reader.Read()) { groupPermissions.Add(new PermissionsGroupPermissionData((string)reader["group_name"], (string)reader["permission_name"], (PermissionState)reader["permission_state"])); // TODO: Test if a direct cast to PermissionState is possible. } return(groupPermissions); } } }
/// <summary> /// Retrieves the ID of the Habbo matching the specified username. /// </summary> /// <param name="username">The Habbo username to match.</param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns>The ID of the Habbo.</returns> public static int GetHabboIdFromHabboUsername(string username, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@username", username); object returnValue; using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { returnValue = connection.GetCachedCommand("SELECT `habbo_id` FROM `habbos` WHERE `username` = @username").ExecuteScalar(parameters); } if (returnValue != null) { return((int)returnValue); } throw new NoResultsException(); }
/// <summary> /// Retrieves the username of the Habbo matching the specified Habbo ID. /// </summary> /// <param name="habboId">The Habbo ID to match.</param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns>The username of the Habbo.</returns> public static string GetHabboUsernameFromHabboId(int habboId, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); string returnValue; using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { returnValue = connection.GetCachedCommand("SELECT `username` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteScalar(parameters) as string; } if (returnValue != null) { return(returnValue); } throw new NoResultsException(); }
/// <summary> /// /// </summary> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static string GetRoomModelFromRoomId(int roomId, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@room_id", roomId); string returnValue; using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { returnValue = connection.GetCachedCommand("SELECT `model` FROM `rooms` WHERE `room_id` = @room_id").ExecuteScalar(parameters) as string; } if (returnValue != null) { return(returnValue); } throw new NoResultsException(); }
/// <summary> /// Retrieves the IDs of the Rooms owned by owner ID. /// </summary> /// <param name="ownerId">The owner ID to search with.</param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> public static IEnumerable<int> GetRoomIdsFromRoomOwner(string ownerId, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@owner_id", ownerId); List<int> roomIds = new List<int>(); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `room_id` FROM `rooms` WHERE `owner_id` = @owner_id").ExecuteReader(parameters)) { while (reader.Read()) { roomIds.Add((int)reader["room_id"]); } return roomIds; } } }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static IEnumerable<string> GetHabboPermissionGroupsFromHabboId(int habboId, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); List<string> groupNames = new List<string>(); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `group_name` FROM `permission_habbo_groups` WHERE `habbo_id` = @habbo_id").ExecuteReader(parameters)) { while (reader.Read()) { groupNames.Add((string)reader["group_name"]); } return groupNames; } } }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static string GetMottoFromHabboId(int habboId, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); object returnValue; using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { // Get the value from the database. returnValue = connection.GetCachedCommand("SELECT `motto` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteScalar(parameters); } if (returnValue != null) { return((string)returnValue); } throw new NoResultsException(); }
/// <summary> /// Retrieves the IDs of the Rooms owned by owner ID. /// </summary> /// <param name="ownerId">The owner ID to search with.</param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> public static IEnumerable <int> GetRoomIdsFromRoomOwner(string ownerId, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@owner_id", ownerId); List <int> roomIds = new List <int>(); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `room_id` FROM `rooms` WHERE `owner_id` = @owner_id").ExecuteReader(parameters)) { while (reader.Read()) { roomIds.Add((int)reader["room_id"]); } return(roomIds); } } }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static IEnumerable <string> GetHabboPermissionGroupsFromHabboId(int habboId, WrappedMySqlConnection connection = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@habbo_id", habboId); List <string> groupNames = new List <string>(); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `group_name` FROM `permission_habbo_groups` WHERE `habbo_id` = @habbo_id").ExecuteReader(parameters)) { while (reader.Read()) { groupNames.Add((string)reader["group_name"]); } return(groupNames); } } }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static Dictionary<string, PermissionState> GetHabboPermissionsFromHabboId(int habboId, WrappedMySqlConnection connection = null) { Dictionary<string, PermissionState> permissions = new Dictionary<string, PermissionState>(); Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `permission_name`, `permission_state` FROM `permission_habbo_permissions` WHERE `habbo_id` = @habbo_id").ExecuteReader(parameters)) { while (reader.Read()) { if((sbyte)reader["permission_state"] == 1) permissions.Add((string)reader["permission_name"], PermissionState.Allow); else permissions.Add((string)reader["permission_name"], PermissionState.Deny); } return permissions; } } ; }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetHabboPermissionsFromId(int habboId, string permissionName, PermissionState permissionState, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@permission_name", permissionName); if (permissionState == PermissionState.Undefined) { using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return connection.GetCachedCommand("DELETE FROM `permission_habbo_permissions` WHERE `habbo_id` = @habbo_id AND `permission_name`= @permission_name").ExecuteNonQuery(parameters) > 0; } } parameters.Add("@permission_state", (int)permissionState); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return connection.GetCachedCommand("INSERT INTO `permission_habbo_permissions` SET `habbo_id` = @habbo_id, `permission_name` = @permission_name, `permission_state` = @permission_state ON DUPLICATE KEY UPDATE `permission_state` = @permission_state").ExecuteNonQuery(parameters) > 0; } }
/// <summary> /// Retrieves the figure details of the Habbo matching the specified Habbo ID. /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool GetFigureFromHabboId(int habboId, out string figureString, out bool gender, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `figure`, `gender` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteReader(parameters)) { if (!reader.HasRows) { figureString = ""; gender = true; return false; } while (reader.Read()) { figureString = reader["figure"] as string; gender = (bool)reader["gender"]; return true; } } } // Should never even be reached... but it is needed... figureString = ""; gender = true; return false; }
/// <summary> /// Updates the SSO ticket of the Habbo matching the specified Habbo ID. /// </summary> /// <param name=""></param> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetSSOTicketFromHabboId(int habboId, string ssoTicket, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@sso_ticket", ssoTicket); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { return connection.GetCachedCommand("UPDATE `habbos` SET `sso_ticket` = @sso_ticket WHERE `habbo_id` = @habbo_id").ExecuteNonQuery(parameters) > 0; } }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetMottoFromHabboId(int habboId, string motto, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@motto", motto); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { // Get the value from the database and return it. return connection.GetCachedCommand("UPDATE `habbos` SET `motto` = @motto WHERE `habbo_id` = @habbo_id").ExecuteNonQuery(parameters) > 0; } }
/// <summary> /// Updates the last access date of the Habbo matching the specified Habbo ID. /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetLastAccessDateFromHabboId(int habboId, DateTime lastAccessDate, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); parameters.Add("@last_access", lastAccessDate); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { // Get the value from the database and return it. return connection.GetCachedCommand("UPDATE `habbos` SET `last_access` = @last_access WHERE `habbo_id` = @habbo_id").ExecuteNonQuery(parameters) > 0; } }
/// <summary> /// Retrieves the SSO ticket of the Habbo matching the specified Habbo ID. /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static string GetSSOTicketFromHabboId(int habboId, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@habbo_id", habboId); string returnValue; using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { // Get the value from the database and return it. returnValue = connection.GetCachedCommand("SELECT `sso_ticket` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteScalar(parameters) as string; } if (returnValue != null) return returnValue; throw new NoResultsException(); }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns></returns> public static bool SetRoomNameFromRoomId(int roomId, string name, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@room_id", roomId); parameters.Add("@name", name); using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { // Get the value from the database and return it. return connection.GetCachedCommand("UPDATE `rooms` SET `name` = @name WHERE `room_id` = @room_id").ExecuteNonQuery(parameters) > 0; } }
/// <summary> /// Retrieves the ID of the Habbo matching the specified SSO Ticket. /// If no match is made, -1 is returned. /// </summary> /// <param name="ssoTicket">The SSO Ticket to match.</param> /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param> /// <returns>The ID of the Habbo, or -1 if no Habbo has the specified SSO Ticket.</returns> public static int GetHabboIdFromSSOTicket(string ssoTicket, WrappedMySqlConnection connection = null) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("@sso_ticket", ssoTicket); object returnValue; using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection()) { returnValue = connection.GetCachedCommand("SELECT `habbo_id` FROM `habbos` WHERE `sso_ticket` = @sso_ticket").ExecuteScalar(parameters); } if (returnValue != null) return (int)returnValue; throw new NoResultsException(); }