Cuberite
A lightweight, fast and extensible game server for Minecraft
StatisticsManager.h
Go to the documentation of this file.
1 
2 // Statistics.h
3 
4 /* Hello fellow developer !
5 In case you are trying to add new statistics to Cuberite you need to do a few things:
6 ---------------------------------------------------------------------------
7 1. add a new entry to the enum class Statistic in Registries\Statistics.h file
8 2. add this to serialization functions in WorldStorage\NamespaceSerializer.cpp
9  The String in the above is used for saving on disk!
10  so use the same string!
11 
12 In case you want to add a mapping of network IDs to the used stats
13 you will find a lua script in ../Tools/BlockTypePaletteGenerator/ExportStatMapping.lua
14 it will provide you with information how to use it. you need a registries.json
15 exported from the server https://wiki.vg/Data_Generators
16 
17  Greetings 12xx12 */
18 
19 
20 
21 
22 
23 #pragma once
24 
26 
27 
28 
29 
30 
33 {
34  typedef unsigned StatValue;
35 
36  // TODO: Block tallies, entities killed, all the others
37 
38  std::unordered_map<CustomStatistic, StatValue> Custom;
39 
41  bool SatisfiesPrerequisite(CustomStatistic a_Stat) const;
42 
43 private:
44 
46  bool IsStatisticPresent(CustomStatistic a_Stat) const;
47 };
CustomStatistic
Class that manages the statistics and achievements of a single player.
bool SatisfiesPrerequisite(CustomStatistic a_Stat) const
Returns whether the prerequisite for awarding an achievement are satisfied.
bool IsStatisticPresent(CustomStatistic a_Stat) const
Returns if a statistic is both present and has nonzero value.
std::unordered_map< CustomStatistic, StatValue > Custom