diff --git a/lib/EventAPI-JS.d.ts b/lib/EventAPI-JS.d.ts index 0bfdb50..ec9c4ec 100644 --- a/lib/EventAPI-JS.d.ts +++ b/lib/EventAPI-JS.d.ts @@ -240,4 +240,12 @@ declare class Event { containerId: number ) => void ): boolean; + + /** 关闭服务器(不可拦截) */ + static listen( + /** 事件名 */ + event: "onServerStopping", + /** 回调函数 */ + listener: () => void + ): boolean; } \ No newline at end of file diff --git a/lib/GMLIB_API-JS.js b/lib/GMLIB_API-JS.js index 8e6cb3a..f9cf0c2 100644 --- a/lib/GMLIB_API-JS.js +++ b/lib/GMLIB_API-JS.js @@ -1,5 +1,3 @@ -/// - /** LRCA导出接口 */ const GMLIB_API = { /** 创建悬浮字 @type {function(FloatPos,string,boolean):number} */ diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index 9575c83..4ef3312 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -1,8 +1,4 @@ #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 bool isInteger(const std::string& str) { diff --git a/src/EventAPI.cpp b/src/EventAPI.cpp index f129297..fe20805 100644 --- a/src/EventAPI.cpp +++ b/src/EventAPI.cpp @@ -314,6 +314,17 @@ void Export_Event_API() { ); return true; } + case doHash("onServerStopping"): { + auto Call = RemoteCall::importAs(eventName, eventId); + eventBus->emplaceListener( + [Call](ll::event::server::ServerStoppingEvent& ev) { + try { + Call(); + } catch (...) {} + } + ); + return true; + } default: return false; }