using StardewModdingAPI; using StardewValley; using StardewValley.Objects; namespace TrainerMod.Framework.Commands.Player { /// A command which adds a ring to the player inventory. internal class AddRingCommand : TrainerCommand { /********* ** Public methods *********/ /// Construct an instance. public AddRingCommand() : base("player_addring", "Gives the player a ring.\n\nUsage: player_addring \n- item: the ring ID (use the 'list_items' command to see a list).") { } /// Handle the command. /// Writes messages to the console and log file. /// The command name. /// The command arguments. public override void Handle(IMonitor monitor, string command, ArgumentParser args) { // parse arguments if (!args.TryGetInt(0, "ring ID", out int ringID, min: Ring.ringLowerIndexRange, max: Ring.ringUpperIndexRange)) return; // handle Ring ring = new Ring(ringID); Game1.player.addItemByMenuIfNecessary(ring); monitor.Log($"OK, added {ring.Name} to your inventory.", LogLevel.Info); } } }