mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 20:33:40 +01:00
Create DailyLifeDutyPlugin for AU Dalamud.
This commit is contained in:
parent
d6ffe6fcdc
commit
06fea85be3
3 changed files with 95 additions and 0 deletions
|
|
@ -33,6 +33,7 @@ internal class FoolsManager : IDisposable, IServiceType
|
||||||
new("Test Fool Plugin", "TestFoolPlugin", "this is a test", "NotNite", typeof(TestFoolPlugin)),
|
new("Test Fool Plugin", "TestFoolPlugin", "this is a test", "NotNite", typeof(TestFoolPlugin)),
|
||||||
new("Pixel Imperfect", "PixelImperfectPlugin", "Whoops... we messed up the math on that one.", "Halpo",
|
new("Pixel Imperfect", "PixelImperfectPlugin", "Whoops... we messed up the math on that one.", "Halpo",
|
||||||
typeof(PixelImperfectPlugin)),
|
typeof(PixelImperfectPlugin)),
|
||||||
|
new("DailyLifeDuty", "DailyLifeDutyPlugin", "Easily Track Daily and Weekly tasks... in real life", "MidoriKami", typeof(DailyLifeDutyPlugin)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
32
Dalamud/Fools/Helper/Chat.cs
Normal file
32
Dalamud/Fools/Helper/Chat.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
using Dalamud.Game.Gui;
|
||||||
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
|
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||||
|
|
||||||
|
namespace Dalamud.Fools.Helper;
|
||||||
|
|
||||||
|
// Copied from KamiLib's Chat
|
||||||
|
// https://github.com/MidoriKami/KamiLib/blob/master/ChatCommands/Chat.cs
|
||||||
|
internal static class Chat
|
||||||
|
{
|
||||||
|
public static void Print(string pluginName, string tag, string message) => Service<ChatGui>.Get().Print(GetBaseString(pluginName, tag, message).BuiltString);
|
||||||
|
|
||||||
|
private static SeStringBuilder GetBaseString(string pluginName, string tag, string message, DalamudLinkPayload? payload = null)
|
||||||
|
{
|
||||||
|
if (payload is null)
|
||||||
|
{
|
||||||
|
return new SeStringBuilder()
|
||||||
|
.AddUiForeground($"[{pluginName}] ", 45)
|
||||||
|
.AddUiForeground($"[{tag}] ", 62)
|
||||||
|
.AddText(message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new SeStringBuilder()
|
||||||
|
.AddUiForeground($"[{pluginName}] ", 45)
|
||||||
|
.AddUiForeground($"[{tag}] ", 62)
|
||||||
|
.Add(payload)
|
||||||
|
.AddUiForeground(message, 35)
|
||||||
|
.Add(RawPayload.LinkTerminator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
62
Dalamud/Fools/Plugins/DailyLifeDutyPlugin.cs
Normal file
62
Dalamud/Fools/Plugins/DailyLifeDutyPlugin.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using Dalamud.Fools.Helper;
|
||||||
|
using Dalamud.Game;
|
||||||
|
|
||||||
|
namespace Dalamud.Fools.Plugins;
|
||||||
|
|
||||||
|
public class DailyLifeDutyPlugin : IFoolsPlugin
|
||||||
|
{
|
||||||
|
private const string PluginName = "DailyLifeDuty";
|
||||||
|
|
||||||
|
private static readonly List<Duty> Duties = new[]
|
||||||
|
{
|
||||||
|
new Duty("Dishes", i => $"{i} dishes to be cleaned"),
|
||||||
|
new Duty("Taxes", _ => "Taxes need to be filed"),
|
||||||
|
new Duty("Pets", i => $"{i} dogs waiting to be pet"),
|
||||||
|
new Duty("Garbage", i => $"{i} garbage bags to be put out"),
|
||||||
|
}.ToList();
|
||||||
|
|
||||||
|
private long lastMessage;
|
||||||
|
|
||||||
|
public DailyLifeDutyPlugin()
|
||||||
|
{
|
||||||
|
Service<Framework>.Get().Update += this.OnUpdate;
|
||||||
|
this.EmitDutyReminder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Service<Framework>.Get().Update -= this.OnUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnUpdate(Framework framework)
|
||||||
|
{
|
||||||
|
if (DateTimeOffset.UtcNow.ToUnixTimeSeconds() - this.lastMessage > 60 * 5)
|
||||||
|
{
|
||||||
|
this.EmitDutyReminder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EmitDutyReminder()
|
||||||
|
{
|
||||||
|
var duty = Duties[Random.Shared.Next(Duties.Count)];
|
||||||
|
Chat.Print(PluginName, duty.Tag, duty.Message(Random.Shared.Next(20)));
|
||||||
|
this.lastMessage = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Duty
|
||||||
|
{
|
||||||
|
public Duty(string tag, Func<int, string> message)
|
||||||
|
{
|
||||||
|
this.Tag = tag;
|
||||||
|
this.Message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string Tag { get; init; }
|
||||||
|
|
||||||
|
internal Func<int, string> Message { get; init; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue