Repository navigation
Expand file tree
/
Copy pathAutoRetainerDetector.cs
More file actions
58 lines (51 loc) · 1.86 KB
/
Copy pathAutoRetainerDetector.cs
File metadata and controls
58 lines (51 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using Dalamud.Interface.ImGuiNotification;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using Restocker.Localization;
namespace Restocker;
/// <summary>
/// AutoRetainer プラグインがロードされているかを起動時に検出し、
/// もし併用なら「巡回が衝突するかも」とトースト警告を 1 回だけ出す。
/// ブロックはせず、あくまで通知のみ(ユーザー設計判断)。
/// </summary>
public sealed class AutoRetainerDetector
{
private readonly IDalamudPluginInterface pluginInterface;
private readonly INotificationManager notifications;
private readonly IPluginLog log;
private bool warned;
public AutoRetainerDetector(
IDalamudPluginInterface pluginInterface,
INotificationManager notifications,
IPluginLog log)
{
this.pluginInterface = pluginInterface;
this.notifications = notifications;
this.log = log;
}
/// <summary>AutoRetainer が同居していたら 1 度だけトーストで警告する。</summary>
public void WarnIfPresent()
{
if (warned) return;
if (!IsAutoRetainerLoaded()) return;
warned = true;
log.Info("[Restocker] AutoRetainer detected; both manage retainer summon flow — coordinate manually.");
notifications.AddNotification(new Notification
{
Title = Strings.WindowTitle,
Content = Strings.ToastAutoRetainerPresent,
Type = NotificationType.Warning,
InitialDuration = TimeSpan.FromSeconds(8),
});
}
public bool IsAutoRetainerLoaded()
{
foreach (var p in pluginInterface.InstalledPlugins)
{
if (p.IsLoaded && string.Equals(p.InternalName, "AutoRetainer", StringComparison.OrdinalIgnoreCase))
return true;
}
return false;
}
}