Fix IPC again

This commit is contained in:
Liza 2023-08-22 20:14:54 +02:00
parent 0457a86239
commit 5e51a7f6f1
Signed by: liza
GPG Key ID: 7199F8D727D55F67

View File

@ -7,6 +7,7 @@ using Dalamud.Plugin;
using Dalamud.Plugin.Ipc; using Dalamud.Plugin.Ipc;
using Dalamud.Plugin.Ipc.Exceptions; using Dalamud.Plugin.Ipc.Exceptions;
using ECommons.Reflection; using ECommons.Reflection;
using ECommons.Schedulers;
namespace Influx.AllaganTools; namespace Influx.AllaganTools;
@ -39,33 +40,41 @@ internal sealed class AllaganToolsIpc : IDisposable
} }
catch (IpcNotReadyError e) catch (IpcNotReadyError e)
{ {
PluginLog.Debug(e, "Not initializing ATools yet"); PluginLog.Error(e, "Not initializing ATools yet, ipc not ready");
} }
} }
private void ConfigureIpc(bool initialized) private void ConfigureIpc(bool initialized)
{ {
try PluginLog.Information("Configuring Allagan tools IPC");
var _ = new TickScheduler(() =>
{ {
if (DalamudReflector.TryGetDalamudPlugin("Allagan Tools", out var it, false, true) && try
_isInitialized != null && _isInitialized.InvokeFunc())
{ {
var pluginService = it.GetType().Assembly.GetType("InventoryTools.PluginService")!; if (DalamudReflector.TryGetDalamudPlugin("Allagan Tools", out var it, false, true))
{
var pluginService = it.GetType().Assembly.GetType("InventoryTools.PluginService")!;
Characters = new CharacterMonitor(pluginService.GetProperty("CharacterMonitor")!.GetValue(null)!); Characters = new CharacterMonitor(pluginService.GetProperty("CharacterMonitor")!.GetValue(null)!);
Inventories = new InventoryMonitor( Inventories = new InventoryMonitor(
pluginService.GetProperty("InventoryMonitor")!.GetValue(null)!); pluginService.GetProperty("InventoryMonitor")!.GetValue(null)!);
}
else
{
PluginLog.Warning("Reflection was unsuccessful");
}
} }
} catch (Exception e)
catch (Exception e) {
{ PluginLog.Error(e, "Could not initialize IPC");
PluginLog.Error(e, "Could not initialize IPC"); _chatGui.PrintError(e.ToString());
_chatGui.PrintError(e.ToString()); }
} }, 100);
} }
public Dictionary<Character, Currencies> CountCurrencies() public Dictionary<Character, Currencies> CountCurrencies()
{ {
PluginLog.Debug($"{Characters.GetType()}, {Inventories.GetType()}");
var characters = Characters.All.ToDictionary(x => x.CharacterId, x => x); var characters = Characters.All.ToDictionary(x => x.CharacterId, x => x);
return Inventories.All return Inventories.All
.Where(x => !_configuration.ExcludedCharacters.Contains(x.Key)) .Where(x => !_configuration.ExcludedCharacters.Contains(x.Key))