Skip to content

Commit

Permalink
fix(autoforager/fruittrees): Additional fruit tree parsing protections
Browse files Browse the repository at this point in the history
  • Loading branch information
jag3dagster committed Mar 27, 2024
1 parent 1467b02 commit 7b3205b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/AutoForager/AutoForager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Name>Auto Forager</Name>
<Authors>Jag3Dagster</Authors>
<Description>Automatically forage items simply by moving near them.</Description>
<Version>2.2.1</Version>
<Version>2.2.2</Version>
<UpdateKeys>Nexus:7736</UpdateKeys>

<MinimumApiVersion>auto</MinimumApiVersion>
Expand Down
14 changes: 9 additions & 5 deletions src/AutoForager/Classes/ForageableItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,18 @@ public static IEnumerable<ForageableItem> ParseFruitTreeData(IDictionary<string,
if (customFields == null || !customFields.ContainsKey(Constants.CustomFieldForageableKey)) continue;

var enabled = true;
var seedData = ItemRegistry.GetData(fruit.ItemId);
var fruitData = ItemRegistry.GetData(fruit.ItemId);
fruitData ??= ItemRegistry.GetData("(O)" + fruit.ItemId);

if (configValues != null && configValues.TryGetValue(seedData.InternalName, out var configEnabled))
if (fruitData != null)
{
enabled = configEnabled;
}
if (configValues != null && configValues.TryGetValue(fruitData.InternalName, out var configEnabled))
{
enabled = configEnabled;
}

forageItems.AddDistinct(new ForageableItem(seedData, customFields, enabled));
forageItems.AddDistinct(new ForageableItem(fruitData, customFields, enabled));
}
}
catch (Exception ex)
{
Expand Down
5 changes: 5 additions & 0 deletions src/AutoForager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ Ukrainian | ✔ | ❌ | ❌

## Releases
Releases can be found on [GitHub](https://github.com/Hedgehog-Technologies/StardewMods/releases), on the [Nexus Mod](https://www.nexusmods.com/stardewvalley/mods/7736) site, and on the [CurseForge](https://www.curseforge.com/stardewvalley/mods/auto-forager) site.
### 2.2.2
- Additional error checks and fallbacks when parsing Fruit Trees
### 2.2.1
- Fixed errors when parsing trees
- Prevent possible future errors from completely halting mod functionality
### 2.2.0
- Added compatibility with Stardew Valley Expanded forageable items
- Added "Moss" as a forageable option
Expand Down

0 comments on commit 7b3205b

Please sign in to comment.