Skip to content
LeviMC
English
AutoLightDark
LeviLamina
Loading...
Searching...
No Matches
Scoreboard.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/world/scores/PlayerScoreSetFunction.h"
5
6// auto generated inclusion list
7#include "mc/deps/core/utility/NonOwnerPointer.h"
8#include "mc/server/commands/CommandOperator.h"
9#include "mc/server/commands/CommandSoftEnumRegistry.h"
10#include "mc/world/events/PlayerScoreboardEventListener.h"
11#include "mc/world/events/ScoreboardEventCoordinator.h"
12#include "mc/world/scores/IdentityDictionary.h"
13#include "mc/world/scores/ObjectiveSortOrder.h"
14#include "mc/world/scores/ScoreboardId.h"
15#include "mc/world/scores/ScoreboardOperationResult.h"
16
17// auto generated forward declare list
18// clang-format off
19class Actor;
21class Objective;
23class PacketSender;
24class Player;
26struct ActorUniqueID;
27struct PlayerScore;
29struct ScoreInfo;
30// clang-format on
31
32class Scoreboard {
33public:
34 // member variables
35 // NOLINTBEGIN
36 ::ll::TypedStorage<8, 8, ::CommandSoftEnumRegistry> mRegistry;
37 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::DisplayObjective>> mDisplayObjectives;
38 ::ll::TypedStorage<8, 256, ::IdentityDictionary> mIdentityDict;
39 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ScoreboardId, ::ScoreboardIdentityRef>> mIdentityRefs;
40 ::ll::TypedStorage<1, 1, bool> mShouldUpdateUI;
41 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::std::unique_ptr<::Objective>>> mObjectives;
42 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint64, ::Bedrock::NonOwnerPointer<::Objective>>>
43 mObjectivesHashLookup;
44 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::std::unique_ptr<::ObjectiveCriteria>>> mCriteria;
45 ::ll::TypedStorage<8, 96, ::ScoreboardEventCoordinator> mScoreboardEventCoordinator;
46 ::ll::TypedStorage<8, 72, ::PlayerScoreboardEventListener> mPlayerListener;
47 // NOLINTEND
48
49public:
50 // prevent constructor by default
51 Scoreboard();
52
53public:
54 LLAPI int modifyPlayerScore(
55 ScoreboardOperationResult& result,
56 ScoreboardId const& id,
57 Objective& objective,
58 int scoreValue,
59 PlayerScoreSetFunction action
60 );
61
62 LLNDAPI ScoreboardId getId(PlayerScoreboardId const& playerId) const;
63
64 [[nodiscard]] std::vector<::Objective const*> getObjectives() const {
65 std::vector<::Objective const*> result;
66 for (auto const& [name, objective] : *mObjectives) {
67 result.emplace_back(objective.get());
68 }
69 return result;
70 }
71
72 LLAPI bool resetPlayerScore(::ScoreboardId const& id, ::Objective& objective);
73
74public:
75 // virtual functions
76 // NOLINTBEGIN
77 virtual ~Scoreboard() = default;
78
79 virtual ::DisplayObjective const* setDisplayObjective(
80 ::std::string const& displaySlotName,
81 ::Objective const& objective,
82 ::ObjectiveSortOrder const order
83 );
84
85 virtual ::Objective* clearDisplayObjective(::std::string const& displaySlotName);
86
87 virtual ::ScoreboardId const& createScoreboardId(::Player const& player);
88
89 virtual ::ScoreboardId const& createScoreboardId(::Actor const& entity);
90
91 virtual ::ScoreboardId const& createScoreboardId(::std::string const& fakePlayer);
92
93 virtual void onObjectiveAdded(::Objective const& objective);
94
95 virtual void onObjectiveRemoved(::Objective& objective);
96
97 virtual void onScoreChanged(::ScoreboardId const& id, ::Objective const& obj);
98
99 virtual void onPlayerScoreRemoved(::ScoreboardId const& id, ::Objective const& objective);
100
101 virtual void onPlayerJoined(::Player const& player);
102
103 virtual void onPlayerIdentityUpdated(::PlayerScoreboardId const& playerId);
104
105 virtual void tick();
106
107 virtual void setPacketSender(::PacketSender* sender);
108
109 virtual void writeToLevelStorage();
110
111 virtual bool isClientSide() const;
112 // NOLINTEND
113
114public:
115 // member functions
116 // NOLINTBEGIN
117 MCNAPI explicit Scoreboard(::CommandSoftEnumRegistry registry);
118
119 MCAPI ::Objective*
120 addObjective(::std::string const& name, ::std::string const& displayName, ::ObjectiveCriteria const& criteria);
121
123 ::ScoreboardOperationResult& result,
124 ::std::vector<::ScoreboardId>& sourceErrorIds,
125 ::ScoreboardId const& target,
126 ::Objective& targetObjective,
127 ::std::vector<::ScoreboardId>& selector,
128 ::Objective& objective,
129 ::CommandOperator opCode
130 );
131
132#ifdef LL_PLAT_C
133 MCNAPI bool clearScoreboardIdentity(::ScoreboardId const& scoreboardId);
134#endif
135
136 MCAPI ::ObjectiveCriteria* getCriteria(::std::string const& criteriaName) const;
137
138 MCNAPI ::std::vector<::PlayerScore> getDisplayInfoFiltered(::std::string const& displaySlot) const;
139
140#ifdef LL_PLAT_C
141 MCNAPI ::std::vector<::PlayerScore> getDisplayInfoSorted(
142 ::std::string const& displaySlot,
143 ::std::function<void(::ObjectiveSortOrder, ::std::vector<::PlayerScore>&)> sortMethod
144 ) const;
145#endif
146
147 MCAPI ::DisplayObjective const* getDisplayObjective(::std::string const& displaySlotName) const;
148
149 MCAPI ::std::vector<::std::string> getDisplayObjectiveSlotNames() const;
150
151 MCAPI ::Objective* getObjective(::std::string const& name) const;
152
153 MCAPI ::ScoreboardId const& getScoreboardId(::Actor const& entity) const;
154
155 MCNAPI ::ScoreboardId const& getScoreboardId(::ActorUniqueID const& entityId) const;
156
157 MCAPI ::ScoreboardId const& getScoreboardId(::std::string const& name) const;
158
159 MCAPI ::std::vector<::ScoreboardId> getTrackedIds() const;
160
161 MCNAPI ::ScoreboardIdentityRef const&
163
164 MCAPI bool removeObjective(::Objective* objective);
165
166 MCNAPI void removeScoreListener(::Player const& player, ::std::string const& objective);
167
168 MCAPI void resetPlayerScore(::ScoreboardId const& id);
169
170 MCAPI ::std::optional<::ScoreInfo> tryGetIdScore(::ScoreboardId const& id, uint64 const& objectiveHash) const;
171 // NOLINTEND
172
173public:
174 // static variables
175 // NOLINTBEGIN
176 MCAPI static ::std::string const& DEFAULT_CRITERIA();
177
178 MCNAPI static ::std::string const& DISPLAY_SLOT_BELOWNAME();
179
180 MCNAPI static ::std::string const& DISPLAY_SLOT_LIST();
181
182 MCNAPI static ::std::string const& DISPLAY_SLOT_SIDEBAR();
183
184 MCNAPI static char const*& OBJECTIVES_ENUM();
185 // NOLINTEND
186
187public:
188 // constructor thunks
189 // NOLINTBEGIN
190 MCNAPI void* $ctor(::CommandSoftEnumRegistry registry);
191 // NOLINTEND
192
193public:
194 // virtual function thunks
195 // NOLINTBEGIN
196 MCNAPI ::DisplayObjective const* $setDisplayObjective(
197 ::std::string const& displaySlotName,
198 ::Objective const& objective,
199 ::ObjectiveSortOrder const order
200 );
201
202 MCNAPI ::Objective* $clearDisplayObjective(::std::string const& displaySlotName);
203
204 MCNAPI ::ScoreboardId const& $createScoreboardId(::Player const& player);
205
206 MCNAPI ::ScoreboardId const& $createScoreboardId(::Actor const& entity);
207
208 MCNAPI ::ScoreboardId const& $createScoreboardId(::std::string const& fakePlayer);
209
210 MCNAPI void $onObjectiveAdded(::Objective const& objective);
211
212 MCNAPI void $onObjectiveRemoved(::Objective& objective);
213
214 MCNAPI void $onScoreChanged(::ScoreboardId const& id, ::Objective const& obj);
215
216 MCNAPI void $onPlayerScoreRemoved(::ScoreboardId const& id, ::Objective const& objective);
217
218 MCNAPI void $onPlayerJoined(::Player const& player);
219
220 MCNAPI void $onPlayerIdentityUpdated(::PlayerScoreboardId const& playerId);
221
222 MCNAPI void $tick();
223
224 MCNAPI void $setPacketSender(::PacketSender* sender);
225
226 MCNAPI void $writeToLevelStorage();
227
228 MCNAPI bool $isClientSide() const;
229
230
231 // NOLINTEND
232};
Definition Actor.h:116
Definition CommandSoftEnumRegistry.h:10
Definition DisplayObjective.h:14
Definition ObjectiveCriteria.h:8
Definition Objective.h:15
Definition PacketSender.h:17
Definition Player.h:131
Definition ScoreboardIdentityRef.h:16
MCAPI void $onObjectiveRemoved(::Objective &objective)
MCAPI::ScoreboardIdentityRef const & registerScoreboardIdentity(::ScoreboardId const &scoreboardId, ::PlayerScoreboardId const &playerId)
static MCAPI ::std::string const & DISPLAY_SLOT_LIST()
MCAPI::ScoreboardId const & getScoreboardId(::ActorUniqueID const &entityId) const
MCAPI::ScoreboardId const & $createScoreboardId(::std::string const &fakePlayer)
MCAPI void $setPacketSender(::PacketSender *sender)
MCAPI void $writeToLevelStorage()
MCAPI void $onScoreChanged(::ScoreboardId const &id, ::Objective const &obj)
static MCAPI ::std::string const & DISPLAY_SLOT_BELOWNAME()
MCAPI void $onPlayerScoreRemoved(::ScoreboardId const &id, ::Objective const &objective)
MCAPI int applyPlayerOperation(::ScoreboardOperationResult &result, ::std::vector<::ScoreboardId > &sourceErrorIds, ::ScoreboardId const &target, ::Objective &targetObjective, ::std::vector<::ScoreboardId > &selector, ::Objective &objective, ::CommandOperator opCode)
MCAPI::ScoreboardId const & $createScoreboardId(::Player const &player)
MCAPI ::std::vector<::PlayerScore > getDisplayInfoFiltered(::std::string const &displaySlot) const
MCAPI bool $isClientSide() const
MCAPI void * $ctor(::CommandSoftEnumRegistry registry)
MCAPI::DisplayObjective const * $setDisplayObjective(::std::string const &displaySlotName, ::Objective const &objective, ::ObjectiveSortOrder const order)
MCAPI void $onObjectiveAdded(::Objective const &objective)
static MCAPI char const *& OBJECTIVES_ENUM()
MCAPI Scoreboard(::CommandSoftEnumRegistry registry)
MCAPI::ScoreboardId const & $createScoreboardId(::Actor const &entity)
MCAPI void $tick()
MCAPI void $onPlayerIdentityUpdated(::PlayerScoreboardId const &playerId)
MCAPI void $onPlayerJoined(::Player const &player)
static MCAPI ::std::string const & DISPLAY_SLOT_SIDEBAR()
MCAPI void removeScoreListener(::Player const &player, ::std::string const &objective)
MCAPI::Objective * $clearDisplayObjective(::std::string const &displaySlotName)
Definition ActorUniqueID.h:5
Definition PlayerScore.h:8
Definition PlayerScoreboardId.h:6
Definition ScoreInfo.h:10
Definition ScoreboardId.h:11