diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs
index 2e9a7b17..89ae93fe 100644
--- a/TShockAPI/Commands.cs
+++ b/TShockAPI/Commands.cs
@@ -2577,6 +2577,7 @@ namespace TShockAPI
{
args.Player.SendMessage("Hit a block to get the name of the region", Color.Yellow);
args.Player.AwaitingName = true;
+ args.Player.AwaitingNameParameters = args.Parameters.Skip(1).ToArray();
}
break;
}
@@ -3026,7 +3027,7 @@ namespace TShockAPI
"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.",
+ "name [-u][-z][-p] - 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.",
diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs
index 9b37250d..1cf7d702 100644
--- a/TShockAPI/GetDataHandlers.cs
+++ b/TShockAPI/GetDataHandlers.cs
@@ -17,11 +17,13 @@ along with this program. If not, see .
*/
using System;
using System.Collections.Generic;
-using System.ComponentModel;
+using System.ComponentModel;
+using System.Diagnostics;
using System.IO;
using System.IO.Streams;
using System.Linq;
-using System.Text;
+using System.Text;
+using TShockAPI.DB;
using Terraria;
using TShockAPI.Net;
@@ -1685,18 +1687,63 @@ namespace TShockAPI
if (args.Player.AwaitingName)
{
- var protectedregions = TShock.Regions.InAreaRegionName(tileX, tileY);
- if (protectedregions.Count == 0)
+ Debug.Assert(args.Player.AwaitingNameParameters != null);
+
+ bool includeUnprotected = false;
+ bool includeZIndexes = false;
+ bool persistentMode = false;
+ foreach (string parameter in args.Player.AwaitingNameParameters)
+ {
+ if (parameter.Equals("-u", StringComparison.InvariantCultureIgnoreCase))
+ includeUnprotected = true;
+ if (parameter.Equals("-z", StringComparison.InvariantCultureIgnoreCase))
+ includeZIndexes = true;
+ if (parameter.Equals("-p", StringComparison.InvariantCultureIgnoreCase))
+ persistentMode = true;
+ }
+
+ List outputRegions = new List();
+ foreach (Region region in TShock.Regions.Regions.OrderBy(r => r.Z).Reverse())
+ {
+ if (!includeUnprotected && !region.DisableBuild)
+ continue;
+ if (tileX < region.Area.Left || tileX > region.Area.Right)
+ continue;
+ if (tileY < region.Area.Top || tileY > region.Area.Bottom)
+ continue;
+
+ string format = "{1}";
+ if (includeZIndexes)
+ format = "{1} (z:{0})";
+
+ outputRegions.Add(string.Format(format, region.Z, region.Name));
+ }
+
+ if (outputRegions.Count == 0)
{
- args.Player.SendMessage("Region is not protected", Color.Yellow);
+ if (includeUnprotected)
+ args.Player.SendMessage("There are no regions at this point.", Color.Yellow);
+ else
+ args.Player.SendMessage("There are no regions at this point or they are not protected.", Color.Yellow);
}
else
{
- string regionlist = string.Join(",", protectedregions.ToArray());
- args.Player.SendMessage("Region Name(s): " + regionlist, Color.Yellow);
+ if (includeUnprotected)
+ args.Player.SendSuccessMessage("Regions at this point:");
+ else
+ args.Player.SendSuccessMessage("Protected regions at this point:");
+
+ foreach (string line in PaginationTools.BuildLinesFromTerms(outputRegions))
+ args.Player.SendMessage(line, Color.White);
}
+
+ if (!persistentMode)
+ {
+ args.Player.AwaitingName = false;
+ args.Player.AwaitingNameParameters = null;
+ }
+
args.Player.SendTileSquare(tileX, tileY);
- args.Player.AwaitingName = false;
return true;
}
diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs
index d9182329..986d3147 100644
--- a/TShockAPI/TSPlayer.cs
+++ b/TShockAPI/TSPlayer.cs
@@ -121,6 +121,8 @@ namespace TShockAPI
public bool AwaitingName { get; set; }
+ public string[] AwaitingNameParameters { get; set; }
+
///
/// The last time a player broke a grief check.
///