fix(breaking): better handling of the server rotation config

The config path was also changed to `BepInEx/config/GBSU/config.json`

Tracks the -maplist argument
This commit is contained in:
anavoi 2025-07-13 23:32:42 +02:00
commit 8132f69ed2
8 changed files with 69 additions and 14 deletions

35
Patches/ConfigLoader.cs Normal file
View file

@ -0,0 +1,35 @@
using System;
using System.IO;
using GB.Config;
using GBSU.Addons;
using HarmonyLib;
using Newtonsoft.Json;
namespace GBSU.Patches;
[HarmonyPatch]
class ConfigLoaderPatch
{
[HarmonyPatch(typeof(GBConfigLoader), "LoadRotationConfig")]
private static bool Prefix(ref RotationConfig __result)
{
string text = ""; // contents of file
Plugin.Log.LogInfo("Loading custom rotation config...");
// Reading from file
try
{
text = File.ReadAllText(Helper.GameConfigPath);
Plugin.Log.LogDebug("Provided rotation config:\n" + text);
RotationConfig rc = JsonConvert.DeserializeObject<RotationConfig>(text);
__result = rc;
}
catch (Exception e)
{
GBSUGui.PushError("Couldn't read game config file. A few details:\n" + e);
}
return false; // skip
}
}