summaryrefslogtreecommitdiff
path: root/src/SMAPI.Mods.ConsoleCommands/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-01-22 21:05:04 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-01-22 21:05:04 -0500
commitd0dc3ea6f6d03e6aabdab5f5f10a60177f0e53b6 (patch)
tree02896d970c7650d8f7c8b84f54e53eddab88b4ca /src/SMAPI.Mods.ConsoleCommands/Framework
parent5953fc3bd083ae0a579d2da1ad833e6163848086 (diff)
parent733750fdc4f5d16069d95880144619c0e31e8a89 (diff)
downloadSMAPI-d0dc3ea6f6d03e6aabdab5f5f10a60177f0e53b6.tar.gz
SMAPI-d0dc3ea6f6d03e6aabdab5f5f10a60177f0e53b6.tar.bz2
SMAPI-d0dc3ea6f6d03e6aabdab5f5f10a60177f0e53b6.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework')
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/ConsoleCommand.cs (renamed from src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs)6
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/IConsoleCommand.cs (renamed from src/SMAPI.Mods.ConsoleCommands/Framework/Commands/ITrainerCommand.cs)2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ApplySaveFixCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/DebugCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowDataFilesCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowGameFilesCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemTypesCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemsCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetColorCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetHealthCommand.cs38
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetImmunityCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMaxHealthCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMaxStaminaCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMoneyCommand.cs38
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetNameCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStaminaCommand.cs38
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStyleCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetDayCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetYearCommand.cs2
27 files changed, 47 insertions, 119 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/ConsoleCommand.cs
index 98daa906..01cab92e 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/ConsoleCommand.cs
@@ -4,8 +4,8 @@ using System.Linq;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
{
- /// <summary>The base implementation for a trainer command.</summary>
- internal abstract class TrainerCommand : ITrainerCommand
+ /// <summary>The base implementation for a console command.</summary>
+ internal abstract class ConsoleCommand : IConsoleCommand
{
/*********
** Accessors
@@ -50,7 +50,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
/// <param name="description">The command description.</param>
/// <param name="mayNeedInput">Whether the command may need to perform logic when the player presses a button.</param>
/// <param name="mayNeedUpdate">Whether the command may need to perform logic when the game updates.</param>
- protected TrainerCommand(string name, string description, bool mayNeedInput = false, bool mayNeedUpdate = false)
+ protected ConsoleCommand(string name, string description, bool mayNeedInput = false, bool mayNeedUpdate = false)
{
this.Name = name;
this.Description = description;
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/ITrainerCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/IConsoleCommand.cs
index d4d36e5d..9c82bbd3 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/ITrainerCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/IConsoleCommand.cs
@@ -1,7 +1,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
{
/// <summary>A console command to register.</summary>
- internal interface ITrainerCommand
+ internal interface IConsoleCommand
{
/*********
** Accessors
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ApplySaveFixCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ApplySaveFixCommand.cs
index 8f59342e..957b0e75 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ApplySaveFixCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ApplySaveFixCommand.cs
@@ -5,7 +5,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
{
/// <summary>A command which runs one of the game's save migrations.</summary>
- internal class ApplySaveFixCommand : TrainerCommand
+ internal class ApplySaveFixCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/DebugCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/DebugCommand.cs
index e4010111..1955c14e 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/DebugCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/DebugCommand.cs
@@ -3,7 +3,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
{
/// <summary>A command which sends a debug command to the game.</summary>
- internal class DebugCommand : TrainerCommand
+ internal class DebugCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowDataFilesCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowDataFilesCommand.cs
index 54d27185..27f6ce53 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowDataFilesCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowDataFilesCommand.cs
@@ -3,7 +3,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
{
/// <summary>A command which shows the data files.</summary>
- internal class ShowDataFilesCommand : TrainerCommand
+ internal class ShowDataFilesCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowGameFilesCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowGameFilesCommand.cs
index 0257892f..71093184 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowGameFilesCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowGameFilesCommand.cs
@@ -3,7 +3,7 @@
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
{
/// <summary>A command which shows the game files.</summary>
- internal class ShowGameFilesCommand : TrainerCommand
+ internal class ShowGameFilesCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs
index 11aa10c3..46583dc3 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs
@@ -3,7 +3,7 @@ using System;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
{
/// <summary>A command which logs the keys being pressed for 30 seconds once enabled.</summary>
- internal class TestInputCommand : TrainerCommand
+ internal class TestInputCommand : ConsoleCommand
{
/*********
** Fields
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs
index 6cb2b624..0e8f7517 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs
@@ -7,7 +7,7 @@ using Object = StardewValley.Object;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which adds an item to the player inventory.</summary>
- internal class AddCommand : TrainerCommand
+ internal class AddCommand : ConsoleCommand
{
/*********
** Fields
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemTypesCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemTypesCommand.cs
index a835455e..1f12e5f9 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemTypesCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemTypesCommand.cs
@@ -4,7 +4,7 @@ using StardewModdingAPI.Mods.ConsoleCommands.Framework.ItemData;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which list item types.</summary>
- internal class ListItemTypesCommand : TrainerCommand
+ internal class ListItemTypesCommand : ConsoleCommand
{
/*********
** Fields
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemsCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemsCommand.cs
index 4232ce16..67569298 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemsCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemsCommand.cs
@@ -6,7 +6,7 @@ using StardewModdingAPI.Mods.ConsoleCommands.Framework.ItemData;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which list items available to spawn.</summary>
- internal class ListItemsCommand : TrainerCommand
+ internal class ListItemsCommand : ConsoleCommand
{
/*********
** Fields
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetColorCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetColorCommand.cs
index f0815ef6..7b7cbf83 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetColorCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetColorCommand.cs
@@ -4,7 +4,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the color of a player feature.</summary>
- internal class SetColorCommand : TrainerCommand
+ internal class SetColorCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetHealthCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetHealthCommand.cs
index 59bda5dd..f27b336f 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetHealthCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetHealthCommand.cs
@@ -4,21 +4,14 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the player's current health.</summary>
- internal class SetHealthCommand : TrainerCommand
+ internal class SetHealthCommand : ConsoleCommand
{
/*********
- ** Fields
- *********/
- /// <summary>Whether to keep the player's health at its maximum.</summary>
- private bool InfiniteHealth;
-
-
- /*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
public SetHealthCommand()
- : base("player_sethealth", "Sets the player's health.\n\nUsage: player_sethealth [value]\n- value: an integer amount, or 'inf' for infinite health.", mayNeedUpdate: true) { }
+ : base("player_sethealth", "Sets the player's health.\n\nUsage: player_sethealth [value]\n- value: an integer amount.") { }
/// <summary>Handle the command.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
@@ -29,36 +22,19 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
// no-argument mode
if (!args.Any())
{
- monitor.Log($"You currently have {(this.InfiniteHealth ? "infinite" : Game1.player.health.ToString())} health. Specify a value to change it.", LogLevel.Info);
+ monitor.Log($"You currently have {Game1.player.health} health. Specify a value to change it.", LogLevel.Info);
return;
}
// handle
string amountStr = args[0];
- if (amountStr == "inf")
+ if (int.TryParse(amountStr, out int amount))
{
- this.InfiniteHealth = true;
- monitor.Log("OK, you now have infinite health.", LogLevel.Info);
+ Game1.player.health = amount;
+ monitor.Log($"OK, you now have {Game1.player.health} health.", LogLevel.Info);
}
else
- {
- this.InfiniteHealth = false;
- if (int.TryParse(amountStr, out int amount))
- {
- Game1.player.health = amount;
- monitor.Log($"OK, you now have {Game1.player.health} health.", LogLevel.Info);
- }
- else
- this.LogArgumentNotInt(monitor);
- }
- }
-
- /// <summary>Perform any logic needed on update tick.</summary>
- /// <param name="monitor">Writes messages to the console and log file.</param>
- public override void OnUpdated(IMonitor monitor)
- {
- if (this.InfiniteHealth && Context.IsWorldReady)
- Game1.player.health = Game1.player.maxHealth;
+ this.LogArgumentNotInt(monitor);
}
}
}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetImmunityCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetImmunityCommand.cs
index 9c66c4fe..df90adf2 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetImmunityCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetImmunityCommand.cs
@@ -4,7 +4,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the player's current immunity.</summary>
- internal class SetImmunityCommand : TrainerCommand
+ internal class SetImmunityCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMaxHealthCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMaxHealthCommand.cs
index f4ae0694..a5f7f444 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMaxHealthCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMaxHealthCommand.cs
@@ -4,7 +4,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the player's maximum health.</summary>
- internal class SetMaxHealthCommand : TrainerCommand
+ internal class SetMaxHealthCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMaxStaminaCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMaxStaminaCommand.cs
index 5bce5ea3..e3c2f011 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMaxStaminaCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMaxStaminaCommand.cs
@@ -4,7 +4,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the player's maximum stamina.</summary>
- internal class SetMaxStaminaCommand : TrainerCommand
+ internal class SetMaxStaminaCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMoneyCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMoneyCommand.cs
index 6e3d68b6..787ce920 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMoneyCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetMoneyCommand.cs
@@ -4,21 +4,14 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the player's current money.</summary>
- internal class SetMoneyCommand : TrainerCommand
+ internal class SetMoneyCommand : ConsoleCommand
{
/*********
- ** Fields
- *********/
- /// <summary>Whether to keep the player's money at a set value.</summary>
- private bool InfiniteMoney;
-
-
- /*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
public SetMoneyCommand()
- : base("player_setmoney", "Sets the player's money.\n\nUsage: player_setmoney <value>\n- value: an integer amount, or 'inf' for infinite money.", mayNeedUpdate: true) { }
+ : base("player_setmoney", "Sets the player's money.\n\nUsage: player_setmoney <value>\n- value: an integer amount.") { }
/// <summary>Handle the command.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
@@ -29,36 +22,19 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
// validate
if (!args.Any())
{
- monitor.Log($"You currently have {(this.InfiniteMoney ? "infinite" : Game1.player.Money.ToString())} gold. Specify a value to change it.", LogLevel.Info);
+ monitor.Log($"You currently have {Game1.player.Money} gold. Specify a value to change it.", LogLevel.Info);
return;
}
// handle
string amountStr = args[0];
- if (amountStr == "inf")
+ if (int.TryParse(amountStr, out int amount))
{
- this.InfiniteMoney = true;
- monitor.Log("OK, you now have infinite money.", LogLevel.Info);
+ Game1.player.Money = amount;
+ monitor.Log($"OK, you now have {Game1.player.Money} gold.", LogLevel.Info);
}
else
- {
- this.InfiniteMoney = false;
- if (int.TryParse(amountStr, out int amount))
- {
- Game1.player.Money = amount;
- monitor.Log($"OK, you now have {Game1.player.Money} gold.", LogLevel.Info);
- }
- else
- this.LogArgumentNotInt(monitor);
- }
- }
-
- /// <summary>Perform any logic needed on update tick.</summary>
- /// <param name="monitor">Writes messages to the console and log file.</param>
- public override void OnUpdated(IMonitor monitor)
- {
- if (this.InfiniteMoney && Context.IsWorldReady)
- Game1.player.Money = 999999;
+ this.LogArgumentNotInt(monitor);
}
}
}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetNameCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetNameCommand.cs
index e8cb0584..4911ad1c 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetNameCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetNameCommand.cs
@@ -3,7 +3,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the player's name.</summary>
- internal class SetNameCommand : TrainerCommand
+ internal class SetNameCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStaminaCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStaminaCommand.cs
index 60a1dcb1..c78378ef 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStaminaCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStaminaCommand.cs
@@ -4,21 +4,14 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits the player's current stamina.</summary>
- internal class SetStaminaCommand : TrainerCommand
+ internal class SetStaminaCommand : ConsoleCommand
{
/*********
- ** Fields
- *********/
- /// <summary>Whether to keep the player's stamina at its maximum.</summary>
- private bool InfiniteStamina;
-
-
- /*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
public SetStaminaCommand()
- : base("player_setstamina", "Sets the player's stamina.\n\nUsage: player_setstamina [value]\n- value: an integer amount, or 'inf' for infinite stamina.", mayNeedUpdate: true) { }
+ : base("player_setstamina", "Sets the player's stamina.\n\nUsage: player_setstamina [value]\n- value: an integer amount.") { }
/// <summary>Handle the command.</summary>
/// <param name="monitor">Writes messages to the console and log file.</param>
@@ -29,36 +22,19 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
// validate
if (!args.Any())
{
- monitor.Log($"You currently have {(this.InfiniteStamina ? "infinite" : Game1.player.Stamina.ToString())} stamina. Specify a value to change it.", LogLevel.Info);
+ monitor.Log($"You currently have {Game1.player.Stamina} stamina. Specify a value to change it.", LogLevel.Info);
return;
}
// handle
string amountStr = args[0];
- if (amountStr == "inf")
+ if (int.TryParse(amountStr, out int amount))
{
- this.InfiniteStamina = true;
- monitor.Log("OK, you now have infinite stamina.", LogLevel.Info);
+ Game1.player.Stamina = amount;
+ monitor.Log($"OK, you now have {Game1.player.Stamina} stamina.", LogLevel.Info);
}
else
- {
- this.InfiniteStamina = false;
- if (int.TryParse(amountStr, out int amount))
- {
- Game1.player.Stamina = amount;
- monitor.Log($"OK, you now have {Game1.player.Stamina} stamina.", LogLevel.Info);
- }
- else
- this.LogArgumentNotInt(monitor);
- }
- }
-
- /// <summary>Perform any logic needed on update tick.</summary>
- /// <param name="monitor">Writes messages to the console and log file.</param>
- public override void OnUpdated(IMonitor monitor)
- {
- if (this.InfiniteStamina && Context.IsWorldReady)
- Game1.player.stamina = Game1.player.MaxStamina;
+ this.LogArgumentNotInt(monitor);
}
}
}
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStyleCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStyleCommand.cs
index 31f4107d..98f6c330 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStyleCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetStyleCommand.cs
@@ -3,7 +3,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
{
/// <summary>A command which edits a player style.</summary>
- internal class SetStyleCommand : TrainerCommand
+ internal class SetStyleCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs
index 29052be3..4b0e45a0 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs
@@ -10,7 +10,7 @@ using SObject = StardewValley.Object;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
{
/// <summary>A command which clears in-game objects.</summary>
- internal class ClearCommand : TrainerCommand
+ internal class ClearCommand : ConsoleCommand
{
/*********
** Fields
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs
index 2cec0fd3..0aa9c9c3 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs
@@ -4,7 +4,7 @@ using StardewValley.Locations;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
{
/// <summary>A command which moves the player to the next mine level.</summary>
- internal class DownMineLevelCommand : TrainerCommand
+ internal class DownMineLevelCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs
index 736a93a0..16faa2fe 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/FreezeTimeCommand.cs
@@ -4,7 +4,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
{
/// <summary>A command which freezes the current time.</summary>
- internal class FreezeTimeCommand : TrainerCommand
+ internal class FreezeTimeCommand : ConsoleCommand
{
/*********
** Fields
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetDayCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetDayCommand.cs
index 23c266ea..4028b3dc 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetDayCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetDayCommand.cs
@@ -5,7 +5,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
{
/// <summary>A command which sets the current day.</summary>
- internal class SetDayCommand : TrainerCommand
+ internal class SetDayCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs
index b4f6d5b3..40f4b19f 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs
@@ -4,7 +4,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
{
/// <summary>A command which moves the player to the given mine level.</summary>
- internal class SetMineLevelCommand : TrainerCommand
+ internal class SetMineLevelCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs
index 676369fe..a4cb35bb 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs
@@ -5,7 +5,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
{
/// <summary>A command which sets the current season.</summary>
- internal class SetSeasonCommand : TrainerCommand
+ internal class SetSeasonCommand : ConsoleCommand
{
/*********
** Fields
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs
index 9eae6741..6782e38a 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs
@@ -5,7 +5,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
{
/// <summary>A command which sets the current time.</summary>
- internal class SetTimeCommand : TrainerCommand
+ internal class SetTimeCommand : ConsoleCommand
{
/*********
** Public methods
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetYearCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetYearCommand.cs
index 648830c1..95401962 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetYearCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetYearCommand.cs
@@ -5,7 +5,7 @@ using StardewValley;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
{
/// <summary>A command which sets the current year.</summary>
- internal class SetYearCommand : TrainerCommand
+ internal class SetYearCommand : ConsoleCommand
{
/*********
** Public methods