Better workaround for Terraria chat commands, courtesy of @DeathCradle
This commit is contained in:
parent
aabc985f1c
commit
1f3a09d738
1 changed files with 17 additions and 5 deletions
|
|
@ -1443,13 +1443,25 @@ namespace TShockAPI
|
||||||
|
|
||||||
string text = args.Text;
|
string text = args.Text;
|
||||||
|
|
||||||
//This is a hacky way of bypassing Terraria's new chat command processing.
|
// Terraria now has chat commands on the client side.
|
||||||
//_name is usually a private variable but the wonders of OTAPI make it available to us
|
// These commands remove the commands prefix (e.g. /me /playing) and send the command id instead
|
||||||
if (args.CommandId._name == "Emote")
|
// In order for us to keep legacy code we must reverse this and get the prefix using the command id
|
||||||
|
foreach (var item in Terraria.UI.Chat.ChatManager.Commands._localizedCommands)
|
||||||
{
|
{
|
||||||
text = "/me " + text;
|
if (item.Value._name == args.CommandId._name)
|
||||||
|
{
|
||||||
|
if (!String.IsNullOrEmpty(text))
|
||||||
|
{
|
||||||
|
text = item.Key.Value + ' ' + text;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text = item.Key.Value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((text.StartsWith(Config.CommandSpecifier) || text.StartsWith(Config.CommandSilentSpecifier))
|
if ((text.StartsWith(Config.CommandSpecifier) || text.StartsWith(Config.CommandSilentSpecifier))
|
||||||
&& !string.IsNullOrWhiteSpace(text.Substring(1)))
|
&& !string.IsNullOrWhiteSpace(text.Substring(1)))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue