fix: /help, /me, and /p commands can't work in non-English languages
This commit is contained in:
parent
0b6bf9ef40
commit
8df09cb4a8
2 changed files with 28 additions and 2 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> VanillaCommands = 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 (VanillaCommands.ContainsKey(command.Value._name))
|
||||||
|
continue;
|
||||||
|
VanillaCommands.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 text in English
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">vanilla command name</param>
|
||||||
|
/// <returns>vanilla command text English</returns>
|
||||||
|
public static string GetCommandTextByName(string name)
|
||||||
|
{
|
||||||
|
string commandText;
|
||||||
|
if (VanillaCommands.TryGetValue(name, out commandText))
|
||||||
|
return commandText;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1497,11 +1497,11 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrEmpty(text))
|
if (!String.IsNullOrEmpty(text))
|
||||||
{
|
{
|
||||||
text = item.Key.Value + ' ' + text;
|
text = EnglishLanguage.GetCommandTextByName(item.Value._name) + ' ' + text;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
text = item.Key.Value;
|
text = EnglishLanguage.GetCommandTextByName(item.Value._name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue