Re-add prefix name support to /item and /give
This commit is contained in:
parent
905538de30
commit
08295343d7
2 changed files with 12 additions and 13 deletions
|
|
@ -2497,7 +2497,7 @@ namespace TShockAPI
|
|||
{
|
||||
if (args.Parameters.Count < 1)
|
||||
{
|
||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /item <item name/id> [item amount] [prefix id]", Color.Red);
|
||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /item <item name/id> [item amount] [prefix id/name]", Color.Red);
|
||||
return;
|
||||
}
|
||||
if (args.Parameters[0].Length == 0)
|
||||
|
|
@ -2512,9 +2512,9 @@ namespace TShockAPI
|
|||
else if (args.Parameters.Count == 3)
|
||||
{
|
||||
int.TryParse(args.Parameters[1], out itemAmount);
|
||||
int.TryParse(args.Parameters[2], out prefix);
|
||||
if (prefix < 0 || prefix > 83)
|
||||
prefix = 0;
|
||||
var found = TShock.Utils.GetPrefixByIdOrName(args.Parameters[2]);
|
||||
if (found.Count == 1)
|
||||
prefix = found[0];
|
||||
}
|
||||
var items = TShock.Utils.GetItemByIdOrName(args.Parameters[0]);
|
||||
if (items.Count == 0)
|
||||
|
|
@ -2553,7 +2553,7 @@ namespace TShockAPI
|
|||
{
|
||||
if (args.Parameters.Count < 2)
|
||||
{
|
||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /give <item type/id> <player> [item amount] [prefix id]", Color.Red);
|
||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /give <item type/id> <player> [item amount] [prefix id/name]", Color.Red);
|
||||
return;
|
||||
}
|
||||
if (args.Parameters[0].Length == 0)
|
||||
|
|
@ -2577,9 +2577,9 @@ namespace TShockAPI
|
|||
else if (args.Parameters.Count == 2)
|
||||
{
|
||||
int.TryParse(args.Parameters[0], out itemAmount);
|
||||
int.TryParse(args.Parameters[1], out prefix);
|
||||
if (prefix < 0 || prefix > 83)
|
||||
prefix = 0;
|
||||
var found = TShock.Utils.GetPrefixByIdOrName(args.Parameters[1]);
|
||||
if (found.Count == 1)
|
||||
prefix = found[0];
|
||||
}
|
||||
|
||||
if (items.Count == 0)
|
||||
|
|
|
|||
|
|
@ -343,11 +343,11 @@ namespace TShockAPI
|
|||
public List<int> GetPrefixByName(string name)
|
||||
{
|
||||
Item item = new Item();
|
||||
item.SetDefaults(0);
|
||||
for (int i = 1; i < 83; i++)
|
||||
{
|
||||
item.prefix = (byte) i;
|
||||
item.AffixName();
|
||||
if (item.name.Trim() == name)
|
||||
if (item.AffixName().Trim() == name)
|
||||
return new List<int> { i };
|
||||
}
|
||||
var found = new List<int>();
|
||||
|
|
@ -356,10 +356,9 @@ namespace TShockAPI
|
|||
try
|
||||
{
|
||||
item.prefix = (byte) i;
|
||||
item.AffixName();
|
||||
if (item.name.Trim().ToLower() == name.ToLower())
|
||||
if (item.AffixName().Trim().ToLower() == name.ToLower())
|
||||
return new List<int> { i };
|
||||
if (item.name.Trim().ToLower().StartsWith(name.ToLower()))
|
||||
if (item.AffixName().Trim().ToLower().StartsWith(name.ToLower()))
|
||||
found.Add(i);
|
||||
}
|
||||
catch { }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue