Cuberite
A lightweight, fast and extensible game server for Minecraft
StatSerializer.h
Go to the documentation of this file.
1 
2 // StatSerializer.h
3 
4 // Declares the cStatSerializer class that is used for saving stats into JSON
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "json/json.h"
13 
14 
15 
16 
17 
18 // fwd:
19 class cStatManager;
20 
21 
22 
23 
25 {
26 public:
27 
28  cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, const AString & a_FileName, cStatManager * a_Manager);
29 
30  /* Try to load the player statistics. Returns whether the operation was successful or not. */
31  bool Load(void);
32 
33  /* Try to save the player statistics. Returns whether the operation was successful or not. */
34  bool Save(void);
35 
36 
37 protected:
38 
39  void SaveStatToJSON(Json::Value & a_Out);
40 
41  bool LoadStatFromJSON(const Json::Value & a_In);
42 
43 
44 private:
45 
47 
48  AString m_LegacyPath; // The old <username>.json path to try to read from if the uuid path doesn't exist on load
50 
51 
52 } ;
53 
54 
55 
56 
Class that manages the statistics and achievements of a single player.
Definition: Statistics.h:127
AString m_LegacyPath
bool LoadStatFromJSON(const Json::Value &a_In)
cStatSerializer(const AString &a_WorldName, const AString &a_PlayerName, const AString &a_FileName, cStatManager *a_Manager)
cStatManager * m_Manager
std::string AString
Definition: StringUtils.h:13
void SaveStatToJSON(Json::Value &a_Out)