Minecraft-Console-Client/MinecraftClient/Mcp/MccMcpRecentEventStore.cs

45 lines
1.2 KiB
C#
Raw Permalink Normal View History

2026-03-30 23:14:28 +02:00
using System;
using System.Linq;
using MinecraftClient.Scripting;
2026-03-30 23:14:28 +02:00
namespace MinecraftClient.Mcp;
public sealed class MccMcpRecentEventEntry
{
public required long Id { get; init; }
public required DateTimeOffset TimestampUtc { get; init; }
public required string Type { get; init; }
public object? Data { get; init; }
}
public static class MccMcpRecentEventStore
{
public static long Add(string type, object? data = null)
{
return MccObservedStateStore.AddRecentEvent(type, data);
2026-03-30 23:14:28 +02:00
}
public static long GetLatestId()
{
return MccObservedStateStore.GetLatestRecentEventId();
2026-03-30 23:14:28 +02:00
}
public static MccMcpRecentEventEntry[] GetAfter(long afterId, int maxCount, string? typeFilter = null)
{
return MccObservedStateStore.GetRecentEventsAfter(afterId, maxCount, typeFilter)
.Select(entry => new MccMcpRecentEventEntry
{
Id = entry.Id,
TimestampUtc = entry.TimestampUtc,
Type = entry.Type,
Data = entry.Data
})
.ToArray();
2026-03-30 23:14:28 +02:00
}
public static void Clear()
{
MccObservedStateStore.ClearRecentEvents();
2026-03-30 23:14:28 +02:00
}
}