添加onServerStopping事件

This commit is contained in:
子沐呀
2024-08-01 20:54:18 +08:00
Unverified
parent ae34d79b56
commit e2e053c8c1
4 changed files with 19 additions and 6 deletions
+8
View File
@@ -240,4 +240,12 @@ declare class Event {
containerId: number containerId: number
) => void ) => void
): boolean; ): boolean;
/** 关闭服务器(不可拦截) */
static listen(
/** 事件名 */
event: "onServerStopping",
/** 回调函数 */
listener: () => void
): boolean;
} }
-2
View File
@@ -1,5 +1,3 @@
/// <reference path='d:/dts/dts/helperlib/src/index.d.ts'/>
/** LRCA导出接口 */ /** LRCA导出接口 */
const GMLIB_API = { const GMLIB_API = {
/** 创建悬浮字 @type {function(FloatPos,string,boolean):number} */ /** 创建悬浮字 @type {function(FloatPos,string,boolean):number} */
-4
View File
@@ -1,8 +1,4 @@
#include "Global.h" #include "Global.h"
#include "ll/api/service/Bedrock.h"
#include "magic_enum.hpp"
#include "mc/deps/core/string/HashedString.h"
#include "mc/world/effect/MobEffect.h"
#include <regex> #include <regex>
bool isInteger(const std::string& str) { bool isInteger(const std::string& str) {
+11
View File
@@ -314,6 +314,17 @@ void Export_Event_API() {
); );
return true; return true;
} }
case doHash("onServerStopping"): {
auto Call = RemoteCall::importAs<bool()>(eventName, eventId);
eventBus->emplaceListener<ll::event::server::ServerStoppingEvent>(
[Call](ll::event::server::ServerStoppingEvent& ev) {
try {
Call();
} catch (...) {}
}
);
return true;
}
default: default:
return false; return false;
} }