diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 48f5a194..eaf69ec6 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -628,12 +628,29 @@ namespace TShockAPI if (cmdPrefix == SilentSpecifier) silent = true; - var args = ParseParameters(cmdText); - if (args.Count < 1) - return false; + int index = -1; + for (int i = 0; i < cmdText.Length; i++) + if (IsWhiteSpace(cmdText[i])) + { + index = i; + break; + } + string cmdName; + if (index == 0) // Space after the command specifier should not be supported + { + player.SendErrorMessage("Invalid command entered. Type {0}help for a list of valid commands.", Specifier); + return true; + } + else if (index < 0) + cmdName = cmdText; + else + cmdName = cmdText.Substring(0, index); - string cmdName = args[0].ToLower(); - args.RemoveAt(0); + List args; + if (index < 0) + args = new List(); + else + args = ParseParameters(cmdText.Substring(index)); IEnumerable cmds = ChatCommands.FindAll(c => c.HasAlias(cmdName)); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index bb2f1702..707d9008 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1384,7 +1384,13 @@ namespace TShockAPI { try { - args.Handled = Commands.HandleCommand(tsplr, args.Text); + args.Handled = true; + if (!Commands.HandleCommand(tsplr, args.Text)) + { + // This is required in case anyone makes HandleCommand return false again + tsplr.SendErrorMessage("Unable to parse command. Please contact an administrator for assistance."); + Log.ConsoleError("Unable to parse command '{0}' from player {1}.", args.Text, tsplr.Name); + } } catch (Exception ex) {