Merge pull request #3039 from ACaiCat/general-devel
fix: /help, /me, and /p commands can't work in non-English languages
This commit is contained in:
commit
92c3f0086d
3 changed files with 32 additions and 3 deletions
|
|
@ -20,7 +20,9 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
|
using Terraria.Initializers;
|
||||||
using Terraria.Localization;
|
using Terraria.Localization;
|
||||||
|
using Terraria.UI.Chat;
|
||||||
|
|
||||||
namespace TShockAPI.Localization
|
namespace TShockAPI.Localization
|
||||||
{
|
{
|
||||||
|
|
@ -37,6 +39,8 @@ namespace TShockAPI.Localization
|
||||||
|
|
||||||
private static readonly Dictionary<int, string> Buffs = new Dictionary<int, string>();
|
private static readonly Dictionary<int, string> Buffs = new Dictionary<int, string>();
|
||||||
|
|
||||||
|
private static readonly Dictionary<string,string> VanillaCommandsPrefixs = new Dictionary<string, string>();
|
||||||
|
|
||||||
internal static void Initialize()
|
internal static void Initialize()
|
||||||
{
|
{
|
||||||
var culture = Language.ActiveCulture;
|
var culture = Language.ActiveCulture;
|
||||||
|
|
@ -71,6 +75,15 @@ namespace TShockAPI.Localization
|
||||||
var i = (int)field.GetValue(null);
|
var i = (int)field.GetValue(null);
|
||||||
Prefixs.Add(i, Lang.prefix[i].Value);
|
Prefixs.Add(i, Lang.prefix[i].Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChatInitializer.Load();
|
||||||
|
foreach (var command in ChatManager.Commands._localizedCommands)
|
||||||
|
{
|
||||||
|
if (VanillaCommandsPrefixs.ContainsKey(command.Value._name))
|
||||||
|
continue;
|
||||||
|
VanillaCommandsPrefixs.Add(command.Value._name,command.Key.Value);
|
||||||
|
}
|
||||||
|
ChatManager.Commands._localizedCommands.Clear();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
@ -136,5 +149,18 @@ namespace TShockAPI.Localization
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get vanilla command prefix in English
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">vanilla command name</param>
|
||||||
|
/// <returns>vanilla command prefix in English</returns>
|
||||||
|
public static string GetCommandPrefixByName(string name)
|
||||||
|
{
|
||||||
|
string commandText;
|
||||||
|
if (VanillaCommandsPrefixs.TryGetValue(name, out commandText))
|
||||||
|
return commandText;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1505,11 +1505,11 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrEmpty(text))
|
if (!String.IsNullOrEmpty(text))
|
||||||
{
|
{
|
||||||
text = item.Key.Value + ' ' + text;
|
text = EnglishLanguage.GetCommandPrefixByName(item.Value._name) + ' ' + text;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
text = item.Key.Value;
|
text = EnglishLanguage.GetCommandPrefixByName(item.Value._name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ Use past tense when adding new entries; sign your name off when you add or chang
|
||||||
* In the constructor `stack` and `prefix` are now optional parameters.
|
* In the constructor `stack` and `prefix` are now optional parameters.
|
||||||
* Fixed unable to transfer long response body for REST API. (@sgkoishi, #2925)
|
* Fixed unable to transfer long response body for REST API. (@sgkoishi, #2925)
|
||||||
* Fixed the `/wind` command not being very helpful. (@punchready)
|
* Fixed the `/wind` command not being very helpful. (@punchready)
|
||||||
|
* Fixed /help, /me, and /p commands can't work in non-English languages. (@ACaiCat)
|
||||||
|
|
||||||
## TShock 5.2.1
|
## TShock 5.2.1
|
||||||
* Updated `TSPlayer.GodMode`. (@AgaSpace)
|
* Updated `TSPlayer.GodMode`. (@AgaSpace)
|
||||||
|
|
@ -102,7 +103,9 @@ Use past tense when adding new entries; sign your name off when you add or chang
|
||||||
* Added a property `TSPlayer.Hostile`, which gets pvp player mode. (@AgaSpace)
|
* Added a property `TSPlayer.Hostile`, which gets pvp player mode. (@AgaSpace)
|
||||||
* Fixed bug where when the `UseSqlLogs` config property is true, an empty log file would still get created. (@ZakFahey)
|
* Fixed bug where when the `UseSqlLogs` config property is true, an empty log file would still get created. (@ZakFahey)
|
||||||
* Fixed typo in `/gbuff`. (@sgkoishi, #2955)
|
* Fixed typo in `/gbuff`. (@sgkoishi, #2955)
|
||||||
|
* Rewrote the `.dockerignore` file into a denylist. (@timschumi)
|
||||||
|
* Added CI for Docker images. (@timschumi)
|
||||||
|
* Fixed Cursed Flares kicking players for invalid buff. (@Arthri)
|
||||||
|
|
||||||
## TShock 5.2
|
## TShock 5.2
|
||||||
* An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK)
|
* An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue