Fix issue where player names aren't saved
This commit is contained in:
parent
6763b47509
commit
668287a7e2
@ -136,7 +136,7 @@ internal sealed class PersistenceContext
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var updates = mappings
|
var updates = mappings.DistinctBy(x => x.ContentId)
|
||||||
.Where(mapping => mapping.ContentId != 0 && !string.IsNullOrEmpty(mapping.PlayerName))
|
.Where(mapping => mapping.ContentId != 0 && !string.IsNullOrEmpty(mapping.PlayerName))
|
||||||
.Where(mapping =>
|
.Where(mapping =>
|
||||||
{
|
{
|
||||||
@ -157,9 +157,15 @@ internal sealed class PersistenceContext
|
|||||||
using (var scope = _serviceProvider.CreateScope())
|
using (var scope = _serviceProvider.CreateScope())
|
||||||
{
|
{
|
||||||
using var dbContext = scope.ServiceProvider.GetRequiredService<RetainerTrackContext>();
|
using var dbContext = scope.ServiceProvider.GetRequiredService<RetainerTrackContext>();
|
||||||
|
foreach (var update in updates)
|
||||||
|
{
|
||||||
|
if (!dbContext.Players.Any(x => x.LocalContentId == update.LocalContentId))
|
||||||
dbContext.Players.AddRange(updates);
|
dbContext.Players.AddRange(updates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var player in updates)
|
foreach (var player in updates)
|
||||||
_playerNameCache[player.LocalContentId] = player.Name ?? string.Empty;
|
_playerNameCache[player.LocalContentId] = player.Name ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
<Version>3.0</Version>
|
<Version>3.1</Version>
|
||||||
<LangVersion>12.0</LangVersion>
|
<LangVersion>12.0</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
@ -37,7 +37,8 @@ internal sealed class RetainerTrackPlugin : IDalamudPlugin
|
|||||||
ServiceCollection serviceCollection = new();
|
ServiceCollection serviceCollection = new();
|
||||||
serviceCollection.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Trace)
|
serviceCollection.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Trace)
|
||||||
.ClearProviders()
|
.ClearProviders()
|
||||||
.AddDalamudLogger(pluginLog));
|
.AddDalamudLogger(pluginLog)
|
||||||
|
.AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Warning));
|
||||||
serviceCollection.AddSingleton<IDalamudPlugin>(this);
|
serviceCollection.AddSingleton<IDalamudPlugin>(this);
|
||||||
serviceCollection.AddSingleton(pluginInterface);
|
serviceCollection.AddSingleton(pluginInterface);
|
||||||
serviceCollection.AddSingleton(framework);
|
serviceCollection.AddSingleton(framework);
|
||||||
|
Loading…
Reference in New Issue
Block a user