/// <summary> /// Gets the mute status from the chat of a <see cref="ReferenceHub"/> /// </summary> /// <param name="player"></param> /// <returns></returns> public static bool IsChatMuted(this ReferenceHub player) { return(LiteDatabase.GetCollection <Collections.Chat.Mute>().Exists(mute => mute.Target.Id == player.GetRawUserId() && mute.Expire > DateTime.Now)); }
public static Player GetDatabasePlayer(this ReferenceHub player) { if (player == null) { return(null); } else if (Database.PlayerData.TryGetValue(player, out Player databasePlayer)) { return(databasePlayer); } else { return(Database.LiteDatabase.GetCollection <Player>().FindOne(queryPlayer => queryPlayer.Id == player.GetRawUserId())); } }
/// <summary> /// Gets a <see cref="Collections.Chat.Player"/> from a <see cref="ReferenceHub"/> /// </summary> /// <param name="player"></param> /// <returns></returns> public static Collections.Chat.Player GetChatPlayer(this ReferenceHub player) { if (player == null || (string.IsNullOrEmpty(player.GetUserId()) && !player.IsHost())) { return(null); } else if (player.IsHost()) { return(ServerChatPlayer); } else if (ChatPlayers.TryGetValue(player, out Collections.Chat.Player chatPlayer)) { return(chatPlayer); } else { return(LiteDatabase.GetCollection <Collections.Chat.Player>().FindOne(queryPlayer => queryPlayer.Id == player.GetRawUserId())); } }