public static void DeleteClan(Clan deletedClan)
    {
        if (deletedClan != null)
        {
            foreach (var battleStation in GameManager.BattleStations.Values.Where(x => x.Clan.Id == deletedClan.Id))
            {
                battleStation.Destroy(null, DestructionType.MISC);
            }

            GameManager.Clans.TryRemove(deletedClan.Id, out deletedClan);

            foreach (var gameSession in GameManager.GameSessions.Values)
            {
                var member = gameSession?.Player;

                if (member != null && member.Clan.Id == deletedClan.Id)
                {
                    member.Clan = GameManager.GetClan(0);

                    var command = ClanChangedCommand.write(member.Clan.Tag, member.Clan.Id, member.Id);
                    member.SendCommand(command);
                    member.SendCommandToInRangePlayers(command);
                }
            }

            foreach (var clan in GameManager.Clans.Values)
            {
                clan.Diplomacies.Remove(deletedClan.Id);
            }
        }
    }
    public static void LeaveFromClan(Player player)
    {
        foreach (var battleStation in GameManager.BattleStations.Values)
        {
            if (battleStation.EquippedStationModule.ContainsKey(player.Clan.Id))
            {
                battleStation.EquippedStationModule[player.Clan.Id].ForEach(x => { if (x.OwnerId == player.Id)
                                                                                   {
                                                                                       x.Destroy(null, DestructionType.MISC);
                                                                                   }
                                                                            });
            }
        }

        if (player?.GameSession != null)
        {
            if (player.Clan.Id != 0)
            {
                player.Clan = GameManager.GetClan(0);

                var command = ClanChangedCommand.write(player.Clan.Tag, player.Clan.Id, player.Id);
                player.SendCommand(command);
                player.SendCommandToInRangePlayers(command);
            }
        }
    }
    public static void JoinToClan(Player player, Clan clan)
    {
        if (player?.GameSession != null && clan != null)
        {
            player.Clan = clan;

            var command = ClanChangedCommand.write(clan.Tag, clan.Id, player.Id);
            player.SendCommand(command);
            player.SendCommandToInRangePlayers(command);
        }
    }
    public static void CreateClan(Player player, int clanId, int factionId, string name, string tag)
    {
        if (!GameManager.Clans.ContainsKey(clanId))
        {
            var clan = new Clan(clanId, name, tag, factionId);
            GameManager.Clans.TryAdd(clan.Id, clan);

            if (player?.GameSession != null)
            {
                player.Clan = clan;

                var command = ClanChangedCommand.write(clan.Tag, clan.Id, player.Id);
                player.SendCommand(command);
                player.SendCommandToInRangePlayers(command);
            }
        }
    }
    public static void ChangeClanData(Clan clan, string name, string tag, int factionId)
    {
        if (clan.Id != 0)
        {
            clan.Tag  = tag;
            clan.Name = name;
            //clan.FactionId = factionId;

            foreach (GameSession gameSession in GameManager.GameSessions.Values.Where(x => x.Player.Clan.Id == clan.Id))
            {
                var player = gameSession.Player;
                if (player != null)
                {
                    GameManager.SendCommandToMap(player.Spacemap.Id, ClanChangedCommand.write(clan.Tag, clan.Id, player.Id));
                }
            }
        }
    }