Cancel discard if no server response received after 15s
This commit is contained in:
parent
03a79baaa2
commit
d6155e403e
@ -33,6 +33,8 @@ public class AutoDiscardPlogon : IDalamudPlugin
|
|||||||
private readonly AutoRetainerApi _autoRetainerApi;
|
private readonly AutoRetainerApi _autoRetainerApi;
|
||||||
private readonly TaskManager _taskManager;
|
private readonly TaskManager _taskManager;
|
||||||
|
|
||||||
|
private DateTime _cancelDiscardAfter = DateTime.MaxValue;
|
||||||
|
|
||||||
public AutoDiscardPlogon(DalamudPluginInterface pluginInterface, CommandManager commandManager, ChatGui chatGui,
|
public AutoDiscardPlogon(DalamudPluginInterface pluginInterface, CommandManager commandManager, ChatGui chatGui,
|
||||||
DataManager dataManager, ClientState clientState)
|
DataManager dataManager, ClientState clientState)
|
||||||
{
|
{
|
||||||
@ -117,6 +119,7 @@ public class AutoDiscardPlogon : IDalamudPlugin
|
|||||||
PluginLog.Information(
|
PluginLog.Information(
|
||||||
$"Discarding itemId {nextItem->ItemID} in slot {nextItem->Slot} of container {nextItem->Container}.");
|
$"Discarding itemId {nextItem->ItemID} in slot {nextItem->Slot} of container {nextItem->Container}.");
|
||||||
_inventoryUtils.Discard(nextItem);
|
_inventoryUtils.Discard(nextItem);
|
||||||
|
_cancelDiscardAfter = DateTime.Now.AddSeconds(15);
|
||||||
|
|
||||||
_taskManager.DelayNext(20);
|
_taskManager.DelayNext(20);
|
||||||
_taskManager.Enqueue(() => ConfirmDiscardItem(finishRetainerAction, inventoryType, slot));
|
_taskManager.Enqueue(() => ConfirmDiscardItem(finishRetainerAction, inventoryType, slot));
|
||||||
@ -176,10 +179,21 @@ public class AutoDiscardPlogon : IDalamudPlugin
|
|||||||
}
|
}
|
||||||
else if (nextItem->Container == inventoryType && nextItem->Slot == slot)
|
else if (nextItem->Container == inventoryType && nextItem->Slot == slot)
|
||||||
{
|
{
|
||||||
PluginLog.Information($"ContinueAfterDiscard: Waiting for server response");
|
if (_cancelDiscardAfter < DateTime.Now)
|
||||||
|
{
|
||||||
|
PluginLog.Information("No longer waiting for plugin to pop up, assume discard failed");
|
||||||
|
if (finishRetainerAction)
|
||||||
|
_autoRetainerApi.FinishPostProcess();
|
||||||
|
else
|
||||||
|
_chatGui.PrintError("Discarding probably failed due to an error.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PluginLog.Information($"ContinueAfterDiscard: Waiting for server response until {_cancelDiscardAfter}");
|
||||||
_taskManager.DelayNext(20);
|
_taskManager.DelayNext(20);
|
||||||
_taskManager.Enqueue(() => ContinueAfterDiscard(finishRetainerAction, inventoryType, slot));
|
_taskManager.Enqueue(() => ContinueAfterDiscard(finishRetainerAction, inventoryType, slot));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PluginLog.Information($"ContinueAfterDiscard: Discovered different item to discard");
|
PluginLog.Information($"ContinueAfterDiscard: Discovered different item to discard");
|
||||||
|
Loading…
Reference in New Issue
Block a user