-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Server.cs
77 lines (55 loc) · 2.36 KB
/
Server.cs
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using BepInEx;
using BepInEx.Configuration;
using BloodyShop.DB;
using BloodyShop.Server.DB;
using BloodyShop.Server.Systems;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace BloodyShop.Server
{
public class ServerMod
{
public static ConfigEntry<bool> ShopEnabled;
public static ConfigEntry<int> CurrencyGUID;
public static readonly string ConfigPath = Path.Combine(Paths.ConfigPath, "BloodyShop");
public static readonly string DropSystemPath = Path.Combine(ConfigPath, "DropSystem");
public static string ProductListFile = Path.Combine(ConfigPath, "products_list.json");
public static string CurrencyListFile = Path.Combine(ConfigPath, "currency_list.json");
public static string UserCurrenciesPerDayFile = Path.Combine(ConfigPath, "user_currencies_per_day.json");
public static void CreateFilesConfig()
{
if (!Directory.Exists(ConfigPath)) Directory.CreateDirectory(ConfigPath);
if (!File.Exists(ProductListFile)) File.WriteAllText(ProductListFile, "[]");
if (!File.Exists(CurrencyListFile)) File.WriteAllText(CurrencyListFile, "[{\"id\":1,\"name\":\"Silver Coin\",\"guid\":-949672483}]");
if (!Directory.Exists(DropSystemPath)) Directory.CreateDirectory(DropSystemPath);
if (!File.Exists(UserCurrenciesPerDayFile)) File.WriteAllText(UserCurrenciesPerDayFile, "");
}
public static void LoadConfigToDB()
{
if (!LoadDataFromFiles.loadProductList())
{
Plugin.Logger.LogError($"Error loading ProductList");
}
}
public static void LoadCurrenciesToDB()
{
if (!LoadDataFromFiles.loadCurrencies())
{
Plugin.Logger.LogError($"Error loading CurrenciesList");
}
}
public static void SetConfigMod()
{
ConfigDB.ShopEnabled = Plugin.ShopEnabled.Value;
ConfigDB.AnnounceAddRemovePublic = Plugin.AnnounceAddRemovePublic.Value;
ConfigDB.AnnounceBuyPublic = Plugin.AnnounceBuyPublic.Value;
var _storeName = Plugin.StoreName.Value;
if (_storeName != string.Empty)
{
ConfigDB.StoreName = _storeName;
}
}
}
}