/// <summary>
        /// Correct the system estate ID and update any linked regions.
        /// </summary>
        /// <param name="estateConnector">Estate connector.</param>
        /// <param name="eS">E s.</param>
        /// <param name="newEstateID">New estate I.</param>
        static void UpdateSystemEstates(IEstateConnector estateConnector, EstateSettings eS, int newEstateID)
        {
            // this may be an ID correction or just an estate name change
            uint oldEstateID = eS.EstateID;

            // get existing linked regions
            var regions = estateConnector.GetRegions((int)oldEstateID);

            // recreate the correct estate?
            if (oldEstateID != newEstateID)
            {
                estateConnector.DeleteEstate((int)oldEstateID);
                newEstateID = estateConnector.CreateNewEstate(eS);
                MainConsole.Instance.Info("System estate '" + eS.EstateName + "' is present but the ID was corrected.");
            }

            // re-link regions
            foreach (UUID regID in regions)
            {
                estateConnector.LinkRegion(regID, newEstateID);
            }
            if (regions.Count > 0)
            {
                MainConsole.Instance.InfoFormat("Relinked {0} regions", regions.Count);
            }
        }
        /// <summary>
        /// Deletes an estate.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        protected void DeleteEstateCommand(IScene scene, string [] cmd)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            string estateName = "";

            // check for passed estate name
            estateName = (cmd.Length < 3)
                ? MainConsole.Instance.Prompt("Estate name", estateName)
                : Util.CombineParams(cmd, 2);
            if (estateName == "")
            {
                return;
            }

            // verify that the estate does exist

            EstateSettings ES = estateConnector.GetEstateSettings(estateName);

            if (ES == null)
            {
                MainConsole.Instance.ErrorFormat("[EstateService]: The estate '{0}' does not exist!", estateName);
                return;
            }

            // check for bogies...
            if (Utilities.IsSystemUser(ES.EstateOwner))
            {
                MainConsole.Instance.Info("[EstateService]: Tsk, tsk.  System estates should not be deleted!");
                return;
            }

            // check for linked regions
            var regions = estateConnector.GetRegions((int)ES.EstateID);

            if (regions.Count > 0)
            {
                MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' has {1} associated regions. These must be unlinked before deletion!",
                                                estateName, regions.Count);
                return;
            }

            var okDelete = MainConsole.Instance.Prompt("Delete estate '" + estateName + "'. Are you sure? (yes/no)", "no").ToLower() == "yes";

            if (okDelete)
            {
                estateConnector.DeleteEstate((int)ES.EstateID);
                MainConsole.Instance.Warn(estateName + " has been deleted");
            }
            else
            {
                MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' has not been deleted.", estateName);
            }
        }
        /// <summary>
        /// Correct the system estate ID and update any linked regions.
        /// </summary>
        /// <param name="estateConnector">Estate connector.</param>
        /// <param name="eS">E s.</param>
        /// <param name="newEstateID">New estate I.</param>
        static void UpdateSystemEstates (IEstateConnector estateConnector, EstateSettings eS, int newEstateID)
        {
            // this may be an ID correction or just an estate name change
            uint oldEstateID = eS.EstateID;

            // get existing linked regions
            var regions = estateConnector.GetRegions ((int)oldEstateID);

            // recreate the correct estate?
            if (oldEstateID != newEstateID) {
                estateConnector.DeleteEstate ((int)oldEstateID);
                newEstateID = estateConnector.CreateNewEstate (eS);
                MainConsole.Instance.Info ("System estate '" + eS.EstateName + "' is present but the ID was corrected.");
            }

            // re-link regions
            foreach (UUID regID in regions) {
                estateConnector.LinkRegion (regID, newEstateID);
            }
            if (regions.Count > 0)
                MainConsole.Instance.InfoFormat ("Relinked {0} regions", regions.Count);
        }