/// <summary> /// Check if exists a specified punish. /// </summary> /// <param name="player">The <see cref="Collections.Player"/> player.</param> /// <param name="type"> the <see cref="Enums.PunishType"/>.</param> /// <param name="id"> the punish id.</param> /// <param name="server"> the server port.</param> /// <returns> true if the punish exists, false if not.</returns> public static bool CheckId(Collections.Player player, PunishType?type, int id, int server) { switch (type) { case PunishType.Ban: return(BanCollection.Exists(ban => ban.Target == player && ban.BanId == id && ban.Server == server)); case PunishType.Kick: return(KickCollection.Exists(kick => kick.Target == player && kick.KickId == id && kick.Server == server)); case PunishType.Mute: return(MuteCollection.Exists(mute => mute.Target == player && mute.MuteId == id && mute.Server == server)); case PunishType.Warn: return(WarnCollection.Exists(warn => warn.Target == player && warn.WarnId == id && warn.Server == server)); case PunishType.SoftWarn: return(SoftWarnCollection.Exists(sw => sw.Target == player && sw.SoftWarnId == id && sw.Server == server)); case PunishType.SoftBan: return(SoftBanCollection.Exists(sb => sb.Target == player && sb.SoftBanId == id && sb.Server == server)); case PunishType.WatchList: return(WatchListCollection.Exists(wl => wl.Target == player && wl.WatchListId == id && wl.Server == server)); default: return(false); } }
/// <summary> /// Gets a value indicating wherever or not the specified <see cref="Collections.Player"/> is banned. /// </summary> /// <param name="dPlayer"> the specified <see cref="Collections.Player"/>.</param> /// <returns> true if is banned, false if not.</returns> public static bool IsBanned(this Collections.Player dPlayer) => BanCollection.Exists(ban => ban.Target.Id == dPlayer.Id && ban.Expire > DateTime.Now);