summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Volchek <volchek2@illinois.edu>2018-04-17 15:35:22 -0500
committerDan Volchek <volchek2@illinois.edu>2018-04-17 15:35:22 -0500
commit43487a40e391978221df00ba86f2b7628ed8d343 (patch)
tree3ba8ef3e1e6eeeb6380f21b7fcaa07049ea4985f /src
parentb990f81eda42395eff63d77093092663de751712 (diff)
downloadSMAPI-43487a40e391978221df00ba86f2b7628ed8d343.tar.gz
SMAPI-43487a40e391978221df00ba86f2b7628ed8d343.tar.bz2
SMAPI-43487a40e391978221df00ba86f2b7628ed8d343.zip
refactor finding items by name slightly
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs
index 3d55b425..453b8e32 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs
@@ -118,16 +118,17 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
// find matching items
IEnumerable<SearchableItem> matching = this.Items.GetAll().Where(p => p.DisplayName.IndexOf(name, StringComparison.InvariantCultureIgnoreCase) != -1);
- SearchableItem exactMatch = matching.FirstOrDefault(item => item.DisplayName.Equals(name, StringComparison.InvariantCultureIgnoreCase));
-
- int numberOfMatches = matching.Count();
+ match = matching.FirstOrDefault(item => item.DisplayName.Equals(name, StringComparison.InvariantCultureIgnoreCase));
// handle unique requirement
- if (exactMatch != null)
+ if (match != null)
{
- match = matching.ElementAt(0);
+ return;
}
- else if (numberOfMatches == 0)
+
+ int numberOfMatches = matching.Count();
+
+ if (numberOfMatches == 0)
{
monitor.Log($"There's no item with name '{name}'. You can use the 'list_items [name]' command to search for items.", LogLevel.Error);
}