diff --git a/MultiAdmin/Config/Config.cs b/MultiAdmin/Config/Config.cs index 5adde3b..6778c33 100644 --- a/MultiAdmin/Config/Config.cs +++ b/MultiAdmin/Config/Config.cs @@ -69,7 +69,7 @@ public bool Contains(string key) rawData.Any(entry => entry.StartsWith($"{key}:", StringComparison.CurrentCultureIgnoreCase)); } - private static string CleanValue(string value) + private static string CleanValue(string value, bool removeQuotes = true) { if (string.IsNullOrEmpty(value)) return value; @@ -77,7 +77,7 @@ private static string CleanValue(string value) try { - if (newValue.StartsWith("\"") && newValue.EndsWith("\"")) + if (removeQuotes && newValue.StartsWith("\"") && newValue.EndsWith("\"")) return newValue.Substring(1, newValue.Length - 2); } catch (Exception e) @@ -88,7 +88,7 @@ private static string CleanValue(string value) return newValue; } - public string GetString(string key, string def = null) + public string GetString(string key, string def = null, bool removeQuotes = true) { try { @@ -98,7 +98,7 @@ public string GetString(string key, string def = null) try { - return CleanValue(line.Substring(key.Length + 1)); + return CleanValue(line.Substring(key.Length + 1), removeQuotes); } catch (Exception e) { @@ -118,13 +118,13 @@ public string[] GetStringArray(string key, string[] def = null) { try { - foreach (string line in rawData) - { - if (!line.ToLower().StartsWith(key.ToLower() + ":")) continue; + string value = GetString(key, removeQuotes: false); + if (!string.IsNullOrEmpty(value)) + { try { - return line.Substring(key.Length + 1).Split(',').Select(CleanValue).ToArray(); + return value.Split(',').Select(entry => CleanValue(entry)).ToArray(); } catch (Exception e) {