From db2219af3ba350bcb238fece92545b60fee7ccfb Mon Sep 17 00:00:00 2001
From: Yamato <66829532+louis1706@users.noreply.github.com>
Date: Mon, 29 Sep 2025 14:56:57 +0200
Subject: [PATCH 1/3] Nullable Vector3 from PR on ExSLMod#47
taken from https://github.com/ExSLMod-Team/EXILED/pull/47
---
.../CustomConverters/VectorsConverter.cs | 39 ++++++++++++++++---
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/EXILED/Exiled.Loader/Features/Configs/CustomConverters/VectorsConverter.cs b/EXILED/Exiled.Loader/Features/Configs/CustomConverters/VectorsConverter.cs
index 944e2f2784..63f413247d 100644
--- a/EXILED/Exiled.Loader/Features/Configs/CustomConverters/VectorsConverter.cs
+++ b/EXILED/Exiled.Loader/Features/Configs/CustomConverters/VectorsConverter.cs
@@ -12,6 +12,7 @@ namespace Exiled.Loader.Features.Configs.CustomConverters
using System.Globalization;
using System.IO;
+ using Exiled.API.Features;
using Exiled.API.Features.Pools;
using UnityEngine;
@@ -21,18 +22,37 @@ namespace Exiled.Loader.Features.Configs.CustomConverters
using YamlDotNet.Serialization;
///
- /// Converts a Vector2, Vector3 or Vector4 to Yaml configs and vice versa.
+ /// Converts a Vector2, Vector3 or Vector4 (including nullable) to Yaml configs and vice versa.
///
public sealed class VectorsConverter : IYamlTypeConverter
{
///
- public bool Accepts(Type type) => type == typeof(Vector2) || type == typeof(Vector3) || type == typeof(Vector4);
+ public bool Accepts(Type type)
+ {
+ Type baseType = Nullable.GetUnderlyingType(type) ?? type;
+ return baseType == typeof(Vector2) || baseType == typeof(Vector3) || baseType == typeof(Vector4);
+ }
///
public object ReadYaml(IParser parser, Type type)
{
+ Type baseType = Nullable.GetUnderlyingType(type) ?? type;
+
+ if (parser.TryConsume(out Scalar scalar))
+ {
+ if (string.IsNullOrEmpty(scalar.Value) || scalar.Value.Equals("null", StringComparison.OrdinalIgnoreCase))
+ {
+ if (Nullable.GetUnderlyingType(type) != null)
+ return null;
+
+ Log.Error($"Cannot assign null to non-nullable type {baseType.FullName}.");
+ }
+
+ Log.Error($"Expected mapping, but got scalar: {scalar.Value}");
+ }
+
if (!parser.TryConsume(out _))
- throw new InvalidDataException($"Cannot deserialize object of type {type.FullName}.");
+ Log.Error($"Cannot deserialize object of type {type.FullName}.");
List