LeviLamina
Loading...
Searching...
No Matches
PlayerPermissionsManager.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/utility/NonOwnerPointer.h"
7#include "mc/deps/core/utility/pub_sub/Publisher.h"
8#include "mc/deps/core/utility/pub_sub/Subscription.h"
9#include "mc/legacy/ActorUniqueID.h"
10#include "mc/server/commands/PlayerPermissionLevel.h"
11#include "mc/world/actor/player/AbilitiesIndex.h"
12
13// auto generated forward declare list
14// clang-format off
15class Player;
17class PlayerListEntry;
19namespace Bedrock::PubSub::ThreadModel { struct SingleThreaded; }
20// clang-format on
21
22class PlayerPermissionsManager {
23public:
24 // member variables
25 // NOLINTBEGIN
26 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::PlayerAbilitiesManager>> mPlayerAbilitiesManager;
27 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::PlayerListManager>> mPlayerListManager;
28 ::ll::TypedStorage<8, 64, ::std::function<::Player*()>> mGetPrimaryLocalPlayer;
29 ::ll::TypedStorage<8, 8, ::ActorUniqueID> mCurrentPlayerID;
30 ::ll::TypedStorage<1, 2, ::std::optional<::PlayerPermissionLevel>> mCurrentPlayerPermissionLevel;
31 ::ll::TypedStorage<8, 24, ::std::vector<::std::pair<::AbilitiesIndex, bool>>> mCurrentPlayerPermissionsList;
32 ::ll::TypedStorage<8, 24, ::std::vector<::std::pair<::AbilitiesIndex, bool>>> mLocalPlayerPermissionsList;
33 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mPlayerAbilitiesSubscription;
34 ::ll::TypedStorage<
35 8,
36 48,
37 ::Bedrock::PubSub::
39 mPlayerPermissionsChangedPublisher;
40 ::ll::TypedStorage<
41 8,
42 48,
44 void(::ActorUniqueID const&, ::std::optional<::PlayerPermissionLevel>),
46 0>>
47 mCachedPlayerPermissionLevelChangedPublisher;
48 // NOLINTEND
49
50public:
51 // prevent constructor by default
52 PlayerPermissionsManager();
53
54public:
55 // virtual functions
56 // NOLINTBEGIN
57 virtual ~PlayerPermissionsManager();
58
59 virtual bool hasPlayerPermissions(::ActorUniqueID playerId) const;
60 // NOLINTEND
61
62public:
63 // member functions
64 // NOLINTBEGIN
65 MCAPI PlayerPermissionsManager(
68 ::std::function<::Player*()> getPrimaryLocalPlayer
69 );
70
71 MCAPI void _loadLocalPermissionsList();
72
73#ifdef LL_PLAT_C
74 MCAPI ::std::unordered_map<int, bool>
75 _playerAbilitiesListToMap(::std::vector<::std::pair<::AbilitiesIndex, bool>> playerAbilitiesList);
76
77 MCAPI void _updatePermissionLevel();
78
79 MCAPI void _updatePermissionsList();
80
81 MCAPI bool arePermissionsSynced(
82 ::std::optional<::PlayerPermissionLevel> playerPermissionLevel,
83 ::std::vector<::std::pair<::AbilitiesIndex, bool>> playerPermissions
84 ) const;
85
86 MCAPI bool evaluateCanEditPermissions(
87 ::ActorUniqueID localPlayerId,
88 bool isPrimaryClient,
89 bool isHostingLocalDedicatedServer
90 ) const;
91
92 MCAPI bool evaluateCanKickPlayer(::ActorUniqueID playerId, ::ActorUniqueID localPlayerId);
93
94 MCFOLD ::Bedrock::PubSub::Publisher<
95 void(::ActorUniqueID const&, ::std::optional<::PlayerPermissionLevel>),
97 0>&
98 getCachedPlayerPermissionLevelChangedPublisher();
99
100 MCFOLD ::ActorUniqueID getCurrentPlayerId() const;
101
102 MCAPI ::std::optional<::PlayerPermissionLevel> getCurrentPlayerPermissionLevel(::ActorUniqueID playerId) const;
103
104 MCAPI ::std::optional<::std::vector<::std::pair<::AbilitiesIndex, bool>>>
105 getCurrentPlayerPermissionsList(::ActorUniqueID playerId) const;
106
107 MCAPI ::PlayerListEntry* getPlayerFromAUID(::ActorUniqueID playerId) const;
108
109 MCFOLD ::Bedrock::PubSub::
110 Publisher<void(::ActorUniqueID const&, bool), ::Bedrock::PubSub::ThreadModel::SingleThreaded, 0>&
111 getPlayerPermissionsChangedPublisher();
112
113 MCAPI bool isPlayerInList(::ActorUniqueID playerId) const;
114
115 MCAPI bool isPlayerValid(::ActorUniqueID playerId) const;
116#endif
117
118 MCAPI bool loadPlayerPermissions(::ActorUniqueID playerId);
119
120#ifdef LL_PLAT_C
121 MCAPI bool savePlayerPermissions(::ActorUniqueID playerId);
122
123 MCAPI bool setPlayerPermission(::ActorUniqueID playerId, ::AbilitiesIndex index, bool value);
124
125 MCAPI bool setPlayerPermissionLevel(::ActorUniqueID playerId, ::PlayerPermissionLevel permissionLevel);
126#endif
127 // NOLINTEND
128
129public:
130 // constructor thunks
131 // NOLINTBEGIN
132 MCAPI void* $ctor(
135 ::std::function<::Player*()> getPrimaryLocalPlayer
136 );
137 // NOLINTEND
138
139public:
140 // destructor thunk
141 // NOLINTBEGIN
142 MCAPI void $dtor();
143 // NOLINTEND
144
145public:
146 // virtual function thunks
147 // NOLINTBEGIN
148 MCAPI bool $hasPlayerPermissions(::ActorUniqueID playerId) const;
149
150
151 // NOLINTEND
152
153public:
154 // vftables
155 // NOLINTBEGIN
156 MCNAPI static void** $vftable();
157 // NOLINTEND
158};
Definition NonOwnerPointer.h:9
Definition Publisher.h:8
Definition PlayerAbilitiesManager.h:19
Definition PlayerListEntry.h:20
Definition PlayerListManager.h:24
static MCAPI void ** $vftable()
Definition Player.h:137
Definition ActorUniqueID.h:10