qstcompanion v1.0.1
This commit is contained in:
parent
3e10cbbbf2
commit
44c67ab71b
79 changed files with 21148 additions and 0 deletions
|
|
@ -0,0 +1,87 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
|
||||
namespace QuestionableCompanion.Services;
|
||||
|
||||
public class QuestTrackingService : IDisposable
|
||||
{
|
||||
private readonly IPluginLog log;
|
||||
|
||||
private readonly Dictionary<string, HashSet<uint>> characterQuestCache = new Dictionary<string, HashSet<uint>>();
|
||||
|
||||
public QuestTrackingService(IPluginLog log)
|
||||
{
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
public HashSet<uint> GetCharacterCompletedQuests(string characterName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(characterName))
|
||||
{
|
||||
return new HashSet<uint>();
|
||||
}
|
||||
if (characterQuestCache.TryGetValue(characterName, out HashSet<uint> quests))
|
||||
{
|
||||
return quests;
|
||||
}
|
||||
return new HashSet<uint>();
|
||||
}
|
||||
|
||||
public void UpdateCurrentCharacterQuests(string characterName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(characterName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
HashSet<uint> completedQuests = new HashSet<uint>();
|
||||
for (uint questId = 66000u; questId < 72000; questId++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (QuestManager.IsQuestComplete(questId))
|
||||
{
|
||||
completedQuests.Add(questId);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
characterQuestCache[characterName] = completedQuests;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error("[QuestTracking] Failed to update quests for " + characterName + ": " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsQuestCompleted(string characterName, uint questId)
|
||||
{
|
||||
return GetCharacterCompletedQuests(characterName).Contains(questId);
|
||||
}
|
||||
|
||||
public void ClearCharacterCache(string characterName)
|
||||
{
|
||||
if (characterQuestCache.ContainsKey(characterName))
|
||||
{
|
||||
characterQuestCache.Remove(characterName);
|
||||
log.Debug("[QuestTracking] Cleared cache for " + characterName);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearAllCache()
|
||||
{
|
||||
characterQuestCache.Clear();
|
||||
log.Information("[QuestTracking] Cleared all cached quest data");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
characterQuestCache.Clear();
|
||||
log.Information("[QuestTracking] Service disposed");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue