LeviLamina
Loading...
Searching...
No Matches
ServerScriptManager.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/deps/core/threading/Scheduler.h"
5#include "mc/deps/scripting/script_engine/DependencyLocator.h"
6#include "mc/scripting/ScriptFormPromiseTracker.h"
7#include "mc/scripting/ScriptPluginManager.h"
8#include "mc/scripting/ScriptPluginResult.h"
9#include "mc/scripting/ScriptPrintLogger.h"
10#include "mc/scripting/ScriptSettings.h"
11#include "mc/scripting/ScriptTickListener.h"
12#include "mc/scripting/debugger/ScriptDebugger.h"
13#include "mc/scripting/debugger/ScriptDebuggerWatchdog.h"
14
15
16// auto generated inclusion list
17#include "mc/deps/core/utility/NonOwnerPointer.h"
18#include "mc/deps/core/utility/optional_ref.h"
19#include "mc/deps/game_refs/OwnerPtr.h"
20#include "mc/deps/game_refs/StackRefResult.h"
21#include "mc/scripting/PluginExecutionGroup.h"
22#include "mc/scripting/RegisterDiagnosticsStatsTypes.h"
23#include "mc/scripting/ScriptSettings.h"
24#include "mc/scripting/ServerScriptManagerEvents.h"
25#include "mc/scripting/modules/FilterResult.h"
26#include "mc/world/events/EventListenerDispatcher.h"
27#include "mc/world/events/EventResult.h"
28#include "mc/world/events/LevelEventListener.h"
29#include "mc/world/events/ServerInstanceEventListener.h"
30
31// auto generated forward declare list
32// clang-format off
36class ItemRegistryRef;
40class PackManifest;
41class Scheduler;
45class ScriptDebugger;
55class ScriptWatchdog;
56class ServerInstance;
57class ServerLevel;
60namespace ScriptModuleMinecraft { class CustomCommandRegistry; }
61namespace ScriptModuleMinecraft { class IScriptItemCustomComponentRegistry; }
62namespace ScriptModuleMinecraft { class ScriptBlockCustomComponentsRegistry; }
63namespace ScriptModuleMinecraft { class ScriptCustomComponentParameterCache; }
64namespace ScriptModuleMinecraft { class ScriptCustomDimensionRegistry; }
65namespace ScriptModuleMinecraft { class ScriptCustomSpawnRulesRegistry; }
66namespace ScriptModuleMinecraft { class ScriptGlobalEventListeners; }
67namespace Scripting { class DependencyLocator; }
68namespace Scripting { class IRuntime; }
69namespace Scripting { class RegistryManager; }
70namespace Scripting { class ScriptEngine; }
71namespace Scripting { class WeakLifetimeScope; }
72namespace Scripting { struct ModuleDescriptor; }
73namespace cereal { struct ReflectionCtx; }
74// clang-format on
75
76class ServerScriptManager : public ::EventListenerDispatcher<::ServerInstanceEventListener>,
77 public ::EventListenerDispatcher<::LevelEventListener> {
78public:
79 // ServerScriptManager inner types define
80 enum class RuntimeVersion : int {
81 V1 = 1,
82 V2 = 2,
83 };
84
85public:
86 // member variables
87 // NOLINTBEGIN
88 ::ll::TypedStorage<8, 144, ::ServerScriptManagerEvents> mScriptStateEvents;
89 ::ll::TypedStorage<8, 760, ::ScriptSettings> mSettings;
90 ::ll::TypedStorage<8, 8, ::ServerLevel&> mServerLevel;
91 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::ScriptPackSettingsCache>> mPackSettingsCache;
92 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::Scheduler>> mServerScheduler;
93 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::cereal::ReflectionCtx>> mCerealContext;
94 ::ll::TypedStorage<1, 1, ::RegisterDiagnosticsStatsTypes> mRegisterDiagnosticsStatsTypes;
95 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::IScriptTelemetryLogger>> mTelemetryLogger;
96 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptClientDiagnosticsListener>> mClientDiagnosticsListener;
97 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LevelEventHandlerRegistrar>> mLevelEventHandlerRegistrar;
98 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptModuleMinecraft::CustomCommandRegistry>> mCustomCommandRegistry;
99 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptModuleMinecraft::ScriptCustomComponentParameterCache>>
100 mCustomComponentParameterCache;
101 ::ll::TypedStorage<8, 16, ::OwnerPtr<::ScriptModuleMinecraft::ScriptBlockCustomComponentsRegistry>>
102 mBlockCustomComponentsRegistry;
103 ::ll::TypedStorage<8, 16, ::OwnerPtr<::ScriptModuleMinecraft::IScriptItemCustomComponentRegistry>>
104 mItemCustomComponentRegistry;
105 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptModuleMinecraft::ScriptCustomSpawnRulesRegistry>>
106 mCustomSpawnRulesRegistry;
107 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptModuleMinecraft::ScriptCustomDimensionRegistry>>
108 mCustomDimensionRegistry;
109 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptModuleMinecraft::ScriptGlobalEventListeners>>
110 mGlobalEventListeners;
111 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Scripting::ScriptEngine>> mScriptEngine;
112 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptPluginManager>> mScriptPluginManager;
113 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptAsyncJobCoordinator>> mAsyncJobCoordinator;
114 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptFormPromiseTracker>> mFormPromiseTracker;
115 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptDebuggerWatchdog>> mScriptDebuggerWatchdog;
116 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptDebugger>> mScriptDebugger;
117 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptDiagnosticsPublishToFile>> mDiagnosticsPublishToFile;
118 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptDiagnostics>> mScriptDiagnostics;
119 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptTickListener>> mScriptTickListener;
120 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptContentLogEndPoint>> mScriptContentLogEndPoint;
121 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptWatchdog>> mScriptWatchdog;
122 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::AsyncJoinRegistrar>> mAsyncJoinRegistrar;
123 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Scripting::DependencyLocator>> mDependencyLocator;
124 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::Scripting::IRuntime>>> mSharedRuntimes;
125 ::ll::TypedStorage<
126 8,
127 24,
128 ::std::vector<::std::function<::ScriptModuleFilters::FilterResult(
129 ::PackManifest const&,
133 )>>>
134 mModuleFilters;
135 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptServerNetworkHandlerReference>> mServerNetworkHandler;
136 // NOLINTEND
137
138public:
139 // prevent constructor by default
140 ServerScriptManager& operator=(ServerScriptManager const&);
141 ServerScriptManager(ServerScriptManager const&);
142 ServerScriptManager();
143
144public:
145 // virtual functions
146 // NOLINTBEGIN
147 virtual ~ServerScriptManager() /*override*/;
148
149 virtual ::EventResult onServerUpdateEnd(::ServerInstance& instance) /*override*/;
150
151 virtual ::EventResult onServerThreadStarted(::ServerInstance& instance) /*override*/;
152
153 virtual ::EventResult onEvent(::ServerInstanceRequestResourceReload const& reloadEvent) /*override*/;
154
155 virtual ::EventResult onEvent(::LevelStartLeaveGameEvent const& levelStartLeaveGameEvent) /*override*/;
156 // NOLINTEND
157
158public:
159 // member functions
160 // NOLINTBEGIN
161 MCAPI ServerScriptManager(
162 ::ScriptSettings&& settings,
163 ::ServerLevel& serverLevel,
164 ::std::shared_ptr<::ScriptPackSettingsCache> packSettingsCache,
166 ::MinecraftCommands& commands,
167 ::IMinecraftEventing& eventing,
168 ::ItemRegistryRef itemRegistry,
169 ::ServerInstance& server,
171 ::std::unique_ptr<::AsyncJoinRegistrar>&& asyncJoinRegistrar,
172 ::std::unique_ptr<::ScriptServerNetworkHandlerReference>&& serverNetworkHandler
173 );
174
175 MCAPI void _initModules(::ServerInstance& server, ::ServerLevel& serverLevel);
176
177 MCAPI void _loadPlugins(::ServerLevel& serverLevel, bool fromReload);
178
179 MCAPI void _onPreReload(
180 ::ServerInstance& serverInstance,
181 ::ServerLevel& level,
183 );
184
185 MCAPI void _runPlugins(::PluginExecutionGroup exeGroup, ::ServerInstance& serverInstance);
186
187 MCAPI void _sendWorldInitializeEvent(::ServerLevel& level) const;
188
189 MCAPI void addModuleFilter(
190 ::std::function<::ScriptModuleFilters::FilterResult(
191 ::PackManifest const&,
195 )> moduleFilter
196 );
197
198 MCAPI ::StackRefResult<::ScriptModuleMinecraft::ScriptBlockCustomComponentsRegistry>
199 getBlockCustomComponentRegistry() const;
200
201#ifdef LL_PLAT_S
202 MCFOLD ::Scripting::ScriptEngine& getScriptEngine();
203
204 MCFOLD ::ScriptSettings& getScriptSettings();
205#endif
206
207#ifdef LL_PLAT_C
208 MCAPI void onMainThreadStartLeaveGame();
209#endif
210
211 MCAPI void setBlockCustomComponentCerealContext(::cereal::ReflectionCtx& ctx);
212
213 MCAPI void setItemCustomComponentCerealContext(::cereal::ReflectionCtx& ctx);
214 // NOLINTEND
215
216public:
217 // static functions
218 // NOLINTBEGIN
219 MCAPI static void
220 _sendScriptModuleShutdownEvent(::ServerLevel& level, ::std::optional<::Scripting::WeakLifetimeScope> scope);
221
222 MCAPI static void _sendScriptModuleStartupEventImpl(
223 ::ServerLevel& level,
229 ::std::optional<::Scripting::WeakLifetimeScope> scope
230 );
231
232 MCAPI static void _sendWorldInitializeEventImpl(
233 ::ServerLevel& level,
237 bool lastEventInList
238 );
239 // NOLINTEND
240
241public:
242 // constructor thunks
243 // NOLINTBEGIN
244 MCAPI void* $ctor(
245 ::ScriptSettings&& settings,
246 ::ServerLevel& serverLevel,
247 ::std::shared_ptr<::ScriptPackSettingsCache> packSettingsCache,
249 ::MinecraftCommands& commands,
250 ::IMinecraftEventing& eventing,
251 ::ItemRegistryRef itemRegistry,
252 ::ServerInstance& server,
254 ::std::unique_ptr<::AsyncJoinRegistrar>&& asyncJoinRegistrar,
255 ::std::unique_ptr<::ScriptServerNetworkHandlerReference>&& serverNetworkHandler
256 );
257 // NOLINTEND
258
259public:
260 // destructor thunk
261 // NOLINTBEGIN
262 MCAPI void $dtor();
263 // NOLINTEND
264
265public:
266 // virtual function thunks
267 // NOLINTBEGIN
268 MCAPI ::EventResult $onServerUpdateEnd(::ServerInstance& instance);
269
270 MCAPI ::EventResult $onServerThreadStarted(::ServerInstance& instance);
271
272 MCAPI ::EventResult $onEvent(::ServerInstanceRequestResourceReload const& reloadEvent);
273
274 MCAPI ::EventResult $onEvent(::LevelStartLeaveGameEvent const& levelStartLeaveGameEvent);
275
276
277 // NOLINTEND
278
279public:
280 // vftables
281 // NOLINTBEGIN
283
285 // NOLINTEND
286};
Definition AsyncJoinRegistrar.h:18
Definition NonOwnerPointer.h:9
Definition EventListenerDispatcher.h:6
Definition IMinecraftEventing.h:138
Definition IScriptTelemetryLogger.h:10
Definition ItemRegistryRef.h:42
Definition LevelEventHandlerRegistrar.h:10
Definition MinecraftCommands.h:36
Definition MinecraftGameTest.h:22
Definition PackManifest.h:38
Definition Scheduler.h:15
Definition ScriptAsyncJobCoordinator.h:15
Definition ScriptClientDiagnosticsListener.h:15
Definition ScriptContentLogEndPoint.h:15
Definition ScriptDebuggerWatchdog.h:8
Definition ScriptDebugger.h:26
Definition ScriptDiagnosticsPublishToFile.h:17
Definition ScriptDiagnostics.h:11
Definition ScriptFormPromiseTracker.h:37
Definition CustomCommandRegistry.h:24
Definition IScriptItemCustomComponentRegistry.h:20
Definition ScriptBlockCustomComponentsRegistry.h:62
Definition ScriptCustomComponentParameterCache.h:21
Definition ScriptCustomDimensionRegistry.h:23
Definition ScriptCustomSpawnRulesRegistry.h:26
Definition ScriptGlobalEventListeners.h:19
Definition ScriptPackSettingsCache.h:17
Definition ScriptPluginManager.h:30
Definition ScriptPluginResult.h:11
Definition ScriptServerNetworkHandlerReference.h:14
Definition ScriptTickListener.h:22
Definition ScriptWatchdog.h:13
Definition DependencyLocator.h:7
Definition IRuntime.h:37
Definition RegistryManager.h:13
Definition ScriptEngine.h:22
Definition WeakLifetimeScope.h:14
Definition ServerInstance.h:64
Definition ServerLevel.h:59
static MCAPI void ** $vftableForEventListenerDispatcherLevelEventListener()
static MCAPI void ** $vftableForEventListenerDispatcherServerInstanceEventListener()
Definition optional_ref.h:10
Definition LevelStartLeaveGameEvent.h:13
Definition ScriptSettings.h:19
Definition ModuleDescriptor.h:7
Definition ServerInstanceRequestResourceReload.h:13
Definition ReflectionCtx.h:11
Definition ctx.h:5