forked from liza/Deliveroo
Experimental (hardcoded) blacklist for items that won't be turned in
This commit is contained in:
parent
b8520ffc13
commit
2c19f59ffb
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
<TargetFramework>net7.0-windows</TargetFramework>
|
||||||
<Version>2.24</Version>
|
<Version>2.25</Version>
|
||||||
<LangVersion>11.0</LangVersion>
|
<LangVersion>11.0</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Dalamud.Game.ClientState.Objects.Types;
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Deliveroo.GameData;
|
using Deliveroo.GameData;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
using LLib.GameUI;
|
using LLib.GameUI;
|
||||||
|
using Lumina.Text.Payloads;
|
||||||
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
|
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
|
||||||
|
|
||||||
namespace Deliveroo;
|
namespace Deliveroo;
|
||||||
@ -78,7 +81,8 @@ partial class DeliverooPlugin
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var addonGc = (AddonGrandCompanySupplyList*)addon;
|
var addonGc = (AddonGrandCompanySupplyList*)addon;
|
||||||
if (addonGc->ExpertDeliveryList == null || !addonGc->ExpertDeliveryList->AtkComponentBase.OwnerNode->AtkResNode.IsVisible)
|
if (addonGc->ExpertDeliveryList == null ||
|
||||||
|
!addonGc->ExpertDeliveryList->AtkComponentBase.OwnerNode->AtkResNode.IsVisible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (addonGc->SelectedTab != 2)
|
if (addonGc->SelectedTab != 2)
|
||||||
@ -98,7 +102,8 @@ partial class DeliverooPlugin
|
|||||||
int currentListSize = addonGc->ExpertDeliveryList->ListLength;
|
int currentListSize = addonGc->ExpertDeliveryList->ListLength;
|
||||||
if (addonGc->ListEmptyTextNode->AtkResNode.IsVisible || currentListSize == 0)
|
if (addonGc->ListEmptyTextNode->AtkResNode.IsVisible || currentListSize == 0)
|
||||||
{
|
{
|
||||||
_pluginLog.Information($"No items to turn in ({addonGc->ListEmptyTextNode->AtkResNode.IsVisible}, {currentListSize})");
|
_pluginLog.Information(
|
||||||
|
$"No items to turn in ({addonGc->ListEmptyTextNode->AtkResNode.IsVisible}, {currentListSize})");
|
||||||
CurrentStage = Stage.CloseGcSupplyThenStop;
|
CurrentStage = Stage.CloseGcSupplyThenStop;
|
||||||
addon->FireCallbackInt(-1);
|
addon->FireCallbackInt(-1);
|
||||||
return;
|
return;
|
||||||
@ -115,7 +120,8 @@ partial class DeliverooPlugin
|
|||||||
if (currentListSize >= _lastTurnInListSize)
|
if (currentListSize >= _lastTurnInListSize)
|
||||||
{
|
{
|
||||||
_turnInErrors++;
|
_turnInErrors++;
|
||||||
_pluginLog.Information($"Trying to refresh expert delivery list manually ({_turnInErrors}, old list size = {_lastTurnInListSize}, new list size = {currentListSize})...");
|
_pluginLog.Information(
|
||||||
|
$"Trying to refresh expert delivery list manually ({_turnInErrors}, old list size = {_lastTurnInListSize}, new list size = {currentListSize})...");
|
||||||
addon->FireCallbackInt(2);
|
addon->FireCallbackInt(2);
|
||||||
|
|
||||||
_continueAt = DateTime.Now.AddSeconds(0.1);
|
_continueAt = DateTime.Now.AddSeconds(0.1);
|
||||||
@ -176,7 +182,20 @@ partial class DeliverooPlugin
|
|||||||
if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyReward>("GrandCompanySupplyReward",
|
if (_gameGui.TryGetAddonByName<AddonGrandCompanySupplyReward>("GrandCompanySupplyReward",
|
||||||
out var addonSupplyReward) && LAddon.IsAddonReady(&addonSupplyReward->AtkUnitBase))
|
out var addonSupplyReward) && LAddon.IsAddonReady(&addonSupplyReward->AtkUnitBase))
|
||||||
{
|
{
|
||||||
_pluginLog.Information($"Turning in '{addonSupplyReward->AtkUnitBase.AtkValues[4].ReadAtkString()}'");
|
string? itemName = addonSupplyReward->AtkUnitBase.AtkValues[4].ReadAtkString();
|
||||||
|
if (itemName != null && _itemCache.GetItemIdFromItemName(itemName)
|
||||||
|
.Any(itemId => DisabledTurnInItems.Contains(itemId)))
|
||||||
|
{
|
||||||
|
_chatGui.Print(new SeStringBuilder().Append("Won't turn in ")
|
||||||
|
.AddItemLink(_itemCache.GetItemIdFromItemName(itemName).First())
|
||||||
|
.Append(".")
|
||||||
|
.Build());
|
||||||
|
|
||||||
|
addonSupplyReward->AtkUnitBase.FireCallbackInt(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_pluginLog.Information($"Turning in '{itemName}'");
|
||||||
|
|
||||||
addonSupplyReward->AtkUnitBase.FireCallbackInt(0);
|
addonSupplyReward->AtkUnitBase.FireCallbackInt(0);
|
||||||
_continueAt = DateTime.Now.AddSeconds(0.58);
|
_continueAt = DateTime.Now.AddSeconds(0.58);
|
||||||
|
@ -25,6 +25,7 @@ namespace Deliveroo;
|
|||||||
public sealed partial class DeliverooPlugin : IDalamudPlugin
|
public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||||
{
|
{
|
||||||
private readonly WindowSystem _windowSystem = new(typeof(DeliverooPlugin).AssemblyQualifiedName);
|
private readonly WindowSystem _windowSystem = new(typeof(DeliverooPlugin).AssemblyQualifiedName);
|
||||||
|
private readonly IReadOnlyList<uint> DisabledTurnInItems = new List<uint> { 2820 }.AsReadOnly();
|
||||||
|
|
||||||
private readonly DalamudPluginInterface _pluginInterface;
|
private readonly DalamudPluginInterface _pluginInterface;
|
||||||
private readonly IChatGui _chatGui;
|
private readonly IChatGui _chatGui;
|
||||||
@ -48,6 +49,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
|||||||
private readonly GcRewardsCache _gcRewardsCache;
|
private readonly GcRewardsCache _gcRewardsCache;
|
||||||
|
|
||||||
private readonly IconCache _iconCache;
|
private readonly IconCache _iconCache;
|
||||||
|
private readonly ItemCache _itemCache;
|
||||||
private readonly ConfigWindow _configWindow;
|
private readonly ConfigWindow _configWindow;
|
||||||
private readonly TurnInWindow _turnInWindow;
|
private readonly TurnInWindow _turnInWindow;
|
||||||
private readonly IReadOnlyDictionary<uint, uint> _sealCaps;
|
private readonly IReadOnlyDictionary<uint, uint> _sealCaps;
|
||||||
@ -80,6 +82,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
|||||||
_configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration();
|
_configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration();
|
||||||
_gcRewardsCache = new GcRewardsCache(dataManager);
|
_gcRewardsCache = new GcRewardsCache(dataManager);
|
||||||
_iconCache = new IconCache(textureProvider);
|
_iconCache = new IconCache(textureProvider);
|
||||||
|
_itemCache = new ItemCache(dataManager);
|
||||||
_configWindow = new ConfigWindow(_pluginInterface, this, _configuration, _gcRewardsCache, _clientState, _pluginLog, _iconCache);
|
_configWindow = new ConfigWindow(_pluginInterface, this, _configuration, _gcRewardsCache, _clientState, _pluginLog, _iconCache);
|
||||||
_windowSystem.AddWindow(_configWindow);
|
_windowSystem.AddWindow(_configWindow);
|
||||||
_turnInWindow = new TurnInWindow(this, _pluginInterface, _configuration, _condition, _clientState, _gcRewardsCache, _configWindow, _iconCache);
|
_turnInWindow = new TurnInWindow(this, _pluginInterface, _configuration, _condition, _clientState, _gcRewardsCache, _configWindow, _iconCache);
|
||||||
|
27
Deliveroo/GameData/ItemCache.cs
Normal file
27
Deliveroo/GameData/ItemCache.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
||||||
|
namespace Deliveroo.GameData;
|
||||||
|
|
||||||
|
internal class ItemCache
|
||||||
|
{
|
||||||
|
private readonly Dictionary<string, HashSet<uint>> _itemNamesToIds = new();
|
||||||
|
|
||||||
|
public ItemCache(IDataManager dataManager)
|
||||||
|
{
|
||||||
|
foreach (var item in dataManager.GetExcelSheet<Item>()!)
|
||||||
|
{
|
||||||
|
string name = item.Name.ToString();
|
||||||
|
if (string.IsNullOrWhiteSpace(name))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (_itemNamesToIds.TryGetValue(name, out HashSet<uint>? itemIds))
|
||||||
|
itemIds.Add(item.RowId);
|
||||||
|
else
|
||||||
|
_itemNamesToIds.Add(name, new HashSet<uint>{item.RowId});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashSet<uint> GetItemIdFromItemName(string name) => _itemNamesToIds[name];
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user