@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Content.Server.Administration.Logs.Converters;
|
||||
|
||||
public abstract class AdminLogConverter<T> : JsonConverter<T>
|
||||
{
|
||||
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public abstract override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Administration.Logs.Converters;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
[BaseTypeRequired(typeof(AdminLogConverter<>))]
|
||||
public class AdminLogConverterAttribute : Attribute
|
||||
{
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using System.Text.Json;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.Administration.Logs.Converters;
|
||||
|
||||
[AdminLogConverter]
|
||||
public class EntityJsonConverter : AdminLogConverter<Entity>
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, Entity value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteNumber("id", (int) value.Uid);
|
||||
writer.WriteString("name", value.Name);
|
||||
|
||||
if (_entities.TryGetComponent(value.Uid, out ActorComponent? actor))
|
||||
{
|
||||
writer.WriteString("player", actor.PlayerSession.UserId.UserId);
|
||||
}
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.Text.Json;
|
||||
using Content.Shared.FixedPoint;
|
||||
|
||||
namespace Content.Server.Administration.Logs.Converters;
|
||||
|
||||
[AdminLogConverter]
|
||||
public class FixedPoint2Converter : AdminLogConverter<FixedPoint2>
|
||||
{
|
||||
public override void Write(Utf8JsonWriter writer, FixedPoint2 value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteNumberValue(value.Int());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user