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/scripting/PluginExecutionGroup.h"
21#include "mc/scripting/RegisterDiagnosticsStatsTypes.h"
22#include "mc/scripting/ScriptSettings.h"
23#include "mc/scripting/ServerScriptManagerEvents.h"
24#include "mc/scripting/modules/FilterResult.h"
25#include "mc/world/events/EventListenerDispatcher.h"
26#include "mc/world/events/EventResult.h"
27#include "mc/world/events/LevelEventListener.h"
28#include "mc/world/events/ServerInstanceEventListener.h"
29
30// auto generated forward declare list
31// clang-format off
35class ItemRegistryRef;
39class PackManifest;
40class Scheduler;
44class ScriptDebugger;
53class ScriptWatchdog;
54class ServerInstance;
55class ServerLevel;
58namespace ScriptModuleMinecraft { class CustomCommandRegistry; }
59namespace ScriptModuleMinecraft { class IScriptItemCustomComponentRegistry; }
60namespace ScriptModuleMinecraft { class ScriptBlockCustomComponentsRegistry; }
61namespace ScriptModuleMinecraft { class ScriptCustomComponentParameterCache; }
62namespace ScriptModuleMinecraft { class ScriptCustomSpawnRulesRegistry; }
63namespace ScriptModuleMinecraft { class ScriptGlobalEventListeners; }
64namespace Scripting { class DependencyLocator; }
65namespace Scripting { class IRuntime; }
66namespace Scripting { class RegistryManager; }
67namespace Scripting { class ScriptEngine; }
68namespace Scripting { class WeakLifetimeScope; }
69namespace Scripting { struct ModuleDescriptor; }
70namespace cereal { struct ReflectionCtx; }
71// clang-format on
72
73class ServerScriptManager : public ::EventListenerDispatcher<::ServerInstanceEventListener>,
74 public ::EventListenerDispatcher<::LevelEventListener> {
75public:
76 // ServerScriptManager inner types define
77 enum class RuntimeVersion : int {
78 V1 = 1,
79 V2 = 2,
80 };
81
82public:
83 // member variables
84 // NOLINTBEGIN
85 ::ll::TypedStorage<8, 144, ::ServerScriptManagerEvents> mScriptStateEvents;
86 ::ll::TypedStorage<8, 752, ::ScriptSettings> mSettings;
87 ::ll::TypedStorage<8, 8, ::ServerLevel&> mServerLevel;
88 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::ScriptPackSettingsCache>> mPackSettingsCache;
89 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::Scheduler>> mServerScheduler;
90 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::cereal::ReflectionCtx>> mCerealContext;
91 ::ll::TypedStorage<1, 1, ::RegisterDiagnosticsStatsTypes> mRegisterDiagnosticsStatsTypes;
92 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::IScriptTelemetryLogger>> mTelemetryLogger;
93 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptClientDiagnosticsListener>> mClientDiagnosticsListener;
94 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LevelEventHandlerRegistrar>> mLevelEventHandlerRegistrar;
95 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptModuleMinecraft::CustomCommandRegistry>> mCustomCommandRegistry;
96 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptModuleMinecraft::ScriptCustomComponentParameterCache>>
97 mCustomComponentParameterCache;
98 ::ll::TypedStorage<8, 16, ::OwnerPtr<::ScriptModuleMinecraft::ScriptBlockCustomComponentsRegistry>>
99 mBlockCustomComponentsRegistry;
100 ::ll::TypedStorage<8, 16, ::OwnerPtr<::ScriptModuleMinecraft::IScriptItemCustomComponentRegistry>>
101 mItemCustomComponentRegistry;
102 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptModuleMinecraft::ScriptCustomSpawnRulesRegistry>>
103 mCustomSpawnRulesRegistry;
104 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptModuleMinecraft::ScriptGlobalEventListeners>>
105 mGlobalEventListeners;
106 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Scripting::ScriptEngine>> mScriptEngine;
107 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptPluginManager>> mScriptPluginManager;
108 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptAsyncJobCoordinator>> mAsyncJobCoordinator;
109 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptFormPromiseTracker>> mFormPromiseTracker;
110 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptDebuggerWatchdog>> mScriptDebuggerWatchdog;
111 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptDebugger>> mScriptDebugger;
112 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptDiagnosticsPublishToFile>> mDiagnosticsPublishToFile;
113 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptDiagnostics>> mScriptDiagnostics;
114 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptTickListener>> mScriptTickListener;
115 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptContentLogEndPoint>> mScriptContentLogEndPoint;
116 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScriptWatchdog>> mScriptWatchdog;
117 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::AsyncJoinRegistrar>> mAsyncJoinRegistrar;
118 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Scripting::DependencyLocator>> mDependencyLocator;
119 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::Scripting::IRuntime>>> mSharedRuntimes;
120 ::ll::TypedStorage<
121 8,
122 24,
123 ::std::vector<::std::function<::ScriptModuleFilters::FilterResult(
124 ::PackManifest const&,
128 )>>>
129 mModuleFilters;
130 // NOLINTEND
131
132public:
133 // prevent constructor by default
134 ServerScriptManager& operator=(ServerScriptManager const&);
135 ServerScriptManager(ServerScriptManager const&);
136 ServerScriptManager();
137
138public:
139 // virtual functions
140 // NOLINTBEGIN
141 virtual ::EventResult onEvent(::ServerInstanceRequestResourceReload const& reloadEvent) /*override*/;
142
143 virtual ::EventResult onEvent(::LevelStartLeaveGameEvent const& levelStartLeaveGameEvent) /*override*/;
144
145 virtual ~ServerScriptManager() /*override*/;
146
147 virtual ::EventResult onServerUpdateEnd(::ServerInstance& instance) /*override*/;
148
149 virtual ::EventResult onServerThreadStarted(::ServerInstance& instance) /*override*/;
150 // NOLINTEND
151
152public:
153 // member functions
154 // NOLINTBEGIN
155 MCAPI ServerScriptManager(
156 ::ScriptSettings&& settings,
157 ::ServerLevel& serverLevel,
158 ::std::shared_ptr<::ScriptPackSettingsCache> packSettingsCache,
160 ::MinecraftCommands& commands,
161 ::IMinecraftEventing& eventing,
162 ::ItemRegistryRef itemRegistry,
163 ::ServerInstance& server,
165 ::std::unique_ptr<::AsyncJoinRegistrar>&& asyncJoinRegistrar
166 );
167
168 MCAPI void _initModules(::ServerInstance& server, ::ServerLevel& serverLevel);
169
170 MCAPI void _loadPlugins(::ServerLevel& serverLevel, bool fromReload);
171
172 MCAPI void _onPreReload(
173 ::ServerInstance& serverInstance,
174 ::ServerLevel& level,
176 );
177
178 MCAPI void _runPlugins(::PluginExecutionGroup exeGroup, ::ServerInstance& serverInstance);
179
180 MCAPI void _sendScriptModuleStartupEvent(::ServerLevel& level) const;
181
182 MCAPI void _sendWorldInitializeEvent(::ServerLevel& level) const;
183
184 MCAPI void addModuleFilter(
185 ::std::function<::ScriptModuleFilters::FilterResult(
186 ::PackManifest const&,
190 )> moduleFilter
191 );
192 // NOLINTEND
193
194public:
195 // static functions
196 // NOLINTBEGIN
197 MCAPI static void
198 _sendScriptModuleShutdownEvent(::ServerLevel& level, ::std::optional<::Scripting::WeakLifetimeScope> scope);
199
200 MCAPI static void _sendWorldInitializeEventImpl(
201 ::ServerLevel& level,
205 bool lastEventInList
206 );
207 // NOLINTEND
208
209public:
210 // constructor thunks
211 // NOLINTBEGIN
212 MCAPI void* $ctor(
213 ::ScriptSettings&& settings,
214 ::ServerLevel& serverLevel,
215 ::std::shared_ptr<::ScriptPackSettingsCache> packSettingsCache,
217 ::MinecraftCommands& commands,
218 ::IMinecraftEventing& eventing,
219 ::ItemRegistryRef itemRegistry,
220 ::ServerInstance& server,
222 ::std::unique_ptr<::AsyncJoinRegistrar>&& asyncJoinRegistrar
223 );
224 // NOLINTEND
225
226public:
227 // destructor thunk
228 // NOLINTBEGIN
229 MCAPI void $dtor();
230 // NOLINTEND
231
232public:
233 // virtual function thunks
234 // NOLINTBEGIN
235 MCAPI ::EventResult $onEvent(::ServerInstanceRequestResourceReload const& reloadEvent);
236
237 MCAPI ::EventResult $onEvent(::LevelStartLeaveGameEvent const& levelStartLeaveGameEvent);
238
239 MCAPI ::EventResult $onServerUpdateEnd(::ServerInstance& instance);
240
241 MCAPI ::EventResult $onServerThreadStarted(::ServerInstance& instance);
242
243
244 // NOLINTEND
245
246public:
247 // vftables
248 // NOLINTBEGIN
250
252 // NOLINTEND
253};
Definition AsyncJoinRegistrar.h:18
Definition NonOwnerPointer.h:9
Definition EventListenerDispatcher.h:6
Definition IMinecraftEventing.h:137
Definition IScriptTelemetryLogger.h:10
Definition ItemRegistryRef.h:36
Definition LevelEventHandlerRegistrar.h:10
Definition MinecraftCommands.h:34
Definition MinecraftGameTest.h:20
Definition PackManifest.h:37
Definition Scheduler.h:14
Definition ScriptAsyncJobCoordinator.h:11
Definition ScriptClientDiagnosticsListener.h:14
Definition ScriptContentLogEndPoint.h:10
Definition ScriptDebuggerWatchdog.h:8
Definition ScriptDebugger.h:25
Definition ScriptDiagnosticsPublishToFile.h:16
Definition ScriptDiagnostics.h:11
Definition ScriptFormPromiseTracker.h:35
Definition CustomCommandRegistry.h:23
Definition IScriptItemCustomComponentRegistry.h:20
Definition ScriptBlockCustomComponentsRegistry.h:53
Definition ScriptCustomComponentParameterCache.h:19
Definition ScriptCustomSpawnRulesRegistry.h:24
Definition ScriptGlobalEventListeners.h:19
Definition ScriptPackSettingsCache.h:17
Definition ScriptPluginManager.h:25
Definition ScriptPluginResult.h:11
Definition ScriptTickListener.h:21
Definition ScriptWatchdog.h:8
Definition DependencyLocator.h:7
Definition IRuntime.h:37
Definition RegistryManager.h:12
Definition ScriptEngine.h:21
Definition WeakLifetimeScope.h:7
Definition ServerInstance.h:57
Definition ServerLevel.h:50
static MCAPI void ** $vftableForEventListenerDispatcherLevelEventListener()
static MCAPI void ** $vftableForEventListenerDispatcherServerInstanceEventListener()
Definition optional_ref.h:10
Definition LevelStartLeaveGameEvent.h:13
Definition ScriptSettings.h:18
Definition ModuleDescriptor.h:7
Definition ServerInstanceRequestResourceReload.h:13
Definition ReflectionCtx.h:11