qstbak/Questionable/Questionable.External/AutomatonIpc.cs
2025-10-09 07:47:19 +10:00

42 lines
1,015 B
C#

using Dalamud.Plugin;
using Dalamud.Plugin.Ipc;
using Dalamud.Plugin.Ipc.Exceptions;
using Microsoft.Extensions.Logging;
namespace Questionable.External;
internal sealed class AutomatonIpc
{
private readonly ILogger<AutomatonIpc> _logger;
private readonly ICallGateSubscriber<string, bool> _isTweakEnabled;
private bool _loggedIpcError;
public bool IsAutoSnipeEnabled
{
get
{
try
{
return _isTweakEnabled.InvokeFunc("AutoSnipeQuests");
}
catch (IpcError exception)
{
if (!_loggedIpcError)
{
_loggedIpcError = true;
_logger.LogWarning(exception, "Could not query automaton for tweak status, probably not installed");
}
return false;
}
}
}
public AutomatonIpc(IDalamudPluginInterface pluginInterface, ILogger<AutomatonIpc> logger)
{
_logger = logger;
_isTweakEnabled = pluginInterface.GetIpcSubscriber<string, bool>("Automaton.IsTweakEnabled");
logger.LogInformation("Automaton auto-snipe enabled: {IsTweakEnabled}", IsAutoSnipeEnabled);
}
}