summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-05-04 17:11:56 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2021-05-04 17:11:56 +0200
commit34bf5c0d9db195edf8b576d1273876966cf650b2 (patch)
treeb9682f8226fef09d3625089ba06235f93ce5c976 /src
parentAdd player statistics to API (#5193) (diff)
downloadcuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar
cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.gz
cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.bz2
cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.lz
cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.xz
cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.zst
cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/AllToLua.pkg4
-rw-r--r--src/Bindings/LuaState.h2
-rw-r--r--src/CMakeLists.txt5
-rw-r--r--src/Entities/Player.cpp6
-rw-r--r--src/Entities/Player.h2
-rw-r--r--src/OSSupport/CMakeLists.txt1
-rw-r--r--src/OSSupport/Stopwatch.h (renamed from src/Stopwatch.h)0
-rw-r--r--src/Protocol/Palettes/Palette_1_13.h2
-rw-r--r--src/Protocol/Palettes/Palette_1_13_1.h2
-rw-r--r--src/Protocol/Palettes/Palette_1_14.h2
-rw-r--r--src/Protocol/Palettes/Palette_1_15.h2
-rw-r--r--src/Protocol/Palettes/Palette_1_16.h2
-rw-r--r--src/Protocol/Protocol_1_8.h2
-rw-r--r--src/Registries/CMakeLists.txt2
-rw-r--r--src/Registries/CustomStatistics.h (renamed from src/Registries/Statistics.h)0
-rw-r--r--src/StatisticsManager.cpp (renamed from src/Statistics.cpp)2
-rw-r--r--src/StatisticsManager.h (renamed from src/Statistics.h)12
-rw-r--r--src/WorldStorage/CMakeLists.txt4
-rw-r--r--src/WorldStorage/NamespaceSerializer.h2
-rw-r--r--src/WorldStorage/StatisticsSerializer.cpp (renamed from src/WorldStorage/StatSerializer.cpp)8
-rw-r--r--src/WorldStorage/StatisticsSerializer.h (renamed from src/WorldStorage/StatSerializer.h)4
21 files changed, 35 insertions, 31 deletions
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index e6787b70d..1f9636cd0 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -68,7 +68,7 @@ $cfile "../CompositeChat.h"
$cfile "../Map.h"
$cfile "../MapManager.h"
$cfile "../Scoreboard.h"
-$cfile "../Statistics.h"
+$cfile "../StatisticsManager.h"
$cfile "../Protocol/MojangAPI.h"
$cfile "../UUID.h"
@@ -124,7 +124,7 @@ $cfile "../BlockEntities/MobSpawnerEntity.h"
$cfile "../BlockEntities/FlowerPotEntity.h"
// Registries:
-$cfile "../Registries/Statistics.h"
+$cfile "../Registries/CustomStatistics.h"
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index f615ef0a6..6f7a334b6 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -37,7 +37,7 @@ extern "C"
#include "../Defines.h"
#include "../FunctionRef.h"
-#include "../Registries/Statistics.h"
+#include "../Registries/CustomStatistics.h"
#include "PluginManager.h"
#include "LuaState_Typedefs.inc"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e9945fa54..b5dcead39 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -58,7 +58,7 @@ target_sources(
Scoreboard.cpp
Server.cpp
SpawnPrepare.cpp
- Statistics.cpp
+ StatisticsManager.cpp
StringCompression.cpp
StringUtils.cpp
UUID.cpp
@@ -138,8 +138,7 @@ target_sources(
SetChunkData.h
SettingsRepositoryInterface.h
SpawnPrepare.h
- Statistics.h
- Stopwatch.h
+ StatisticsManager.h
StringCompression.h
StringUtils.h
UUID.h
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 1e7c8df98..08adb1096 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -18,7 +18,7 @@
#include "../FastRandom.h"
#include "../ClientHandle.h"
-#include "../WorldStorage/StatSerializer.h"
+#include "../WorldStorage/StatisticsSerializer.h"
#include "../CompositeChat.h"
#include "../Blocks/BlockHandler.h"
@@ -1925,7 +1925,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName)
{
// Load the player stats.
// We use the default world name (like bukkit) because stats are shared between dimensions / worlds.
- StatSerializer::Load(m_Stats, m_DefaultWorldPath, GetUUID().ToLongString());
+ StatisticsSerializer::Load(m_Stats, m_DefaultWorldPath, GetUUID().ToLongString());
}
catch (...)
{
@@ -2059,7 +2059,7 @@ void cPlayer::SaveToDisk()
// Save the player stats.
// We use the default world name (like bukkit) because stats are shared between dimensions / worlds.
// TODO: save together with player.dat, not in some other place.
- StatSerializer::Save(m_Stats, m_DefaultWorldPath, GetUUID().ToLongString());
+ StatisticsSerializer::Save(m_Stats, m_DefaultWorldPath, GetUUID().ToLongString());
}
catch (...)
{
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index e7b18f3b6..987bccbe5 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -7,7 +7,7 @@
#include "../World.h"
#include "../Items/ItemHandler.h"
-#include "../Statistics.h"
+#include "../StatisticsManager.h"
#include "../UUID.h"
diff --git a/src/OSSupport/CMakeLists.txt b/src/OSSupport/CMakeLists.txt
index 742bdcccf..3761913e1 100644
--- a/src/OSSupport/CMakeLists.txt
+++ b/src/OSSupport/CMakeLists.txt
@@ -36,6 +36,7 @@ target_sources(
SleepResolutionBooster.h
StackTrace.h
StartAsService.h
+ Stopwatch.h
TCPLinkImpl.h
UDPEndpointImpl.h
WinStackWalker.h
diff --git a/src/Stopwatch.h b/src/OSSupport/Stopwatch.h
index 7676b3856..7676b3856 100644
--- a/src/Stopwatch.h
+++ b/src/OSSupport/Stopwatch.h
diff --git a/src/Protocol/Palettes/Palette_1_13.h b/src/Protocol/Palettes/Palette_1_13.h
index 5b2a5ccb5..52aa70ea2 100644
--- a/src/Protocol/Palettes/Palette_1_13.h
+++ b/src/Protocol/Palettes/Palette_1_13.h
@@ -2,7 +2,7 @@
#include "BlockState.h"
#include "Registries/Items.h"
-#include "Registries/Statistics.h"
+#include "Registries/CustomStatistics.h"
namespace Palette_1_13
{
diff --git a/src/Protocol/Palettes/Palette_1_13_1.h b/src/Protocol/Palettes/Palette_1_13_1.h
index fda47e5c4..ca230743a 100644
--- a/src/Protocol/Palettes/Palette_1_13_1.h
+++ b/src/Protocol/Palettes/Palette_1_13_1.h
@@ -2,7 +2,7 @@
#include "BlockState.h"
#include "Registries/Items.h"
-#include "Registries/Statistics.h"
+#include "Registries/CustomStatistics.h"
namespace Palette_1_13_1
{
diff --git a/src/Protocol/Palettes/Palette_1_14.h b/src/Protocol/Palettes/Palette_1_14.h
index c92a19eba..3bc9b7980 100644
--- a/src/Protocol/Palettes/Palette_1_14.h
+++ b/src/Protocol/Palettes/Palette_1_14.h
@@ -2,7 +2,7 @@
#include "BlockState.h"
#include "Registries/Items.h"
-#include "Registries/Statistics.h"
+#include "Registries/CustomStatistics.h"
namespace Palette_1_14
{
diff --git a/src/Protocol/Palettes/Palette_1_15.h b/src/Protocol/Palettes/Palette_1_15.h
index 22c993de7..f71c38395 100644
--- a/src/Protocol/Palettes/Palette_1_15.h
+++ b/src/Protocol/Palettes/Palette_1_15.h
@@ -2,7 +2,7 @@
#include "BlockState.h"
#include "Registries/Items.h"
-#include "Registries/Statistics.h"
+#include "Registries/CustomStatistics.h"
namespace Palette_1_15
{
diff --git a/src/Protocol/Palettes/Palette_1_16.h b/src/Protocol/Palettes/Palette_1_16.h
index ae6cf9484..b6f85d2d6 100644
--- a/src/Protocol/Palettes/Palette_1_16.h
+++ b/src/Protocol/Palettes/Palette_1_16.h
@@ -2,7 +2,7 @@
#include "BlockState.h"
#include "Registries/Items.h"
-#include "Registries/Statistics.h"
+#include "Registries/CustomStatistics.h"
namespace Palette_1_16
{
diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h
index faea84e57..b1157366b 100644
--- a/src/Protocol/Protocol_1_8.h
+++ b/src/Protocol/Protocol_1_8.h
@@ -15,7 +15,7 @@ Declares the 1.8 protocol classes:
#include "Protocol.h"
#include "../ByteBuffer.h"
-#include "../Registries/Statistics.h"
+#include "../Registries/CustomStatistics.h"
#include "../mbedTLS++/AesCfb128Decryptor.h"
#include "../mbedTLS++/AesCfb128Encryptor.h"
diff --git a/src/Registries/CMakeLists.txt b/src/Registries/CMakeLists.txt
index 31102881d..cc0a7b4df 100644
--- a/src/Registries/CMakeLists.txt
+++ b/src/Registries/CMakeLists.txt
@@ -5,6 +5,6 @@ target_sources(
BlockStates.h
BlockTypes.h
+ CustomStatistics.h
Items.h
- Statistics.h
) \ No newline at end of file
diff --git a/src/Registries/Statistics.h b/src/Registries/CustomStatistics.h
index c0edba191..c0edba191 100644
--- a/src/Registries/Statistics.h
+++ b/src/Registries/CustomStatistics.h
diff --git a/src/Statistics.cpp b/src/StatisticsManager.cpp
index f037ec7b1..0b343cb76 100644
--- a/src/Statistics.cpp
+++ b/src/StatisticsManager.cpp
@@ -3,7 +3,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-#include "Statistics.h"
+#include "StatisticsManager.h"
diff --git a/src/Statistics.h b/src/StatisticsManager.h
index 38d2f0f7e..288f4aabc 100644
--- a/src/Statistics.h
+++ b/src/StatisticsManager.h
@@ -1,10 +1,6 @@
// Statistics.h
-#pragma once
-
-#include "Registries/Statistics.h"
-
/* Hello fellow developer !
In case you are trying to add new statistics to Cuberite you need to do a few things:
---------------------------------------------------------------------------
@@ -24,6 +20,14 @@ exported from the server https://wiki.vg/Data_Generators
+#pragma once
+
+#include "Registries/CustomStatistics.h"
+
+
+
+
+
/** Class that manages the statistics and achievements of a single player. */
struct StatisticsManager
{
diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt
index af363c97f..13675c5e1 100644
--- a/src/WorldStorage/CMakeLists.txt
+++ b/src/WorldStorage/CMakeLists.txt
@@ -9,7 +9,7 @@ target_sources(
NBTChunkSerializer.cpp
SchematicFileSerializer.cpp
ScoreboardSerializer.cpp
- StatSerializer.cpp
+ StatisticsSerializer.cpp
WSSAnvil.cpp
WorldStorage.cpp
@@ -21,7 +21,7 @@ target_sources(
NBTChunkSerializer.h
SchematicFileSerializer.h
ScoreboardSerializer.h
- StatSerializer.h
+ StatisticsSerializer.h
WSSAnvil.h
WorldStorage.h
)
diff --git a/src/WorldStorage/NamespaceSerializer.h b/src/WorldStorage/NamespaceSerializer.h
index c521db201..6ec6bc6f7 100644
--- a/src/WorldStorage/NamespaceSerializer.h
+++ b/src/WorldStorage/NamespaceSerializer.h
@@ -2,7 +2,7 @@
#include "Defines.h"
#include "Mobs/MonsterTypes.h"
-#include "Registries/Statistics.h"
+#include "Registries/CustomStatistics.h"
namespace NamespaceSerializer
{
diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatisticsSerializer.cpp
index 5432f6ab9..34621d81c 100644
--- a/src/WorldStorage/StatSerializer.cpp
+++ b/src/WorldStorage/StatisticsSerializer.cpp
@@ -1,10 +1,10 @@
-// StatSerializer.cpp
+// StatisticsSerializer.cpp
#include "Globals.h"
-#include "../Statistics.h"
-#include "StatSerializer.h"
+#include "StatisticsManager.h"
+#include "StatisticsSerializer.h"
#include "NamespaceSerializer.h"
#include <json/json.h>
@@ -13,7 +13,7 @@
-namespace StatSerializer
+namespace StatisticsSerializer
{
static auto MakeStatisticsDirectory(const std::string & WorldPath, std::string && FileName)
{
diff --git a/src/WorldStorage/StatSerializer.h b/src/WorldStorage/StatisticsSerializer.h
index a178db79c..1ccc55dbd 100644
--- a/src/WorldStorage/StatSerializer.h
+++ b/src/WorldStorage/StatisticsSerializer.h
@@ -1,5 +1,5 @@
-// StatSerializer.h
+// StatisticsSerializer.h
// Declares the cStatSerializer class that is used for saving stats into JSON
@@ -20,7 +20,7 @@ namespace Json { class Value; }
-namespace StatSerializer
+namespace StatisticsSerializer
{
/* Try to load the player statistics. */
void Load(StatisticsManager & Manager, const std::string & WorldPath, std::string && FileName);