Merge remote-tracking branch 'upstream/general-devel' into config/WorldTileProvider
This commit is contained in:
commit
b24fd4fe43
7 changed files with 144 additions and 80 deletions
|
|
@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria;
|
||||
|
|
@ -35,6 +35,8 @@ namespace TShockAPI.Localization
|
|||
|
||||
private static readonly Dictionary<int, string> Prefixs = new Dictionary<int, string>();
|
||||
|
||||
private static readonly Dictionary<int, string> Buffs = new Dictionary<int, string>();
|
||||
|
||||
internal static void Initialize()
|
||||
{
|
||||
var culture = Language.ActiveCulture;
|
||||
|
|
@ -58,10 +60,16 @@ namespace TShockAPI.Localization
|
|||
NpcNames.Add(i, Lang.GetNPCNameValue(i));
|
||||
}
|
||||
|
||||
for (var i = 0; i < Terraria.ID.BuffID.Count; i++)
|
||||
{
|
||||
Buffs.Add(i, Lang.GetBuffName(i));
|
||||
}
|
||||
|
||||
foreach (var field in typeof(Main).Assembly.GetType("Terraria.ID.PrefixID")
|
||||
.GetFields().Where(f => !f.Name.Equals("Count", StringComparison.Ordinal)))
|
||||
{
|
||||
Prefixs.Add((int) field.GetValue(null), field.Name);
|
||||
var i = (int)field.GetValue(null);
|
||||
Prefixs.Add(i, Lang.prefix[i].Value);
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
|
@ -114,5 +122,19 @@ namespace TShockAPI.Localization
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get buff name in English
|
||||
/// </summary>
|
||||
/// <param name="id">Buff Id</param>
|
||||
/// <returns>Buff name in English</returns>
|
||||
public static string GetBuffNameById(int id)
|
||||
{
|
||||
string buff;
|
||||
if (Buffs.TryGetValue(id, out buff))
|
||||
return buff;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ namespace TShockAPI
|
|||
/// <summary>VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info.</summary>
|
||||
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
/// <summary>VersionCodename - The version codename is displayed when the server starts. Inspired by software codenames conventions.</summary>
|
||||
public static readonly string VersionCodename = "ζ Ori";
|
||||
public static readonly string VersionCodename = "Thank you, everyone, for your support of TShock all these years! <3";
|
||||
|
||||
/// <summary>SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins).</summary>
|
||||
public static string SavePath = "tshock";
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
Also, be sure to release on github with the exact assembly version tag as below
|
||||
so that the update manager works correctly (via the Github releases api and mimic)
|
||||
-->
|
||||
<Version>5.1.2</Version>
|
||||
<Version>5.1.3</Version>
|
||||
<AssemblyTitle>TShock for Terraria</AssemblyTitle>
|
||||
<Company>Pryaxis & TShock Contributors</Company>
|
||||
<Product>TShockAPI</Product>
|
||||
|
|
|
|||
|
|
@ -280,37 +280,35 @@ namespace TShockAPI
|
|||
/// <returns>List of Items</returns>
|
||||
public List<Item> GetItemByName(string name)
|
||||
{
|
||||
var found = new List<Item>();
|
||||
Item item = new Item();
|
||||
string nameLower = name.ToLowerInvariant();
|
||||
var checkEnglish = Language.ActiveCulture != GameCulture.FromCultureName(GameCulture.CultureName.English);
|
||||
|
||||
for (int i = 1; i < Terraria.ID.ItemID.Count; i++)
|
||||
var startswith = new List<int>();
|
||||
var contains = new List<int>();
|
||||
for (int i = 1; i < ItemID.Count; i++)
|
||||
{
|
||||
item.netDefaults(i);
|
||||
if (!String.IsNullOrWhiteSpace(item.Name))
|
||||
var currentName = Lang.GetItemNameValue(i);
|
||||
if (!string.IsNullOrEmpty(currentName))
|
||||
{
|
||||
if (item.Name.ToLowerInvariant() == nameLower)
|
||||
return new List<Item> { item };
|
||||
if (item.Name.ToLowerInvariant().StartsWith(nameLower))
|
||||
found.Add(item.Clone());
|
||||
if (currentName.Equals(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
return new List<Item> { GetItemById(i) };
|
||||
if (currentName.StartsWith(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
startswith.Add(i);
|
||||
else if (currentName.Contains(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
contains.Add(i);
|
||||
}
|
||||
currentName = EnglishLanguage.GetItemNameById(i);
|
||||
if (!string.IsNullOrEmpty(currentName))
|
||||
{
|
||||
if (currentName.Equals(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
return new List<Item> { GetItemById(i) };
|
||||
if (currentName.StartsWith(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
startswith.Add(i);
|
||||
else if (currentName.Contains(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
contains.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (!checkEnglish)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string englishName = EnglishLanguage.GetItemNameById(i).ToLowerInvariant();
|
||||
if (!String.IsNullOrEmpty(englishName))
|
||||
{
|
||||
if (englishName == nameLower)
|
||||
return new List<Item> { item };
|
||||
if (englishName.StartsWith(nameLower))
|
||||
found.Add(item.Clone());
|
||||
}
|
||||
}
|
||||
return found;
|
||||
if (startswith.Count != 1)
|
||||
startswith.AddRange(contains);
|
||||
return startswith.Select(GetItemById).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -369,22 +367,35 @@ namespace TShockAPI
|
|||
/// <returns>List of matching NPCs</returns>
|
||||
public List<NPC> GetNPCByName(string name)
|
||||
{
|
||||
var found = new List<NPC>();
|
||||
NPC npc = new NPC();
|
||||
string nameLower = name.ToLowerInvariant();
|
||||
for (int i = -17; i < Terraria.ID.NPCID.Count; i++)
|
||||
var startswith = new List<int>();
|
||||
var contains = new List<int>();
|
||||
for (int i = -17; i < NPCID.Count; i++)
|
||||
{
|
||||
string englishName = EnglishLanguage.GetNpcNameById(i).ToLowerInvariant();
|
||||
|
||||
npc.SetDefaults(i);
|
||||
if (npc.FullName.ToLowerInvariant() == nameLower || npc.TypeName.ToLowerInvariant() == nameLower
|
||||
|| nameLower == englishName)
|
||||
return new List<NPC> { npc };
|
||||
if (npc.FullName.ToLowerInvariant().StartsWith(nameLower) || npc.TypeName.ToLowerInvariant().StartsWith(nameLower)
|
||||
|| englishName?.StartsWith(nameLower) == true)
|
||||
found.Add((NPC)npc.Clone());
|
||||
var currentName = Lang.GetNPCNameValue(i);
|
||||
if (!string.IsNullOrEmpty(currentName))
|
||||
{
|
||||
if (currentName.Equals(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
return new List<NPC> { GetNPCById(i) };
|
||||
if (currentName.StartsWith(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
startswith.Add(i);
|
||||
else if (currentName.Contains(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
contains.Add(i);
|
||||
}
|
||||
return found;
|
||||
currentName = EnglishLanguage.GetNpcNameById(i);
|
||||
if (!string.IsNullOrEmpty(currentName))
|
||||
{
|
||||
if (currentName.Equals(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
return new List<NPC> { GetNPCById(i) };
|
||||
if (currentName.StartsWith(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
startswith.Add(i);
|
||||
else if (currentName.Contains(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
contains.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (startswith.Count != 1)
|
||||
startswith.AddRange(contains);
|
||||
return startswith.Select(GetNPCById).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -414,22 +425,35 @@ namespace TShockAPI
|
|||
/// <returns>Matching list of buff ids</returns>
|
||||
public List<int> GetBuffByName(string name)
|
||||
{
|
||||
string nameLower = name.ToLower();
|
||||
string buffname;
|
||||
for (int i = 1; i < Terraria.ID.BuffID.Count; i++)
|
||||
var startswith = new List<int>();
|
||||
var contains = new List<int>();
|
||||
for (int i = 1; i < BuffID.Count; i++)
|
||||
{
|
||||
buffname = Lang.GetBuffName(i);
|
||||
if (!String.IsNullOrWhiteSpace(buffname) && buffname.ToLower() == nameLower)
|
||||
var currentName = Lang.GetBuffName(i);
|
||||
if (!string.IsNullOrWhiteSpace(currentName))
|
||||
{
|
||||
if (currentName.Equals(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
return new List<int> { i };
|
||||
if (currentName.StartsWith(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
startswith.Add(i);
|
||||
else if (currentName.Contains(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
contains.Add(i);
|
||||
}
|
||||
var found = new List<int>();
|
||||
for (int i = 1; i < Terraria.ID.BuffID.Count; i++)
|
||||
currentName = EnglishLanguage.GetBuffNameById(i);
|
||||
if (!string.IsNullOrWhiteSpace(currentName))
|
||||
{
|
||||
buffname = Lang.GetBuffName(i);
|
||||
if (!String.IsNullOrWhiteSpace(buffname) && buffname.ToLower().StartsWith(nameLower))
|
||||
found.Add(i);
|
||||
if (currentName.Equals(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
return new List<int> { i };
|
||||
if (currentName.StartsWith(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
startswith.Add(i);
|
||||
else if (currentName.Contains(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
contains.Add(i);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
if (startswith.Count != 1)
|
||||
startswith.AddRange(contains);
|
||||
return startswith;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -449,21 +473,35 @@ namespace TShockAPI
|
|||
/// <returns>List of prefix IDs</returns>
|
||||
public List<int> GetPrefixByName(string name)
|
||||
{
|
||||
Item item = new Item();
|
||||
item.SetDefaults(0);
|
||||
string lowerName = name.ToLowerInvariant();
|
||||
var found = new List<int>();
|
||||
var startswith = new List<int>();
|
||||
var contains = new List<int>();
|
||||
for (int i = FirstItemPrefix; i <= LastItemPrefix; i++)
|
||||
{
|
||||
item.prefix = (byte)i;
|
||||
string prefixName = item.AffixName().Trim().ToLowerInvariant();
|
||||
string englishName = EnglishLanguage.GetPrefixById(i).ToLowerInvariant();
|
||||
if (prefixName == lowerName || englishName == lowerName)
|
||||
return new List<int>() { i };
|
||||
else if (prefixName.StartsWith(lowerName) || englishName?.StartsWith(lowerName) == true) // Partial match
|
||||
found.Add(i);
|
||||
var currentName = Lang.prefix[i].ToString();
|
||||
if (!string.IsNullOrWhiteSpace(currentName))
|
||||
{
|
||||
if (currentName.Equals(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
return new List<int> { i };
|
||||
if (currentName.StartsWith(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
startswith.Add(i);
|
||||
else if (currentName.Contains(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
contains.Add(i);
|
||||
}
|
||||
return found;
|
||||
currentName = EnglishLanguage.GetPrefixById(i);
|
||||
if (!string.IsNullOrWhiteSpace(currentName))
|
||||
{
|
||||
if (currentName.Equals(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
return new List<int> { i };
|
||||
if (currentName.StartsWith(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
startswith.Add(i);
|
||||
else if (currentName.Contains(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
contains.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (startswith.Count != 1)
|
||||
startswith.AddRange(contains);
|
||||
return startswith;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
<PackageReference Include="GetText.NET" Version="1.7.14" /> <!-- only used to extract out to ./bin. -->
|
||||
|
||||
<!-- the launcher doesnt need the direct OTAPI reference, but since PackageReference[ExcludeFromSingleFile] doesnt work, exclude the assets and copy manually -->
|
||||
<PackageReference Include="OTAPI.Upcoming" Version="3.1.19" ExcludeAssets="all" GeneratePathProperty="true" />
|
||||
<PackageReference Include="OTAPI.Upcoming" Version="3.1.20" ExcludeAssets="all" GeneratePathProperty="true" />
|
||||
<None Include="$(PkgOTAPI_Upcoming)\lib\net6.0\OTAPI.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 5ed35f3791e07b87a6e15320cd9e50803c5d50dd
|
||||
Subproject commit e0e2df24dbc618683cc75595c59bf7f88acada08
|
||||
|
|
@ -80,6 +80,10 @@ Use past tense when adding new entries; sign your name off when you add or chang
|
|||
## Upcoming changes
|
||||
* Your changes could be here!
|
||||
* Added `WorldTileProvider` to the tshock config with values `default`, `constileation` or `heaptile`. This allows tile providers to be changed in environments where CLI args cannot be altered. See the documentation website for more info about these providers. (@SignatureBeef)
|
||||
* Updated the Utils.FindByIdOrName to follow same logic. Now fuzzy match fallback to `StartsWith` and then `Contains`. (@sgkoishi)
|
||||
|
||||
## TShock 5.1.3
|
||||
* Added support for Terraria 1.4.4.9 via OTAPI 3.1.20. (@SignatureBeef)
|
||||
|
||||
## TShock 5.1.2
|
||||
* Added support for Terraria 1.4.4.8.1 via OTAPI 3.1.19. (@SignatureBeef)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue