public bool IpBanned(IPAddress ipAddress, out PlayerBan ban) { uint ip = ipAddress.ToUint32(); ban = BannedPlayers.FirstOrDefault(_ban => _ban.BanType == IdentityType.Ip && _ban.Ip == ip); return(ban != null && !ban.Expired()); }
public bool UnbanSteamId(ulong steamId) { bool success = BannedPlayers.RemoveAll(ban => ban.BanType == IdentityType.SteamId && ban.SteamId == steamId) > 0; if (success) { Config.Save(); } return(success); }
public bool UnbanIp(IPAddress ip) { var uintIp = ip.ToUint32(); bool success = BannedPlayers.RemoveAll(ban => ban.BanType == IdentityType.Ip && ban.Ip == uintIp) > 0; if (success) { Config.Save(); } return(success); }
public PlayerBan BanSteamId(ulong steamId, string reason = null, DateTime?expirationDate = null, string referenceName = null) { Config.RemoveExpiredBans(); if (SteamIdBanned(steamId, out var existingBan)) { return(existingBan); } PlayerBan ban = new PlayerBan(steamId, reason, expirationDate, referenceName); BannedPlayers.Add(ban); Config.Save(); return(ban); }
private void RemovePlayerFromBan(object sender, RoutedEventArgs e) { var playerForRemove = BannedPlayers.FirstOrDefault( player => player.Name.ToLower() == PlayerNameTextBox.Text.ToLower() && player.Realm.ToLower() == SelectedPlayerServerName.ToLower()); if (playerForRemove == null) { MessageBox.Show("Игрок не найден"); return; } BannedPlayers.Remove(playerForRemove); }
private void OnWindowClosing(object sender, CancelEventArgs e) { if (BannedGuilds.Any()) { WriteObjects(BannedGuildsFileName, BannedGuilds.ToList()); } if (BannedPlayers.Any()) { WriteObjects(BannedPlayersFileName, BannedPlayers.ToList()); } if (GuildsForChecking.Any()) { WriteObjects(GuildsForCheckingFileName, GuildsForChecking.ToList()); } }
public PlayerBan BanIp(IPAddress ip, string reason = null, DateTime?expirationDate = null, string referenceName = null) { Config.RemoveExpiredBans(); uint uintIp = ip.ToUint32(); if (IpBanned(ip, out var existingBan)) { return(existingBan); } PlayerBan ban = new PlayerBan(uintIp, reason, expirationDate, referenceName); BannedPlayers.Add(ban); Config.Save(); return(ban); }
private void AddPlayerToBan(object sender, RoutedEventArgs e) { var player = BannedPlayers.FirstOrDefault( p => string.Equals(p.Name, PlayerNameTextBox.Text, StringComparison.OrdinalIgnoreCase)); if (player != null) { if (string.Equals(player.Guild.Name, SelectedPlayerServerName, StringComparison.OrdinalIgnoreCase)) { MessageBox.Show("Данный игрок уже добавлен"); return; } } var bannedPlayer = _explorer.GetCharacter(SelectedPlayerServerName, PlayerNameTextBox.Text, CharacterOptions.GetPetSlots); BannedPlayers.Add(bannedPlayer); }
private void UpdateBannedGuildsAndPeoples() { foreach (var bannedGuild in BannedGuilds.ToArray()) { var guild = _explorer.GetGuild(Region.EU, bannedGuild.Realm, bannedGuild.Name, GuildOptions.GetMembers); Parallel.ForEach(guild.Members, member => { member.FullCharactor = _explorer.GetCharacter(Region.EU, member.GuildCharacter.Realm, member.GuildCharacter.Name, CharacterOptions.GetPetSlots); }); BannedGuilds.Remove(bannedGuild); BannedGuilds.Add(guild); } foreach (var bannedPlayer in BannedPlayers.ToArray()) { var updated = _explorer.GetCharacter(bannedPlayer.Realm, bannedPlayer.Name, CharacterOptions.GetPetSlots); BannedPlayers.Remove(bannedPlayer); BannedPlayers.Add(updated); } }
public IEnumerable <PlayerBan> FindBansByName(string name) { return(BannedPlayers.Where(ban => ban.ReferenceName?.ToLower().StartsWith(name.ToLower()) == true)); }
public void RemoveBan(PlayerBan ban) { BannedPlayers.Remove(ban); Config.Save(); }
public bool SteamIdBanned(ulong steamId, out PlayerBan ban) { ban = BannedPlayers.FirstOrDefault(_ban => _ban.BanType == IdentityType.SteamId && _ban.SteamId == steamId); return(ban != null && !ban.Expired()); }