Support player sessions in admin logs and add test

Fix EventRan log type id
Make slipping low impact
This commit is contained in:
DrSmugleaf
2021-11-22 23:15:22 +01:00
parent ce94c28e8a
commit 7b5878b846
6 changed files with 170 additions and 65 deletions

View File

@@ -0,0 +1,33 @@
using System.Text.Json;
using Robust.Server.Player;
namespace Content.Server.Administration.Logs.Converters;
[AdminLogConverter]
public class PlayerSessionConverter : AdminLogConverter<SerializablePlayer>
{
public override void Write(Utf8JsonWriter writer, SerializablePlayer value, JsonSerializerOptions options)
{
writer.WriteStartObject();
if (value.Player.AttachedEntity != null)
{
writer.WriteNumber("id", (int) value.Player.AttachedEntity.Uid);
writer.WriteString("name", value.Player.AttachedEntity.Name);
}
writer.WriteString("player", value.Player.UserId.UserId);
writer.WriteEndObject();
}
}
public readonly struct SerializablePlayer
{
public readonly IPlayerSession Player;
public SerializablePlayer(IPlayerSession player)
{
Player = player;
}
}