mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
change role color handling
This commit is contained in:
1 parent
5bd5b608ec
commit
07296ed616
1 file changed
+7
-3
@@ -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); }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user