Ensure that AD duty mode is set to 'Support'

This commit is contained in:
Liza 2025-02-08 00:21:00 +01:00
parent 63e279376a
commit 21721e34b4
Signed by: liza
GPG Key ID: 2C41B84815CF6445

View File

@ -12,18 +12,23 @@ internal sealed class AutoDutyIpc
private readonly Configuration _configuration; private readonly Configuration _configuration;
private readonly TerritoryData _territoryData; private readonly TerritoryData _territoryData;
private readonly ILogger<AutoDutyIpc> _logger; private readonly ILogger<AutoDutyIpc> _logger;
private readonly ICallGateSubscriber<uint,bool> _contentHasPath; private readonly ICallGateSubscriber<uint, bool> _contentHasPath;
private readonly ICallGateSubscriber<uint,int,bool,object> _run; private readonly ICallGateSubscriber<string, string, object> _setConfig;
private readonly ICallGateSubscriber<uint, int, bool, object> _run;
private readonly ICallGateSubscriber<bool> _isStopped; private readonly ICallGateSubscriber<bool> _isStopped;
private readonly ICallGateSubscriber<object> _stop;
public AutoDutyIpc(IDalamudPluginInterface pluginInterface, Configuration configuration, TerritoryData territoryData, ILogger<AutoDutyIpc> logger) public AutoDutyIpc(IDalamudPluginInterface pluginInterface, Configuration configuration,
TerritoryData territoryData, ILogger<AutoDutyIpc> logger)
{ {
_configuration = configuration; _configuration = configuration;
_territoryData = territoryData; _territoryData = territoryData;
_logger = logger; _logger = logger;
_contentHasPath = pluginInterface.GetIpcSubscriber<uint, bool>("AutoDuty.ContentHasPath"); _contentHasPath = pluginInterface.GetIpcSubscriber<uint, bool>("AutoDuty.ContentHasPath");
_setConfig = pluginInterface.GetIpcSubscriber<string, string, object>("AutoDuty.SetConfig");
_run = pluginInterface.GetIpcSubscriber<uint, int, bool, object>("AutoDuty.Run"); _run = pluginInterface.GetIpcSubscriber<uint, int, bool, object>("AutoDuty.Run");
_isStopped = pluginInterface.GetIpcSubscriber<bool>("AutoDuty.IsStopped"); _isStopped = pluginInterface.GetIpcSubscriber<bool>("AutoDuty.IsStopped");
_stop = pluginInterface.GetIpcSubscriber<object>("AutoDuty.Stop");
} }
public bool IsConfiguredToRunContent(uint? cfcId, bool autoDutyEnabled) public bool IsConfiguredToRunContent(uint? cfcId, bool autoDutyEnabled)
@ -55,7 +60,8 @@ internal sealed class AutoDutyIpc
} }
catch (IpcError e) catch (IpcError e)
{ {
_logger.LogWarning("Unable to query AutoDuty for path in territory {TerritoryType}: {Message}", cfcData.TerritoryId, e.Message); _logger.LogWarning("Unable to query AutoDuty for path in territory {TerritoryType}: {Message}",
cfcData.TerritoryId, e.Message);
return false; return false;
} }
} }
@ -67,6 +73,7 @@ internal sealed class AutoDutyIpc
try try
{ {
_setConfig.InvokeAction("dutyModeEnum", "Support");
_run.InvokeAction(cfcData.TerritoryId, 1, true); _run.InvokeAction(cfcData.TerritoryId, 1, true);
} }
catch (IpcError e) catch (IpcError e)
@ -86,4 +93,17 @@ internal sealed class AutoDutyIpc
return true; return true;
} }
} }
public void Stop()
{
try
{
_logger.LogInformation("Calling AutoDuty.Stop");
_stop.InvokeAction();
}
catch (IpcError e)
{
throw new TaskException($"Unable to stop AutoDuty: {e.Message}", e);
}
}
} }