fix new error when entering an empty command in SMAPI console

This commit is contained in:
Jesse Plamondon-Willard 2017-02-21 15:54:48 -05:00
parent 7521570341
commit 703f5f89a8
2 changed files with 4 additions and 2 deletions

View File

@ -70,6 +70,9 @@ namespace StardewModdingAPI.Framework
/// <returns>Returns whether a matching command was triggered.</returns> /// <returns>Returns whether a matching command was triggered.</returns>
public bool Trigger(string input) public bool Trigger(string input)
{ {
if (string.IsNullOrWhiteSpace(input))
return false;
string[] args = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] args = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
string name = args[0]; string name = args[0];
args = args.Skip(1).ToArray(); args = args.Skip(1).ToArray();

View File

@ -575,7 +575,7 @@ namespace StardewModdingAPI
while (true) while (true)
{ {
string input = Console.ReadLine(); string input = Console.ReadLine();
if (!this.CommandManager.Trigger(input)) if (!string.IsNullOrWhiteSpace(input) && !this.CommandManager.Trigger(input))
this.Monitor.Log("Unknown command; type 'help' for a list of available commands.", LogLevel.Error); this.Monitor.Log("Unknown command; type 'help' for a list of available commands.", LogLevel.Error);
} }
} }
@ -587,7 +587,6 @@ namespace StardewModdingAPI
{ {
if (arguments.Any()) if (arguments.Any())
{ {
Framework.Command result = this.CommandManager.Get(arguments[0]); Framework.Command result = this.CommandManager.Get(arguments[0]);
if (result == null) if (result == null)
this.Monitor.Log("There's no command with that name.", LogLevel.Error); this.Monitor.Log("There's no command with that name.", LogLevel.Error);