Merge pull request #493 from CoderCow/patch-1
Fixed /region info, Improved /item
This commit is contained in:
commit
e5889765fc
2 changed files with 161 additions and 132 deletions
|
|
@ -2843,9 +2843,7 @@ namespace TShockAPI
|
|||
}
|
||||
case "info":
|
||||
{
|
||||
if (args.Parameters.Count > 1)
|
||||
{
|
||||
if (args.Parameters.Count > 4)
|
||||
if (args.Parameters.Count == 1 || args.Parameters.Count > 4)
|
||||
{
|
||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /region info <region> [-d] [page]");
|
||||
break;
|
||||
|
|
@ -2936,19 +2934,20 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
new Timer((dummy) => {
|
||||
Timer boundaryHideTimer = null;
|
||||
boundaryHideTimer = new Timer((state) => {
|
||||
foreach (Point boundaryPoint in Utils.Instance.EnumerateRegionBoundaries(regionArea))
|
||||
if ((boundaryPoint.X + boundaryPoint.Y & 1) == 0)
|
||||
args.Player.SendTileSquare(boundaryPoint.X, boundaryPoint.Y, 1);
|
||||
|
||||
// ReSharper disable AccessToModifiedClosure
|
||||
Debug.Assert(boundaryHideTimer != null);
|
||||
boundaryHideTimer.Dispose();
|
||||
// ReSharper restore AccessToModifiedClosure
|
||||
},
|
||||
null, 5000, Timeout.Infinite
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /region info <name>");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -3493,43 +3492,77 @@ namespace TShockAPI
|
|||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /item <item name/id> [item amount] [prefix id/name]");
|
||||
return;
|
||||
}
|
||||
if (args.Parameters[0].Length == 0)
|
||||
{
|
||||
args.Player.SendErrorMessage("Missing an item name/id.");
|
||||
return;
|
||||
}
|
||||
|
||||
int amountParamIndex = -1;
|
||||
int itemAmount = 0;
|
||||
int prefix = 0;
|
||||
if (args.Parameters.Count == 2)
|
||||
int.TryParse(args.Parameters[1], out itemAmount);
|
||||
else if (args.Parameters.Count == 3)
|
||||
for (int i = 1; i < args.Parameters.Count; i++)
|
||||
{
|
||||
int.TryParse(args.Parameters[1], out itemAmount);
|
||||
var found = TShock.Utils.GetPrefixByIdOrName(args.Parameters[2]);
|
||||
if (found.Count == 1)
|
||||
prefix = found[0];
|
||||
if (int.TryParse(args.Parameters[i], out itemAmount))
|
||||
{
|
||||
amountParamIndex = i;
|
||||
break;
|
||||
}
|
||||
var items = TShock.Utils.GetItemByIdOrName(args.Parameters[0]);
|
||||
if (items.Count == 0)
|
||||
}
|
||||
|
||||
string itemNameOrId;
|
||||
if (amountParamIndex == -1)
|
||||
itemNameOrId = string.Join(" ", args.Parameters);
|
||||
else
|
||||
itemNameOrId = string.Join(" ", args.Parameters.Take(amountParamIndex));
|
||||
|
||||
Item item;
|
||||
List<Item> matchedItems = TShock.Utils.GetItemByIdOrName(itemNameOrId);
|
||||
if (matchedItems.Count == 0)
|
||||
{
|
||||
args.Player.SendErrorMessage("Invalid item type!");
|
||||
return;
|
||||
}
|
||||
else if (items.Count > 1)
|
||||
else if (matchedItems.Count > 1)
|
||||
{
|
||||
args.Player.SendErrorMessage(string.Format("More than one ({0}) item matched!", items.Count));
|
||||
args.Player.SendErrorMessage("More than one item matched:");
|
||||
args.Player.SendErrorMessage(string.Join(", ", matchedItems.Select(i => i.name)));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
var item = items[0];
|
||||
if (item.type >= 1 && item.type < Main.maxItemTypes)
|
||||
item = matchedItems[0];
|
||||
}
|
||||
if (item.type < 1 && item.type >= Main.maxItemTypes)
|
||||
{
|
||||
args.Player.SendErrorMessage("The item type {0} is invalid.", itemNameOrId);
|
||||
return;
|
||||
}
|
||||
|
||||
int prefixId = 0;
|
||||
if (amountParamIndex != -1 && args.Parameters.Count > amountParamIndex + 1)
|
||||
{
|
||||
string prefixidOrName = args.Parameters[amountParamIndex + 1];
|
||||
List<int> matchedPrefixIds = TShock.Utils.GetPrefixByIdOrName(prefixidOrName);
|
||||
if (matchedPrefixIds.Count > 1)
|
||||
{
|
||||
args.Player.SendErrorMessage("More than one ({0}) prefixes matched \"{1}\".", matchedPrefixIds.Count, prefixidOrName);
|
||||
return;
|
||||
}
|
||||
else if (matchedPrefixIds.Count == 0)
|
||||
{
|
||||
args.Player.SendErrorMessage("No prefix matched \"{0}\".", prefixidOrName);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
prefixId = matchedPrefixIds[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (args.Player.InventorySlotAvailable || item.name.Contains("Coin"))
|
||||
{
|
||||
if (itemAmount == 0 || itemAmount > item.maxStack)
|
||||
itemAmount = item.maxStack;
|
||||
if (args.Player.GiveItemCheck(item.type, item.name, item.width, item.height, itemAmount, prefix))
|
||||
|
||||
if (args.Player.GiveItemCheck(item.type, item.name, item.width, item.height, itemAmount, prefixId))
|
||||
{
|
||||
args.Player.SendSuccessMessage(string.Format("Gave {0} {1}(s).", itemAmount, item.name));
|
||||
item.prefix = (byte)prefixId;
|
||||
args.Player.SendSuccessMessage("Gave {0} {1}(s).", itemAmount, item.AffixName());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3538,13 +3571,7 @@ namespace TShockAPI
|
|||
}
|
||||
else
|
||||
{
|
||||
args.Player.SendErrorMessage("You don't have free slots!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Player.SendErrorMessage("Invalid item type!");
|
||||
}
|
||||
args.Player.SendErrorMessage("Your inventory seems full.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1381,11 +1381,13 @@ namespace TShockAPI
|
|||
}
|
||||
else if (!TShock.CheckInventory(args.Player))
|
||||
{
|
||||
args.Player.LoginFailsBySsi = true;
|
||||
args.Player.SendMessage("Login Failed, Please fix the above errors then /login again.", Color.Cyan);
|
||||
args.Player.IgnoreActionsForClearingTrashCan = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
args.Player.LoginFailsBySsi = false;
|
||||
|
||||
if (group.HasPermission(Permissions.ignorestackhackdetection))
|
||||
args.Player.IgnoreActionsForCheating = "none";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue