From d3e0acacaa9f8de19a3f45cd0d950f546ce07cb4 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Fri, 16 Dec 2011 09:06:33 +0800 Subject: [PATCH] Remove name support for prefixes Searching by name causes a null exception --- TShockAPI/Commands.cs | 16 ++++++++-------- TShockAPI/TSPlayer.cs | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 66e01272..0d47bacf 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -2497,7 +2497,7 @@ namespace TShockAPI { if (args.Parameters.Count < 1) { - args.Player.SendMessage("Invalid syntax! Proper syntax: /item [item amount] [prefix name/id]", Color.Red); + args.Player.SendMessage("Invalid syntax! Proper syntax: /item [item amount] [prefix id]", 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); - var found = TShock.Utils.GetPrefixByIdOrName(args.Parameters[2]); - if (found.Count == 1) - prefix = found[0]; + int.TryParse(args.Parameters[2], out prefix); + if (prefix < 0 || prefix > 83) + prefix = 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 amount] [prefix id/name]", Color.Red); + args.Player.SendMessage("Invalid syntax! Proper syntax: /give [item amount] [prefix id]", 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); - var found = TShock.Utils.GetPrefixByIdOrName(args.Parameters[1]); - if (found.Count == 1) - prefix = found[0]; + int.TryParse(args.Parameters[1], out prefix); + if (prefix < 0 || prefix > 83) + prefix = 0; } if (items.Count == 0) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 4ea74b01..afef60b5 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -277,6 +277,7 @@ namespace TShockAPI Main.item[itemid].wet = Collision.WetCollision(Main.item[itemid].position, Main.item[itemid].width, Main.item[itemid].height); Main.item[itemid].stack = stack; Main.item[itemid].owner = Index; + Main.item[itemid].prefix = (byte) prefix; NetMessage.SendData((int)PacketTypes.ItemDrop, -1, -1, "", itemid, 0f, 0f, 0f); NetMessage.SendData((int)PacketTypes.ItemOwner, -1, -1, "", itemid, 0f, 0f, 0f); }