From 5df31a12a167b3910b452afb9292635686370c93 Mon Sep 17 00:00:00 2001 From: CoderCow Date: Mon, 1 Jul 2013 16:38:16 +0200 Subject: [PATCH] Added /region tp [region]. Additionally to "manageregion", also requires the "tp" permission. --- TShockAPI/Commands.cs | 62 +++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 3cabafa2..2e9a7b17 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -2986,6 +2986,31 @@ namespace TShockAPI } break; } + case "tp": + { + if (!args.Player.Group.HasPermission(Permissions.tp)) + { + args.Player.SendErrorMessage("You don't have the necessary permission to do that."); + break; + } + if (args.Parameters.Count <= 1) + { + args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /region tp [region]."); + break; + } + + string regionName = string.Join(" ", args.Parameters.Skip(1)); + Region region = TShock.Regions.GetRegionByName(regionName); + if (region == null) + { + args.Player.SendErrorMessage("Region \"{0}\" does not exist.", regionName); + break; + } + + args.Player.Teleport(region.Area.Center.X, region.Area.Center.Y + 3); + + break; + } case "help": default: { @@ -2996,24 +3021,27 @@ namespace TShockAPI if (!PaginationTools.TryParsePageNumber(args.Parameters, pageParamIndex, args.Player, out pageNumber)) return; + List lines = new List { + "set [1/2] - Sets the temporary region points.", + "clear - Clears the temporary region points.", + "define [name] - Defines the region with the given name.", + "delete [name] - Deletes the given region.", + "name - Shows the name of the region at the given point.", + "list - Lists all regions.", + "resize [region] [u/d/l/r] [amount] - Resizes a region.", + "allow [user] [region] - Allows a user to a region.", + "remove [user] [region] - Removes a user from a region.", + "allowg [group] [region] - Allows a user group to a region.", + "removeg [group] [region] - Removes a user group from a region.", + "info [region] - Displays several information about the given region.", + "protect [name] [true/false] - Sets whether the tiles inside the region are protected or not.", + "z [name] [#] - Sets the z-order of the region.", + }; + if (args.Player.Group.HasPermission(Permissions.tp)) + lines.Add("tp [region] - Teleports you to the given region's center."); + PaginationTools.SendPage( - args.Player, pageNumber, new[] - { - "set [1/2] - Sets the temporary region points.", - "clear - Clears the temporary region points.", - "define [name] - Defines the region.", - "delete [name] - Deletes the given region.", - "name - Shows the name of the region at the given point.", - "list - Lists all regions.", - "resize [region] [u/d/l/r] [amount] - Resizes a region.", - "allow [user] [region] - Allows a user to a region.", - "remove [user] [region] - Removes a user from a region.", - "allowg [group] [region] - Allows a user group to a region.", - "removeg [group] [region] - Removes a user group from a region.", - "info [region] - Displays several information about the given region.", - "protect [name] [true/false] - Sets whether the tiles inside the region are protected or not.", - "z [name] [#] - Sets the z-order of the region.", - }, + args.Player, pageNumber, lines, new PaginationTools.Settings { HeaderFormat = "Available Region Sub-Commands ({0}/{1}):",