Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
74d32c070b | |||
da37092a85 | |||
7682bc325c | |||
61b6b2115a |
@ -1,14 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using Dalamud.Game.Command;
|
using Dalamud.Game.Command;
|
||||||
using Dalamud.Game.Text.SeStringHandling;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using Dalamud.Plugin.Ipc;
|
using Dalamud.Plugin.Ipc;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||||
|
using LLib;
|
||||||
|
|
||||||
namespace KitchenSink.Commands;
|
namespace KitchenSink.Commands;
|
||||||
|
|
||||||
@ -22,18 +25,35 @@ internal sealed class DropboxQueue : IDisposable
|
|||||||
InventoryType.Inventory4,
|
InventoryType.Inventory4,
|
||||||
InventoryType.Crystals,
|
InventoryType.Crystals,
|
||||||
InventoryType.Currency,
|
InventoryType.Currency,
|
||||||
|
|
||||||
|
InventoryType.ArmoryMainHand,
|
||||||
|
InventoryType.ArmoryOffHand,
|
||||||
|
|
||||||
|
InventoryType.ArmoryHead,
|
||||||
|
InventoryType.ArmoryBody,
|
||||||
|
InventoryType.ArmoryHands,
|
||||||
|
InventoryType.ArmoryLegs,
|
||||||
|
InventoryType.ArmoryFeets,
|
||||||
|
|
||||||
|
InventoryType.ArmoryEar,
|
||||||
|
InventoryType.ArmoryNeck,
|
||||||
|
InventoryType.ArmoryWrist,
|
||||||
|
InventoryType.ArmoryRings,
|
||||||
];
|
];
|
||||||
|
|
||||||
private readonly ICommandManager _commandManager;
|
private readonly ICommandManager _commandManager;
|
||||||
private readonly IChatGui _chatGui;
|
private readonly IChatGui _chatGui;
|
||||||
private readonly DropboxApi _dropboxApi;
|
private readonly DropboxApi _dropboxApi;
|
||||||
|
|
||||||
public DropboxQueue(IDalamudPluginInterface pluginInterface, ICommandManager commandManager, IChatGui chatGui,
|
public DropboxQueue(IDalamudPluginInterface pluginInterface,
|
||||||
|
DalamudReflector reflector,
|
||||||
|
ICommandManager commandManager,
|
||||||
|
IChatGui chatGui,
|
||||||
IPluginLog pluginLog)
|
IPluginLog pluginLog)
|
||||||
{
|
{
|
||||||
_commandManager = commandManager;
|
_commandManager = commandManager;
|
||||||
_chatGui = chatGui;
|
_chatGui = chatGui;
|
||||||
_dropboxApi = new DropboxApi(pluginInterface, pluginLog);
|
_dropboxApi = new DropboxApi(pluginInterface, reflector, pluginLog);
|
||||||
|
|
||||||
_commandManager.AddHandler("/dbq", new CommandInfo(Queue)
|
_commandManager.AddHandler("/dbq", new CommandInfo(Queue)
|
||||||
{
|
{
|
||||||
@ -57,14 +77,23 @@ internal sealed class DropboxQueue : IDisposable
|
|||||||
case "crystals":
|
case "crystals":
|
||||||
BuildRequest(string.Join(" ", Enumerable.Range(8, 6).Select(x => $"{x}:9999")));
|
BuildRequest(string.Join(" ", Enumerable.Range(8, 6).Select(x => $"{x}:9999")));
|
||||||
break;
|
break;
|
||||||
|
case "clusters":
|
||||||
|
BuildRequest(string.Join(" ", Enumerable.Range(14, 6).Select(x => $"{x}:9999")));
|
||||||
|
break;
|
||||||
case "shards+crystals":
|
case "shards+crystals":
|
||||||
BuildRequest(string.Join(" ", Enumerable.Range(2, 12).Select(x => $"{x}:9999")));
|
BuildRequest(string.Join(" ", Enumerable.Range(2, 12).Select(x => $"{x}:9999")));
|
||||||
break;
|
break;
|
||||||
|
case "crystals+clusters":
|
||||||
|
BuildRequest(string.Join(" ", Enumerable.Range(8, 12).Select(x => $"{x}:9999")));
|
||||||
|
break;
|
||||||
|
case "shards+crystals+clusters":
|
||||||
|
BuildRequest(string.Join(" ", Enumerable.Range(2, 18).Select(x => $"{x}:9999")));
|
||||||
|
break;
|
||||||
case "request":
|
case "request":
|
||||||
BuildRequest(parts.Length == 2 ? parts[1] : string.Empty);
|
BuildRequest(parts.Length == 2 ? parts[1] : string.Empty);
|
||||||
break;
|
break;
|
||||||
case "clear":
|
case "clear":
|
||||||
//_dropboxApi.ClearQueue();
|
_dropboxApi.ClearQueue();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
AddToQueue(arguments);
|
AddToQueue(arguments);
|
||||||
@ -90,7 +119,9 @@ internal sealed class DropboxQueue : IDisposable
|
|||||||
var missingItems = parsedItems
|
var missingItems = parsedItems
|
||||||
.Select(item => item with
|
.Select(item => item with
|
||||||
{
|
{
|
||||||
Needed = item.Needed - inventoryManger->GetItemCountInContainer(item.ItemId, InventoryType.Crystals)
|
Needed = item.Needed - DefaultInventoryTypes.Sum(y =>
|
||||||
|
inventoryManger->GetItemCountInContainer(item.ItemId, y) +
|
||||||
|
inventoryManger->GetItemCountInContainer(item.ItemId, y, true))
|
||||||
})
|
})
|
||||||
.Where(x => x.Needed > 0)
|
.Where(x => x.Needed > 0)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -233,13 +264,15 @@ internal sealed class DropboxQueue : IDisposable
|
|||||||
|
|
||||||
private sealed class DropboxApi
|
private sealed class DropboxApi
|
||||||
{
|
{
|
||||||
|
private readonly DalamudReflector _reflector;
|
||||||
private readonly IPluginLog _pluginLog;
|
private readonly IPluginLog _pluginLog;
|
||||||
private readonly ICallGateSubscriber<object> _beginTradingQueue;
|
private readonly ICallGateSubscriber<object> _beginTradingQueue;
|
||||||
private readonly ICallGateSubscriber<uint, bool, int> _getItemQuantity;
|
private readonly ICallGateSubscriber<uint, bool, int> _getItemQuantity;
|
||||||
private readonly ICallGateSubscriber<uint, bool, int, object> _setItemQuantity;
|
private readonly ICallGateSubscriber<uint, bool, int, object> _setItemQuantity;
|
||||||
|
|
||||||
public DropboxApi(IDalamudPluginInterface pluginInterface, IPluginLog pluginLog)
|
public DropboxApi(IDalamudPluginInterface pluginInterface, DalamudReflector reflector, IPluginLog pluginLog)
|
||||||
{
|
{
|
||||||
|
_reflector = reflector;
|
||||||
_pluginLog = pluginLog;
|
_pluginLog = pluginLog;
|
||||||
|
|
||||||
_beginTradingQueue = pluginInterface.GetIpcSubscriber<object>("Dropbox.BeginTradingQueue");
|
_beginTradingQueue = pluginInterface.GetIpcSubscriber<object>("Dropbox.BeginTradingQueue");
|
||||||
@ -258,5 +291,27 @@ internal sealed class DropboxQueue : IDisposable
|
|||||||
int currentQuantity = _getItemQuantity.InvokeFunc(itemId, hq);
|
int currentQuantity = _getItemQuantity.InvokeFunc(itemId, hq);
|
||||||
_setItemQuantity.InvokeAction(itemId, hq, quantity + currentQuantity);
|
_setItemQuantity.InvokeAction(itemId, hq, quantity + currentQuantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ClearQueue()
|
||||||
|
{
|
||||||
|
if (TryGetItemQuantities(out _, out IDictionary? itemQuantities))
|
||||||
|
itemQuantities.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryGetItemQuantities([NotNullWhen(true)] out IDalamudPlugin? dropboxPlugin,
|
||||||
|
[NotNullWhen(true)] out IDictionary? itemQuantities)
|
||||||
|
{
|
||||||
|
if (!_reflector.TryGetDalamudPlugin("Dropbox", out dropboxPlugin))
|
||||||
|
{
|
||||||
|
itemQuantities = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var itemQueueUiType = dropboxPlugin.GetType().Assembly.GetType("Dropbox.ItemQueueUI")!;
|
||||||
|
itemQuantities =
|
||||||
|
(IDictionary?)itemQueueUiType.GetField("ItemQuantities", BindingFlags.Public | BindingFlags.Static)!
|
||||||
|
.GetValue(null);
|
||||||
|
return itemQuantities != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
|
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>1.0</Version>
|
<Version>1.2</Version>
|
||||||
<OutputPath>dist</OutputPath>
|
<OutputPath>dist</OutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ using Dalamud.Plugin;
|
|||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using ECommons;
|
using ECommons;
|
||||||
using KitchenSink.Commands;
|
using KitchenSink.Commands;
|
||||||
|
using LLib;
|
||||||
|
|
||||||
namespace KitchenSink;
|
namespace KitchenSink;
|
||||||
|
|
||||||
@ -17,13 +18,15 @@ internal sealed class KitchenSinkPlugin : IDalamudPlugin
|
|||||||
|
|
||||||
public KitchenSinkPlugin(IDalamudPluginInterface pluginInterface, ICommandManager commandManager,
|
public KitchenSinkPlugin(IDalamudPluginInterface pluginInterface, ICommandManager commandManager,
|
||||||
IClientState clientState, IChatGui chatGui, INotificationManager notificationManager, IDtrBar dtrBar,
|
IClientState clientState, IChatGui chatGui, INotificationManager notificationManager, IDtrBar dtrBar,
|
||||||
ICondition condition, IPluginLog pluginLog)
|
ICondition condition, IFramework framework, IPluginLog pluginLog)
|
||||||
{
|
{
|
||||||
|
DalamudReflector reflector = new DalamudReflector(pluginInterface, framework, pluginLog);
|
||||||
|
|
||||||
ECommonsMain.Init(pluginInterface, this);
|
ECommonsMain.Init(pluginInterface, this);
|
||||||
_autoRetainerApi = new AutoRetainerApi();
|
_autoRetainerApi = new AutoRetainerApi();
|
||||||
_characterSwitch = new CharacterSwitch(_autoRetainerApi, commandManager, clientState, chatGui,
|
_characterSwitch = new CharacterSwitch(_autoRetainerApi, commandManager, clientState, chatGui,
|
||||||
notificationManager, dtrBar, condition, pluginLog);
|
notificationManager, dtrBar, condition, pluginLog);
|
||||||
_dropboxQueue = new DropboxQueue(pluginInterface, commandManager, chatGui, pluginLog);
|
_dropboxQueue = new DropboxQueue(pluginInterface, reflector, commandManager, chatGui, pluginLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
Loading…
Reference in New Issue
Block a user