From 6615a6f83745fa8de3a711d8a03f8f0b6544df39 Mon Sep 17 00:00:00 2001 From: ShrBox Date: Sat, 20 Jan 2024 15:10:17 +0800 Subject: [PATCH] fix: fix onRespawn --- src/api/EventAPI.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/api/EventAPI.cpp b/src/api/EventAPI.cpp index 88c11f90..35e1fc33 100644 --- a/src/api/EventAPI.cpp +++ b/src/api/EventAPI.cpp @@ -21,6 +21,7 @@ #include "ll/api/event/player/PlayerDieEvent.h" #include "ll/api/event/player/PlayerJoinEvent.h" #include "ll/api/event/player/PlayerLeaveEvent.h" +#include "ll/api/event/player/PlayerRespawnEvent.h" #include "mc/world/actor/player/Player.h" #include "mc/world/level/dimension/Dimension.h" @@ -426,15 +427,16 @@ void EnableEventListener(int eventId) { }); break; - // case EVENT_TYPES::onRespawn: - // Event::PlayerRespawnEvent::subscribe([](const PlayerRespawnEvent &ev) { - // IF_LISTENED(EVENT_TYPES::onRespawn) { - // CallEvent(EVENT_TYPES::onRespawn, - // PlayerClass::newPlayer((Player *)ev.mPlayer)); - // } - // IF_LISTENED_END(EVENT_TYPES::onRespawn) - // }); - // break; + case EVENT_TYPES::onRespawn: + bus.emplaceListener( + [](ll::event::PlayerRespawnEvent &ev) { + IF_LISTENED(EVENT_TYPES::onRespawn) { + CallEvent(EVENT_TYPES::onRespawn, + PlayerClass::newPlayer(&ev.self())); + } + IF_LISTENED_END(EVENT_TYPES::onRespawn) + }); + break; // case EVENT_TYPES::onStartDestroyBlock: // Event::PlayerStartDestroyBlockEvent::subscribe(