Merge pull request #1429 from mistzzt/t-1.3.5
Fix duplicate items shown in Utils.GetItemByName and a client crash
This commit is contained in:
commit
a674b42ff3
1 changed files with 15 additions and 5 deletions
|
|
@ -17,21 +17,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
using Terraria.ID;
|
using Terraria.ID;
|
||||||
using Terraria.Utilities;
|
using Terraria.Utilities;
|
||||||
using TShockAPI.DB;
|
using TShockAPI.DB;
|
||||||
using BCrypt.Net;
|
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using Terraria.Localization;
|
||||||
using TShockAPI.Localization;
|
using TShockAPI.Localization;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
|
|
@ -346,6 +344,8 @@ namespace TShockAPI
|
||||||
var found = new List<Item>();
|
var found = new List<Item>();
|
||||||
Item item = new Item();
|
Item item = new Item();
|
||||||
string nameLower = name.ToLowerInvariant();
|
string nameLower = name.ToLowerInvariant();
|
||||||
|
var checkEnglish = Language.ActiveCulture != GameCulture.English;
|
||||||
|
|
||||||
for (int i = -48; i < Main.maxItemTypes; i++)
|
for (int i = -48; i < Main.maxItemTypes; i++)
|
||||||
{
|
{
|
||||||
item.netDefaults(i);
|
item.netDefaults(i);
|
||||||
|
|
@ -357,6 +357,11 @@ namespace TShockAPI
|
||||||
found.Add(item.Clone());
|
found.Add(item.Clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!checkEnglish)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
string englishName = EnglishLanguage.GetItemNameById(i).ToLowerInvariant();
|
string englishName = EnglishLanguage.GetItemNameById(i).ToLowerInvariant();
|
||||||
if (!String.IsNullOrEmpty(englishName))
|
if (!String.IsNullOrEmpty(englishName))
|
||||||
{
|
{
|
||||||
|
|
@ -864,8 +869,13 @@ namespace TShockAPI
|
||||||
/// <param name="matches">An enumerable list with the matches</param>
|
/// <param name="matches">An enumerable list with the matches</param>
|
||||||
public void SendMultipleMatchError(TSPlayer ply, IEnumerable<object> matches)
|
public void SendMultipleMatchError(TSPlayer ply, IEnumerable<object> matches)
|
||||||
{
|
{
|
||||||
ply.SendErrorMessage("More than one match found: {0}", string.Join(",", matches));
|
ply.SendErrorMessage("More than one match found: ");
|
||||||
ply.SendErrorMessage("Use \"my query\" for items with spaces");
|
|
||||||
|
var lines = PaginationTools.BuildLinesFromTerms(matches.ToArray());
|
||||||
|
|
||||||
|
lines.ForEach(ply.SendInfoMessage);
|
||||||
|
|
||||||
|
ply.SendErrorMessage("Use \"my query\" for items with spaces.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue