Fixed some errors on SettingsDictionary
This commit is contained in:
@@ -32,6 +32,10 @@ public class Config
|
||||
Directory.CreateDirectory("./Data/Logs");
|
||||
|
||||
AppSettings = new SettingsDictionary<string, string>("./Data/Resources/config.json");
|
||||
bool response = await AppSettings.LoadFromFile();
|
||||
|
||||
if (!response)
|
||||
throw new Exception("Invalid config file");
|
||||
|
||||
AppSettings["LogFolder"] = "./Data/Logs";
|
||||
AppSettings["PluginFolder"] = "./Data/Plugins";
|
||||
@@ -39,8 +43,11 @@ public class Config
|
||||
|
||||
AppSettings["PluginDatabase"] = "./Data/Resources/plugins.json";
|
||||
|
||||
|
||||
ArchiveManager.Initialize();
|
||||
|
||||
|
||||
|
||||
if (!File.Exists(AppSettings["PluginDatabase"]))
|
||||
{
|
||||
List<PluginInfo> plugins = new();
|
||||
@@ -50,14 +57,14 @@ public class Config
|
||||
Logger = new Logger(false, true, AppSettings["LogFolder"] + $"/{DateTime.Today.ToShortDateString().Replace("/", "")}.log");
|
||||
|
||||
|
||||
_isLoaded = true;
|
||||
|
||||
PluginsManager = new PluginsManager("releases");
|
||||
|
||||
await PluginsManager.UninstallMarkedPlugins();
|
||||
|
||||
await PluginsManager.CheckForUpdates();
|
||||
|
||||
_isLoaded = true;
|
||||
|
||||
Logger.Log("Config initialized", typeof(Config));
|
||||
|
||||
}
|
||||
|
||||
@@ -13,11 +13,6 @@ public class SettingsDictionary<TKey, TValue>: IDictionary<TKey, TValue>
|
||||
public SettingsDictionary(string? file)
|
||||
{
|
||||
_file = file;
|
||||
if (!LoadFromFile())
|
||||
{
|
||||
_dictionary = new Dictionary<TKey, TValue>();
|
||||
SaveToFile();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SaveToFile()
|
||||
@@ -26,7 +21,7 @@ public class SettingsDictionary<TKey, TValue>: IDictionary<TKey, TValue>
|
||||
await JsonManager.SaveToJsonFile(_file, _dictionary);
|
||||
}
|
||||
|
||||
private bool LoadFromFile()
|
||||
public async Task<bool> LoadFromFile()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_file))
|
||||
try
|
||||
@@ -42,7 +37,9 @@ public class SettingsDictionary<TKey, TValue>: IDictionary<TKey, TValue>
|
||||
}
|
||||
else
|
||||
File.WriteAllText(_file, "{}");
|
||||
_dictionary = JsonManager.ConvertFromJson<IDictionary<TKey, TValue>>(_file).Result;
|
||||
|
||||
|
||||
_dictionary = await JsonManager.ConvertFromJson<IDictionary<TKey, TValue>>(_file);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.1.32421.90
|
||||
@@ -9,11 +8,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginManager", "PluginMana
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SethPlugins", "SethPlugins", "{78B6D390-F61A-453F-B38D-E4C054321615}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MusicPlayer", "..\SethPlugins\MusicPlayer\MusicPlayer.csproj", "{1690CBBC-BDC0-4DD8-B701-F8817189D9D5}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MusicPlayer", "..\SethPlugins\MusicPlayer\MusicPlayer.csproj", "{1690CBBC-BDC0-4DD8-B701-F8817189D9D5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LevelingSystem", "..\SethPlugins\LevelingSystem\LevelingSystem.csproj", "{BFE3491C-AC01-4252-B242-6451270FC548}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LevelingSystem", "..\SethPlugins\LevelingSystem\LevelingSystem.csproj", "{BFE3491C-AC01-4252-B242-6451270FC548}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonCompatibilityLayer", "..\SethPlugins\PythonCompatibilityLayer\PythonCompatibilityLayer.csproj", "{81ED4953-13E5-4950-96A8-8CEF5FD59559}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PythonCompatibilityLayer", "..\SethPlugins\PythonCompatibilityLayer\PythonCompatibilityLayer.csproj", "{81ED4953-13E5-4950-96A8-8CEF5FD59559}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscordBotUI", "DiscordBotUI\DiscordBotUI.csproj", "{1E781CB6-3EAF-425D-9913-4FE879B1D633}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -41,6 +42,10 @@ Global
|
||||
{81ED4953-13E5-4950-96A8-8CEF5FD59559}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{81ED4953-13E5-4950-96A8-8CEF5FD59559}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{81ED4953-13E5-4950-96A8-8CEF5FD59559}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1E781CB6-3EAF-425D-9913-4FE879B1D633}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1E781CB6-3EAF-425D-9913-4FE879B1D633}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1E781CB6-3EAF-425D-9913-4FE879B1D633}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1E781CB6-3EAF-425D-9913-4FE879B1D633}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user