29 using System.Collections.Generic;
30 using System.Reflection;
32 using System.Text.RegularExpressions;
38 using OpenSim.Framework;
39 using OpenSim.Framework.Console;
40 using OpenSim.Framework.Monitoring;
41 using OpenSim.Region.Framework.Interfaces;
42 using OpenSim.Region.Framework.Scenes;
49 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"UserCommandsModule")]
54 public const string TeleportUserCommandSyntax =
"teleport user <first-name> <last-name> <destination>";
56 public static Regex InterRegionDestinationRegex
57 =
new Regex(
@"^(?<regionName>.+)/(?<x>\d+)/(?<y>\d+)/(?<z>\d+)$", RegexOptions.Compiled);
59 public static Regex WithinRegionDestinationRegex
60 =
new Regex(
@"^(?<x>\d+)/(?<y>\d+)/(?<z>\d+)$", RegexOptions.Compiled);
62 private Dictionary<UUID, Scene> m_scenes =
new Dictionary<UUID, Scene>();
64 public string Name {
get {
return "User Commands Module"; } }
66 public Type ReplaceableInterface {
get {
return null; } }
88 m_scenes[scene.RegionInfo.RegionID] = scene;
94 TeleportUserCommandSyntax,
95 "Teleport a user in this simulator to the given destination",
96 "<destination> is in format [<region-name>]/<x>/<y>/<z>, e.g. regionone/20/30/40 or just 20/30/40 to teleport within same region."
97 +
"\nIf the region contains a space then the whole destination must be in quotes, e.g. \"region one/20/30/40\"",
106 m_scenes.Remove(scene.RegionInfo.RegionID);
114 private ScenePresence GetUser(
string firstName,
string lastName)
120 foreach (
Scene scene
in m_scenes.Values)
122 ScenePresence user = scene.GetScenePresence(firstName, lastName);
134 private void HandleTeleportUser(
string module,
string[] cmd)
138 MainConsole.Instance.OutputFormat(
"Usage: " + TeleportUserCommandSyntax);
142 string firstName = cmd[2];
143 string lastName = cmd[3];
144 string rawDestination = cmd[4];
150 MainConsole.Instance.OutputFormat(
"No user found with name {0} {1}", firstName, lastName);
156 Match m = WithinRegionDestinationRegex.Match(rawDestination);
160 m = InterRegionDestinationRegex.Match(rawDestination);
164 MainConsole.Instance.OutputFormat(
"Invalid destination {0}", rawDestination);
170 = m.Groups[
"regionName"].Success ? m.Groups[
"regionName"].Value : user.Scene.RegionInfo.RegionName;
172 MainConsole.Instance.OutputFormat(
173 "Teleporting {0} to {1},{2},{3} in {4}",
175 m.Groups[
"x"], m.Groups[
"y"], m.Groups[
"z"],
178 user.Scene.RequestTeleportLocation(
179 user.ControllingClient,
182 float.Parse(m.Groups[
"x"].Value),
183 float.Parse(m.Groups[
"y"].Value),
184 float.Parse(m.Groups[
"z"].Value)),
OpenSim.Framework.Constants.TeleportFlags TeleportFlags
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
Interactive OpenSim region server
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
A module that holds commands for manipulating objects in the scene.
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...