public static TModConfig LoadOrCreateConfig <TModConfig>(this ICoreAPI api, object caller, bool required = false) where TModConfig : ModConfigBase, new() { var modCode = new TModConfig().ModCode; if (string.IsNullOrEmpty(modCode)) { modCode = ModConfigBase.GetModCode(caller); } return(LoadOrCreateConfig <TModConfig>(api, modCode + ".json", required)); }
public static void SaveConfig <TModConfig>(this ICoreAPI api, TModConfig config) where TModConfig : ModConfigBase { var filename = config.ModCode; if (string.IsNullOrEmpty(filename)) { filename = ModConfigBase.GetModCode(config); } if (!filename.EndsWith(".json")) { filename += ".json"; } api.World.Logger.Notification($"Saving modconfig at 'ModConfig/{filename}'..."); api.StoreModConfig(config, filename); }
public void Save(ICoreAPI api, string filename = default) { if (string.IsNullOrEmpty(filename)) { filename = this.ModCode; } if (string.IsNullOrEmpty(filename)) { filename = ModConfigBase.GetModCode(this); } if (!filename.EndsWith(".json")) { filename += ".json"; } api.World.Logger.Notification($"Saving modconfig at 'ModConfig/{filename}'..."); api.StoreModConfig(this, filename); }