File tree Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public void Load()
29
29
}
30
30
31
31
var jsonData = File . ReadAllText ( _mapConfigPath ) ;
32
- _mapConfigData = JsonSerializer . Deserialize < MapConfigData > ( jsonData ) ;
32
+ _mapConfigData = JsonSerializer . Deserialize < MapConfigData > ( jsonData , Helpers . JsonSerializerOptions ) ;
33
33
34
34
// TODO: Implement validation to make sure the config is valid / has enough spawns.
35
35
// if (_mapConfigData!.Spawns == null || _mapConfigData.Spawns.Count < 0)
@@ -119,10 +119,7 @@ private MapConfigData GetSanitisedMapConfigData()
119
119
120
120
private void Save ( )
121
121
{
122
- var jsonString = JsonSerializer . Serialize ( GetSanitisedMapConfigData ( ) , new JsonSerializerOptions
123
- {
124
- WriteIndented = true
125
- } ) ;
122
+ var jsonString = JsonSerializer . Serialize ( GetSanitisedMapConfigData ( ) , Helpers . JsonSerializerOptions ) ;
126
123
127
124
try
128
125
{
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ public void Load()
25
25
}
26
26
27
27
var jsonData = File . ReadAllText ( _retakesConfigPath ) ;
28
- RetakesConfigData = JsonSerializer . Deserialize < RetakesConfigData > ( jsonData ) ;
28
+ RetakesConfigData = JsonSerializer . Deserialize < RetakesConfigData > ( jsonData , Helpers . JsonSerializerOptions ) ;
29
29
30
30
if ( RetakesConfigData == null )
31
31
{
@@ -54,10 +54,7 @@ public void Load()
54
54
55
55
private void Save ( )
56
56
{
57
- var jsonString = JsonSerializer . Serialize ( RetakesConfigData , new JsonSerializerOptions
58
- {
59
- WriteIndented = true
60
- } ) ;
57
+ var jsonString = JsonSerializer . Serialize ( RetakesConfigData , Helpers . JsonSerializerOptions ) ;
61
58
62
59
try
63
60
{
Original file line number Diff line number Diff line change 1
1
using System . Drawing ;
2
2
using System . Text ;
3
+ using System . Text . Json ;
3
4
using CounterStrikeSharp . API ;
4
5
using CounterStrikeSharp . API . Core ;
5
6
using CounterStrikeSharp . API . Modules . Entities . Constants ;
6
7
using CounterStrikeSharp . API . Modules . Utils ;
7
8
using RetakesPlugin . Modules . Configs ;
9
+ using RetakesPlugin . Modules . Configs . JsonConverters ;
8
10
using RetakesPluginShared . Enums ;
9
11
10
12
namespace RetakesPlugin . Modules ;
11
13
12
14
public static class Helpers
13
15
{
14
16
internal static readonly Random Random = new ( ) ;
17
+ internal static readonly JsonSerializerOptions JsonSerializerOptions = new ( )
18
+ {
19
+ WriteIndented = true ,
20
+ Converters =
21
+ {
22
+ new VectorJsonConverter ( ) ,
23
+ new QAngleJsonConverter ( )
24
+ }
25
+ } ;
15
26
16
27
public static bool IsValidPlayer ( CCSPlayerController ? player )
17
28
{
You can’t perform that action at this time.
0 commit comments