-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathPersistentData.cs
More file actions
53 lines (40 loc) · 994 Bytes
/
PersistentData.cs
File metadata and controls
53 lines (40 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Newtonsoft.Json.Linq;
using Terraria;
using Terraria.IO;
using Terraria.ModLoader;
namespace CalRemix;
public sealed class PersistentData : ILoadable
{
private static readonly Preferences data = new(Path.Combine(Main.SavePath, "remix", "persist.json"));
private static List<string> helpers = [];
void ILoadable.Load(Mod mod)
{
data.Load();
helpers = data.Get<JArray>(nameof(helpers), []).Select(x => x.ToString()).ToList();
}
void ILoadable.Unload()
{
Save();
}
private static void Save()
{
data.Put(nameof(helpers), helpers);
data.Save();
}
public static void UnlockHelper(string helper)
{
if (helpers.Contains(helper))
{
return;
}
helpers.Add(helper);
Save();
}
public static List<string> GetHelpers()
{
return helpers;
}
}