summaryrefslogtreecommitdiff
path: root/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-13 22:06:07 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-13 22:06:07 -0400
commit2765e3f9b379f0dc2a5732c1ca9ba23dbe2a7f15 (patch)
tree3b97dd4aa6e9b7971dafa139c64a39c31e841fe6 /src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs
parentaa7b0caf4656d65ee156c3cf5ea786f561b850bb (diff)
downloadSMAPI-2765e3f9b379f0dc2a5732c1ca9ba23dbe2a7f15.tar.gz
SMAPI-2765e3f9b379f0dc2a5732c1ca9ba23dbe2a7f15.tar.bz2
SMAPI-2765e3f9b379f0dc2a5732c1ca9ba23dbe2a7f15.zip
enable nullable annotations in bundled mods (#837)
Diffstat (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs')
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs
index 0d8db870..74d3d9df 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Linq;
using StardewModdingAPI.Mods.ConsoleCommands.Framework.ItemData;
@@ -42,7 +40,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
}
// read arguments
- if (!args.TryGet(0, "item type", out string type, oneOf: this.ValidTypes))
+ if (!args.TryGet(0, "item type", out string? type, oneOf: this.ValidTypes))
return;
if (!args.TryGetInt(2, "count", out int count, min: 1, required: false))
count = 1;
@@ -50,7 +48,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
quality = Object.lowQuality;
// find matching item
- SearchableItem match = Enum.TryParse(type, true, out ItemType itemType)
+ SearchableItem? match = Enum.TryParse(type, true, out ItemType itemType)
? this.FindItemByID(monitor, args, itemType)
: this.FindItemByName(monitor, args);
if (match == null)
@@ -78,14 +76,14 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
/// <param name="monitor">Writes messages to the console and log file.</param>
/// <param name="args">The command arguments.</param>
/// <param name="type">The item type.</param>
- private SearchableItem FindItemByID(IMonitor monitor, ArgumentParser args, ItemType type)
+ private SearchableItem? FindItemByID(IMonitor monitor, ArgumentParser args, ItemType type)
{
// read arguments
if (!args.TryGetInt(1, "item ID", out int id, min: 0))
return null;
// find matching item
- SearchableItem item = this.Items.GetAll().FirstOrDefault(p => p.Type == type && p.ID == id);
+ SearchableItem? item = this.Items.GetAll().FirstOrDefault(p => p.Type == type && p.ID == id);
if (item == null)
monitor.Log($"There's no {type} item with ID {id}.", LogLevel.Error);
return item;
@@ -94,10 +92,10 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
/// <summary>Get a matching item by its name.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
/// <param name="args">The command arguments.</param>
- private SearchableItem FindItemByName(IMonitor monitor, ArgumentParser args)
+ private SearchableItem? FindItemByName(IMonitor monitor, ArgumentParser args)
{
// read arguments
- if (!args.TryGet(1, "item name", out string name))
+ if (!args.TryGet(1, "item name", out string? name))
return null;
// find matching items