change role color handling

This commit is contained in:
Gurge44 committed 2026-04-07 08:40:35 +02:00
1 parent 5bd5b608ec
commit 07296ed616
1 file changed
+7 -3
+7 -3
View File
@@ -930,9 +930,13 @@ public class Main : BasePlugin
try
{
string json = File.ReadAllText(path);
if (string.IsNullOrWhiteSpace(json) || json == serialized || json.Length < serialized.Length) return;
var deserialized = JsonSerializer.Deserialize<Dictionary<string, string>>(json);
RoleColors = deserialized.ToDictionary(x => Enum.Parse<CustomRoles>(x.Key), x => x.Value);
if (string.IsNullOrWhiteSpace(json) || json == serialized) return;
foreach ((string roleName, string hex) in JsonSerializer.Deserialize<Dictionary<string, string>>(json) ?? [])
{
if (!Enum.TryParse(roleName, true, out CustomRoles role)) continue;
RoleColors[role] = hex;
}
}
catch (Exception e) { Utils.ThrowException(e); }
}