Include a version number in config, to track if it needs automatic migrations.

This commit is contained in:
zontreck 2025-03-07 01:22:25 -07:00
parent 2efa532059
commit a3eee94f7e
3 changed files with 15 additions and 13 deletions

View file

@ -22,28 +22,24 @@ namespace AriasServerUtils
{ CooldownType.RTP, "30s" },
{ CooldownType.Back, "5s" }
};
private static readonly int CURRENT_VERSION = 3;
public int Version { get; set; } = 0;
public int MaxHomes { get; set; } = 20;
public bool AdminsBypassMaxHomes { get; set; } = true;
public bool onlyAdminsCreateWarps { get; set; } = true;
public int MaxBackCache { get; set; } = 10;
public int PlayerSleepingPercentage { get; set; } = 50;
public int MaxRTPBlockDistance { get; set; } = 5000;
public Dictionary<CooldownType, string> Cooldowns { get; set; } = new Dictionary<CooldownType, string>
{
{ CooldownType.Home, "5s" },
{ CooldownType.Warp, "10s" },
{ CooldownType.Spawn, "5s" },
{ CooldownType.RTP, "30s" },
{ CooldownType.Back, "5s" }
};
public Dictionary<CooldownType, string> Cooldowns { get; set; } = new Dictionary<CooldownType, string>();
public Dictionary<CooldownType, string> GetDefaultCooldowns()
{
return m_defaultCD;
}
public void SanityCheckCooldowns()
public void SanityCheck()
{
foreach (var cd in GetDefaultCooldowns())
{
@ -53,6 +49,12 @@ namespace AriasServerUtils
ServerUtilities.MarkDirty();
}
}
if (Version < CURRENT_VERSION)
{
Version = CURRENT_VERSION;
ServerUtilities.MarkDirty(); // This is here to ensure that the config gets saved when there is a update. Whenever a new field is added to config, the CURRENT_VERSION should get bumped so that this SanityCheck can properly work
}
}