From 8ee4e240f81651dcde254a13b9d23e613a544c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=90=E6=B2=90=E5=91=80?= <163636894+zimuya4153@users.noreply.github.com> Date: Sat, 20 Jul 2024 21:50:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9ESendContainerClosePacket?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/EventAPI-JS.d.ts | 15 ++++++++++++++- src/EventAPI.cpp | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/EventAPI-JS.d.ts b/lib/EventAPI-JS.d.ts index cb6e598..638e1a2 100644 --- a/lib/EventAPI-JS.d.ts +++ b/lib/EventAPI-JS.d.ts @@ -215,10 +215,23 @@ declare class Event { player: Player, /** 请求类型 */ actionType: string, - /** 容器ID */ + /** 容器类型 */ ContainerNetId: string, /** 请求的槽位 */ slot: number ) => boolean | void ): boolean; + + /** 发送容器关闭数据包后(不可拦截) */ + static listen( + /** 事件名 */ + event: "SendContainerClosePacket", + /** 回调函数 */ + listener: ( + /** 要被关闭的玩家 */ + player: Player, + /** 容器类型 */ + ContainerNetId: string + ) => void + ): boolean; } diff --git a/src/EventAPI.cpp b/src/EventAPI.cpp index fae1556..f9a5d1a 100644 --- a/src/EventAPI.cpp +++ b/src/EventAPI.cpp @@ -289,6 +289,22 @@ void Export_Event_API() { ); return true; } + case doHash("SendContainerClosePacket"): { + auto Call = + RemoteCall::importAs(eventName, eventId); + eventBus->emplaceListener( + [Call](Event::PacketEvent::ContainerClosePacketSendAfterEvent& ev) { + try { + Call( + ev.getServerNetworkHandler() + .getServerPlayer(ev.getNetworkIdentifier(), ev.getPacket().mClientSubId), + magic_enum::enum_name(ev.getPacket().mContainerId).data() + ); + } catch (...) {} + } + ); + return true; + } default: return false; }