Skip to content

Commit

Permalink
Fix issue where incorrect stat history was logged to the stats table
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackburn29 committed Jan 10, 2024
1 parent 6a49e23 commit ce4351c
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ public class CharacterStatsChangeListener : AbstractEntityChangeListener<Fragmen
{
protected override Task OnEntityChanged(FragmentContext context, EntityEntry entry)
{
if (entry.Entity is not CharacterStats statsEntry)
{
return Task.CompletedTask;
}

// If the player stats are deleted (which should never happen), we can ignore stats updates
if (entry.State == EntityState.Deleted)
if (entry.State != EntityState.Modified)
{
return Task.CompletedTask;
}

context.CharacterStatHistory.Add(CharacterStatHistory.FromStats(statsEntry));
context.CharacterStatHistory.Add(CharacterStatHistory.FromStats((CharacterStats)entry.OriginalValues.ToObject()));

return Task.CompletedTask;
}
Expand Down

0 comments on commit ce4351c

Please sign in to comment.