2026-03-30 23:14:28 +02:00
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2026-04-03 19:06:43 +02:00
|
|
|
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)
|
|
|
|
|
{
|
2026-04-03 19:06:43 +02:00
|
|
|
return MccObservedStateStore.AddRecentEvent(type, data);
|
2026-03-30 23:14:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static long GetLatestId()
|
|
|
|
|
{
|
2026-04-03 19:06:43 +02:00
|
|
|
return MccObservedStateStore.GetLatestRecentEventId();
|
2026-03-30 23:14:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static MccMcpRecentEventEntry[] GetAfter(long afterId, int maxCount, string? typeFilter = null)
|
|
|
|
|
{
|
2026-04-03 19:06:43 +02:00
|
|
|
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()
|
|
|
|
|
{
|
2026-04-03 19:06:43 +02:00
|
|
|
MccObservedStateStore.ClearRecentEvents();
|
2026-03-30 23:14:28 +02:00
|
|
|
}
|
|
|
|
|
}
|