Skip to content
LeviMC
English
AutoLightDark
LeviLamina
Loading...
Searching...
No Matches
LevelStorage.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/common/CompactionStatus.h"
7#include "mc/deps/core/file/PathBuffer.h"
8#include "mc/deps/core/threading/Async.h"
9#include "mc/world/level/storage/StorageVersion.h"
10#include "mc/world/level/storage/db_helpers/Category.h"
11
12// auto generated forward declare list
13// clang-format off
14class ChunkSource;
15class CompoundTag;
16class ContentIdentity;
17class LevelData;
20class Player;
23namespace Core { struct LevelStorageResult; }
24// clang-format on
25
27public:
28 // LevelStorage inner types define
29 enum class StatsType : uint {
30 Level0 = 0,
31 Level1 = 1,
32 Level2 = 2,
33 Memory = 3,
34 Default = 0,
35 };
36
37public:
38 // virtual functions
39 // NOLINTBEGIN
40 virtual ~LevelStorage() = default;
41
42 virtual void addStorageObserver(::std::unique_ptr<::LevelStorageObserver> observer) = 0;
43
44 virtual bool loadedSuccessfully() const;
45
46 virtual ::std::unique_ptr<::CompoundTag>
47 getCompoundTag(::std::string const& key, ::DBHelpers::Category category) = 0;
48
49 virtual bool hasKey(::std::string_view key, ::DBHelpers::Category category) const = 0;
50
51 virtual void forEachKeyWithPrefix(
52 ::std::string_view prefix,
53 ::DBHelpers::Category category,
54 ::std::function<void(::std::string_view, ::std::string_view)> const& callback
55 ) const = 0;
56
57 virtual bool loadLevelData(::LevelData& data) = 0;
58
59 virtual ::std::unique_ptr<::ChunkSource> createChunkStorage(::std::unique_ptr<::ChunkSource>, ::StorageVersion) = 0;
60
61 virtual void saveLevelData(::LevelData const& levelData) = 0;
62
63 virtual ::Core::PathBuffer<::std::string> const& getFullPath() const = 0;
64
65 virtual ::Bedrock::Threading::Async<void>
66 saveData(::std::string const& key, ::std::string&& data, ::DBHelpers::Category category) = 0;
67
68 virtual ::Bedrock::Threading::Async<void> saveData(::LevelStorageWriteBatch const& batch) = 0;
69
70 virtual ::Bedrock::Threading::Async<void> deleteData(::std::string const& key, ::DBHelpers::Category category) = 0;
71
72 virtual void getStatistics(::std::string& outStats, ::LevelStorage::StatsType statsType) const = 0;
73
74 virtual bool clonePlayerData(::std::string_view fromKey, ::std::string_view toKey, bool isEditorPlayer);
75
76 virtual ::Core::LevelStorageResult getLevelStorageState() const = 0;
77
78 virtual ::ContentIdentity const* getContentIdentity() const = 0;
79
80 virtual void startShutdown() = 0;
81
82 virtual bool isShuttingDown() const = 0;
83
84 virtual bool checkShutdownDone() = 0;
85
86 virtual bool loadData(::std::string_view key, ::std::string& buffer, ::DBHelpers::Category category) const;
87
88 virtual ::Core::LevelStorageResult getState() const = 0;
89
90 virtual ::std::vector<::SnapshotFilenameAndLength>
91 createSnapshot(::std::string const& filePrefix, bool flushWriteCache) = 0;
92
93 virtual void releaseSnapshot() = 0;
94
95 virtual ::Bedrock::Threading::Async<void> compactStorage() = 0;
96
97 virtual void syncAndSuspendStorage() = 0;
98
99 virtual void resumeStorage() = 0;
100
101 virtual void setFlushAllowed(bool flushAllowed) = 0;
102
103 virtual void flushToPermanentStorage() = 0;
104
105 virtual void freeCaches();
106
107 virtual void setCompactionCallback(::std::function<void(::CompactionStatus)> callback) = 0;
108
109 virtual void setCriticalSyncSaveCallback(::std::function<void()> callback) = 0;
110
111 virtual void setWorldSaveAndExitPackTelemetry(::std::vector<::WorldSaveAndExitPackTelemetryData> packs) = 0;
112
113 virtual void corruptLevel();
114 // NOLINTEND
115
116public:
117 // member functions
118 // NOLINTBEGIN
119#ifdef LL_PLAT_C
120 MCNAPI ::std::unique_ptr<::LevelStorageWriteBatch> createWriteBatch();
121#endif
122
123 MCAPI ::std::string getServerId(::Player const& client, bool isXboxLive);
124
125 MCAPI ::std::vector<::std::string> loadAllPlayerIDs(bool includeLocalPlayer) const;
126
127 MCAPI ::std::unique_ptr<::CompoundTag> loadServerPlayerData(::Player const& client, bool isXboxLive);
128
129 MCAPI void save(::Player& player);
130
131 MCAPI ::Bedrock::Threading::Async<void>
132 saveData(::std::string const& key, ::CompoundTag const& tag, ::DBHelpers::Category category);
133 // NOLINTEND
134
135public:
136 // static variables
137 // NOLINTBEGIN
138 MCAPI static ::std::string const& LEGACY_CONSOLE_PLAYER_PREFIX();
139
140 MCNAPI static ::std::string const& LOCAL_PLAYER_EDITOR_TAG();
141
142 MCAPI static ::std::string const& LOCAL_PLAYER_TAG();
143 // NOLINTEND
144
145public:
146 // virtual function thunks
147 // NOLINTBEGIN
148 MCNAPI bool $clonePlayerData(::std::string_view fromKey, ::std::string_view toKey, bool isEditorPlayer);
149
150 MCNAPI void $corruptLevel();
151
152
153 // NOLINTEND
154};
Definition ChunkSource.h:37
Definition CompoundTag.h:18
Definition ContentIdentity.h:8
Definition LevelData.h:57
Definition LevelStorageObserver.h:5
Definition LevelStorageWriteBatch.h:13
Definition LevelStorage.h:26
MCAPI bool $clonePlayerData(::std::string_view fromKey, ::std::string_view toKey, bool isEditorPlayer)
MCAPI void $corruptLevel()
static MCAPI ::std::string const & LOCAL_PLAYER_EDITOR_TAG()
Definition Player.h:131
Definition LevelStorageResult.h:7
Definition SnapshotFilenameAndLength.h:5
Definition WorldSaveAndExitPackTelemetryData.h:5
Definition buffer.h:5