-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66c6bbc
commit c03d497
Showing
8 changed files
with
162 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using SpaceWarp.API.Managers; | ||
using Newtonsoft.Json; | ||
|
||
namespace SpaceWarp.API.Configuration | ||
{ | ||
public class ConfigurationManager | ||
public class ConfigurationManager : Manager | ||
{ | ||
public static readonly Dictionary<string, (Type configType, object configObject)> ModConfigurations = new Dictionary<string, (Type configType, object configObject)>(); | ||
|
||
private readonly Dictionary<string, (Type configType, object configObject, string path)> ModConfigurations = new Dictionary<string, (Type configType, object configObject, string path)>(); | ||
public void Add(string id, (Type configType, object configObject, string path) configuration) | ||
{ | ||
if (ModConfigurations.ContainsKey(id)) return; | ||
ModConfigurations[id] = configuration; | ||
} | ||
|
||
public bool TryGet(string id, out (Type configType, object configObject, string path) config) | ||
{ | ||
return ModConfigurations.TryGetValue(id, out config); | ||
} | ||
|
||
public void UpdateConfiguration(string id) | ||
{ | ||
if (!ModConfigurations.TryGetValue(id, out (Type, object, string) config)) | ||
return; | ||
// Saves the new configuration | ||
File.WriteAllText(config.Item3,JsonConvert.SerializeObject(config.Item2)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters