forked from liza/ARControl
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">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
<TargetFramework>net7.0-windows</TargetFramework>
|
||||||
<Version>3.1</Version>
|
<Version>3.2</Version>
|
||||||
<LangVersion>11.0</LangVersion>
|
<LangVersion>11.0</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
@ -44,9 +44,13 @@ partial class AutoRetainerControlPlugin
|
|||||||
save = true;
|
save = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove retainers without name
|
||||||
|
save |= character.Retainers.RemoveAll(x => string.IsNullOrEmpty(x.Name)) > 0;
|
||||||
|
|
||||||
// migrate legacy retainers
|
// migrate legacy retainers
|
||||||
foreach (var legacyRetainer in character.Retainers.Where(x => x.RetainerContentId == 0))
|
foreach (var legacyRetainer in character.Retainers.Where(x => x.RetainerContentId == 0))
|
||||||
{
|
{
|
||||||
|
_pluginLog.Information($"Migrating retainer '{legacyRetainer.Name}' (char: {character})");
|
||||||
var retainerData =
|
var retainerData =
|
||||||
offlineCharacterData.RetainerData.SingleOrDefault(x => legacyRetainer.Name == x.Name);
|
offlineCharacterData.RetainerData.SingleOrDefault(x => legacyRetainer.Name == x.Name);
|
||||||
if (retainerData != null)
|
if (retainerData != null)
|
||||||
@ -71,7 +75,7 @@ partial class AutoRetainerControlPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<ulong> unknownRetainerIds = offlineCharacterData.RetainerData.Select(x => x.RetainerID).Where(x => x != 0).ToList();
|
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);
|
unknownRetainerIds.Remove(retainerData.RetainerID);
|
||||||
|
|
||||||
|
@ -74,8 +74,19 @@ public sealed partial class AutoRetainerControlPlugin : IDalamudPlugin
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (_autoRetainerApi.Ready)
|
if (_autoRetainerApi.Ready)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
Sync();
|
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)
|
private void SendRetainerToVenture(string retainerName)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user