Exemplo n.º 1
0
        protected void ChangeEstate(string[] cmd)
        {
            IEstateConnector EstateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();

            if (EstateConnector != null)
            {
                if (MainConsole.Instance.ConsoleScene == null)
                {
                    MainConsole.Instance.Warn("Select a region before using this command.");
                    return;
                }
                IScene scene            = MainConsole.Instance.ConsoleScene;
                string removeFromEstate =
                    MainConsole.Instance.Prompt(
                        "Are you sure you want to leave the estate for region " + scene.RegionInfo.RegionName + "?",
                        "yes");
                if (removeFromEstate == "yes")
                {
                    if (!EstateConnector.DelinkRegion(scene.RegionInfo.RegionID))
                    {
                        MainConsole.Instance.Warn("Unable to remove this region from the estate.");
                        return;
                    }
                    scene.RegionInfo.EstateSettings = CreateEstateInfo(scene);
                }
                else
                {
                    MainConsole.Instance.Warn("No action has been taken.");
                }
            }
        }
        public bool CreateNewEstate(UUID regionID, string estateName, string ownerName)
        {
            object remoteValue = InternalDoRemote(regionID, estateName, ownerName);

            if (remoteValue != null || m_doRemoteOnly)
            {
                return(remoteValue == null ? false : (bool)remoteValue);
            }

            IEstateConnector conn = Aurora.DataManager.DataManager.RequestPlugin <IEstateConnector>();

            if (conn != null)
            {
                var account = m_registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, ownerName);
                if (account != null)
                {
                    UUID userID = account.PrincipalID;
                    conn.DelinkRegion(regionID);

                    return(conn.CreateNewEstate(new EstateSettings()
                    {
                        EstateName = estateName, EstateOwner = userID
                    }, regionID) != 0);
                }
            }
            return(false);
        }
        public void ChangeEstate(string ownerName, string estateToJoin, UUID regionID)
        {
            InternalDoRemote(ownerName, estateToJoin, regionID);
            if (m_doRemoteOnly)
            {
                return;
            }

            IEstateConnector conn = Aurora.DataManager.DataManager.RequestPlugin <IEstateConnector>();

            if (conn != null)
            {
                conn.DelinkRegion(regionID);
                UserAccount account = m_registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, ownerName);
                conn.LinkRegion(regionID, conn.GetEstate(account.PrincipalID, estateToJoin));
            }
        }
        /// <summary>
        /// Changes the region estate.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        protected void ChangeEstate(IScene scene, string[] cmd)
        {
            IEstateConnector EstateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();

            if (EstateConnector != null)
            {
                // a bit of info re 'Mainland'
                string regType = scene.RegionInfo.RegionType.ToLower();
                if (regType.StartsWith("m") && (scene.RegionInfo.EstateSettings.EstateID == Constants.SystemEstateID))
                {
                    MainConsole.Instance.Info("[Estate]: This region is already part of the Mainland system estate");
                    return;
                }

                string removeFromEstate =
                    MainConsole.Instance.Prompt(
                        "Are you sure you want to change the estate for region '" + scene.RegionInfo.RegionName + "'? (yes/no)",
                        "yes");

                if (removeFromEstate == "yes")
                {
                    if (regType.StartsWith("m"))
                    {
                        MainConsole.Instance.Info("[Estate]: Mainland type regions can only be part of the Mainland system estate");
                    }

                    if (!EstateConnector.DelinkRegion(scene.RegionInfo.RegionID))
                    {
                        MainConsole.Instance.Warn("[Estate]: Unable to remove this region from the estate.");
                        return;
                    }
                    scene.RegionInfo.EstateSettings = CreateEstateInfo(scene);
                }
                else
                {
                    MainConsole.Instance.Warn("[Estate]: No action has been taken.");
                }
            }
        }
Exemplo n.º 5
0
        protected void ChangeEstate(string module, string[] cmd)
        {
            IEstateConnector EstateConnector = DataManager.RequestPlugin <IEstateConnector>();

            if (EstateConnector != null)
            {
                if (MainConsole.Instance.ConsoleScene == null)
                {
                    m_log.Warn("Select a region before using this command.");
                    return;
                }
                Scene  scene            = (Scene)MainConsole.Instance.ConsoleScene;
                string removeFromEstate = MainConsole.Instance.CmdPrompt("Are you sure you want to leave the estate for region " + scene.RegionInfo.RegionName + "?", "yes");
                if (removeFromEstate == "yes")
                {
                    if (!EstateConnector.DelinkRegion(scene.RegionInfo.RegionID, scene.RegionInfo.EstateSettings.EstatePass))
                    {
                        m_log.Warn("Unable to remove this region from the estate.");
                        return;
                    }
                    scene.RegionInfo.EstateSettings = CreateEstateInfo(scene);
                    IGenericsConnector g = DataManager.RequestPlugin <IGenericsConnector>();
                    EstatePassword     s = null;
                    if (g != null)
                    {
                        s = g.GetGeneric <EstatePassword>(scene.RegionInfo.RegionID, "EstatePassword", scene.RegionInfo.EstateSettings.EstateID.ToString(), new EstatePassword());
                    }
                    if (s != null)
                    {
                        scene.RegionInfo.EstateSettings.EstatePass = s.Password;
                    }
                }
                else
                {
                    m_log.Warn("No action has been taken.");
                }
            }
        }
        /// <summary>
        /// Un-link a region from an estate region.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void EstateUnLinkRegionCommand(IScene scene, string [] cmd)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
            IGridService     gridService     = m_registry.RequestModuleInterface <IGridService> ();

            string estateName = "";
            string regionName = "";

            // check for passed estate name
            estateName = (cmd.Length < 4)
                ? MainConsole.Instance.Prompt("Estate name", estateName)
                : cmd [3];
            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 passed  region to link to
            if (scene != null)
            {
                regionName = scene.RegionInfo.RegionName;
            }

            regionName = (cmd.Length < 4)
                ? MainConsole.Instance.Prompt("Region to remove", regionName)
                : cmd [4];
            if (regionName == "")
            {
                return;
            }

            // verify that the region does exist
            var region = gridService.GetRegionByName(null, regionName);

            if (region == null)
            {
                MainConsole.Instance.ErrorFormat("[EstateService]: The requested region '{0}' does not exist!", regionName);
                return;
            }
            regionName = region.RegionName;

            // verify that the region is actually part of the estate
            if (!estateConnector.EstateRegionExists((int)ES.EstateID, region.RegionID))
            {
                MainConsole.Instance.ErrorFormat("[EstateService]: The requested region '{0}' is not part of the '{1}' estate!",
                                                 regionName, ES.EstateName);
                return;
            }

            // have all details.. do it...
            if (!estateConnector.DelinkRegion(region.RegionID))
            {
                MainConsole.Instance.Warn("Unlinking the region failed. Please try again.");
                return;
            }

            // unlink was successful..
            MainConsole.Instance.InfoFormat("Region '{0}' has been removed from estate '{1}'",
                                            regionName, estateName);

            //We really need to attach it to another estate though...
            ISystemEstateService sysEstateInfo = m_registry.RequestModuleInterface <ISystemEstateService> ();

            ES = estateConnector.GetEstateSettings(sysEstateInfo.SystemEstateName);
            if (ES != null)
            {
                if (estateConnector.LinkRegion(region.RegionID, (int)ES.EstateID))
                {
                    MainConsole.Instance.WarnFormat("'{0}' has been placed in the '{1}' estate until re-assigned",
                                                    regionName, sysEstateInfo.SystemEstateName);
                    UpdateConsoleRegionEstate(regionName, ES);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Changes the region estate.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd parameters.</param>
        protected void ChangeRegionEstate(IScene scene, string [] cmd)
        {
            var    conScenes = MainConsole.Instance.ConsoleScenes;
            IScene regScene  = scene;

            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            if (estateConnector == null)
            {
                MainConsole.Instance.Error("[Estate]: Unable to obtain estate connector for update");
                return;
            }

            string regionName;

            if (regScene == null)
            {
                regionName = cmd.Length > 2 ? cmd [2] : MainConsole.Instance.Prompt("The region you wish to change?");
                if (string.IsNullOrEmpty(regionName))
                {
                    return;
                }

                // find the required region/scene
                regionName = regionName.ToLower();
                foreach (IScene scn in conScenes)
                {
                    if (scn.RegionInfo.RegionName.ToLower() == regionName)
                    {
                        regScene = scn;
                        break;
                    }
                }

                if (regScene == null)
                {
                    MainConsole.Instance.Error("[Estate]: The region '" + regionName + "' could not be found.");
                    return;
                }
            }
            else
            {
                regionName = regScene.RegionInfo.RegionName;
            }

            // check for mainland regions
            if (regScene.RegionInfo.RegionType.ToLower().StartsWith("m", System.StringComparison.Ordinal))
            {
                var sysEstates     = regScene.RequestModuleInterface <ISystemEstateService> ();
                var mainlandEstate = sysEstates.MainlandEstateName;
                MainConsole.Instance.InfoFormat("[Estate]: {0} is a Mainland region and is automatically part of the '{1}' estate",
                                                regionName, mainlandEstate);
                return;
            }

            var regionID   = regScene.RegionInfo.RegionID;
            var oldOwnerID = regScene.RegionInfo.EstateSettings.EstateOwner;

            // get the new estate name
            string estateName = cmd.Length > 3
                ? cmd [3]
                : MainConsole.Instance.Prompt("The new estate for " + regionName + " (? for more options)");

            if (string.IsNullOrEmpty(estateName))
            {
                return;
            }

            int newEstateId = 0;

            if (estateName != "?")
            {
                newEstateId = estateConnector.GetEstateID(estateName);
            }

            if (newEstateId == 0)
            {
                if (estateName != "?")
                {
                    MainConsole.Instance.Warn("[Estate]: The estate '" + estateName + "' matches no known estate.");
                }

                // try the long way...
                newEstateId = GetUserEstateID(regScene, estateConnector);
                if (newEstateId == 0)
                {
                    return;
                }
                var estate = estateConnector.GetEstateIDSettings(newEstateId);
                if (estate != null)
                {
                    estateName = estate.EstateName;
                }
            }

            // we have a region & estate name
            bool deLinkEstate = true;

            if (cmd.Length == 3)
            {
                var resp = MainConsole.Instance.Prompt(
                    "Are you sure you want to change '" + regionName + "' to the '" + estateName + "' estate? (yes/no)", "yes");
                deLinkEstate = (resp.StartsWith("y", System.StringComparison.Ordinal));
            }
            if (!deLinkEstate)
            {
                return;
            }

            // good to go
            if (!estateConnector.DelinkRegion(regionID))
            {
                MainConsole.Instance.Warn("[Estate]: Aborting - Unable to remove this region from the current estate.");
                return;
            }

            // check for'Mainland'
            string regType = regScene.RegionInfo.RegionType.ToLower();

            if (regType.StartsWith("m", System.StringComparison.Ordinal))
            {
                if (newEstateId == Constants.MainlandEstateID)
                {
                    MainConsole.Instance.Info("[Estate]: This region is already part of the Mainland estate");
                    return;
                }

                // link this region to the mainland
                MainConsole.Instance.Info("[Estate]: Mainland type regions must be part of the Mainland estate");
                LinkSystemEstate(regionID, Constants.MainlandEstateID);
                return;
            }

            var newEstate = LinkRegionEstate(regionID, newEstateId);

            if (newEstate != null)
            {
                regScene.RegionInfo.EstateSettings = newEstate;

                // Linking was successful, change any previously owned parcels to the new owner
                if (oldOwnerID != UUID.Zero)
                {
                    IParcelManagementModule parcelManagement = regScene.RequestModuleInterface <IParcelManagementModule> ();
                    if (parcelManagement != null)
                    {
                        parcelManagement.ReclaimParcels(oldOwnerID, newEstate.EstateOwner);
                    }
                }
            }
        }