Added support for multiple chat commands being executed off one /command. This is due to a request that we allow people to register the same command as someone else. Also, this will fix any issues where two plugins register the same command and one breaks. Ofc, any better suggestions are extremely welcome.
This commit is contained in:
parent
c37cc91ca0
commit
b9099757fb
1 changed files with 21 additions and 19 deletions
|
|
@ -223,9 +223,9 @@ namespace TShockAPI
|
||||||
string cmdName = args[0].ToLower();
|
string cmdName = args[0].ToLower();
|
||||||
args.RemoveAt(0);
|
args.RemoveAt(0);
|
||||||
|
|
||||||
Command cmd = ChatCommands.FirstOrDefault(c => c.HasAlias(cmdName));
|
IEnumerable<Command> cmds = ChatCommands.Where(c => c.HasAlias(cmdName));
|
||||||
|
|
||||||
if (cmd == null)
|
if (cmds.Count() == 0)
|
||||||
{
|
{
|
||||||
if (player.AwaitingResponse.ContainsKey(cmdName))
|
if (player.AwaitingResponse.ContainsKey(cmdName))
|
||||||
{
|
{
|
||||||
|
|
@ -237,7 +237,8 @@ namespace TShockAPI
|
||||||
player.SendErrorMessage("Invalid command entered. Type /help for a list of valid commands.");
|
player.SendErrorMessage("Invalid command entered. Type /help for a list of valid commands.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
foreach (Command cmd in cmds)
|
||||||
|
{
|
||||||
if (!cmd.CanRun(player))
|
if (!cmd.CanRun(player))
|
||||||
{
|
{
|
||||||
TShock.Utils.SendLogs(string.Format("{0} tried to execute /{1}.", player.Name, cmdText), Color.Red);
|
TShock.Utils.SendLogs(string.Format("{0} tried to execute /{1}.", player.Name, cmdText), Color.Red);
|
||||||
|
|
@ -252,6 +253,7 @@ namespace TShockAPI
|
||||||
if (cmd.DoLog)
|
if (cmd.DoLog)
|
||||||
TShock.Utils.SendLogs(string.Format("{0} executed: /{1}.", player.Name, cmdText), Color.Red);
|
TShock.Utils.SendLogs(string.Format("{0} executed: /{1}.", player.Name, cmdText), Color.Red);
|
||||||
cmd.Run(cmdText, player, args);
|
cmd.Run(cmdText, player, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue