Fix issue where non-existent retainers could cause plugin to not work properly
This commit is contained in:
parent
37e9f29d41
commit
e78cd642cd
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<Version>3.1</Version>
|
||||
<Version>3.2</Version>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
|
@ -44,9 +44,13 @@ partial class AutoRetainerControlPlugin
|
||||
save = true;
|
||||
}
|
||||
|
||||
// remove retainers without name
|
||||
save |= character.Retainers.RemoveAll(x => string.IsNullOrEmpty(x.Name)) > 0;
|
||||
|
||||
// migrate legacy retainers
|
||||
foreach (var legacyRetainer in character.Retainers.Where(x => x.RetainerContentId == 0))
|
||||
{
|
||||
_pluginLog.Information($"Migrating retainer '{legacyRetainer.Name}' (char: {character})");
|
||||
var retainerData =
|
||||
offlineCharacterData.RetainerData.SingleOrDefault(x => legacyRetainer.Name == x.Name);
|
||||
if (retainerData != null)
|
||||
@ -71,7 +75,7 @@ partial class AutoRetainerControlPlugin
|
||||
}
|
||||
|
||||
List<ulong> unknownRetainerIds = offlineCharacterData.RetainerData.Select(x => x.RetainerID).Where(x => x != 0).ToList();
|
||||
foreach (var retainerData in offlineCharacterData.RetainerData)
|
||||
foreach (var retainerData in offlineCharacterData.RetainerData.Where(x => !string.IsNullOrEmpty(x.Name)))
|
||||
{
|
||||
unknownRetainerIds.Remove(retainerData.RetainerID);
|
||||
|
||||
|
@ -74,8 +74,19 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
|
||||
});
|
||||
|
||||
if (_autoRetainerApi.Ready)
|
||||
{
|
||||
try
|
||||
{
|
||||
Sync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_pluginLog.Error(e, "Unable to sync characters");
|
||||
_chatGui.PrintError(
|
||||
"Unable to synchronize characters with AutoRetainer, plugin might not work properly.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SendRetainerToVenture(string retainerName)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user