-Added "-p" parameter to "/region name" for persistent mode, type "/region name" without "-p" to disable.
-Added "-u" parameter to "/region name". Use to include unprotected regions in the listing. -Added "-z" parameter to "/region name". Use to include z indexes in the listing. -Regions displayed by "/region name" are now sorted by z index.
This commit is contained in:
parent
6fa744e2b5
commit
8c23d68727
3 changed files with 59 additions and 9 deletions
|
|
@ -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.",
|
||||
|
|
|
|||
|
|
@ -17,11 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
||||
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<string> outputRegions = new List<string>();
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ namespace TShockAPI
|
|||
|
||||
public bool AwaitingName { get; set; }
|
||||
|
||||
public string[] AwaitingNameParameters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The last time a player broke a grief check.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue