diff --git a/src-server/ll/api/event/player/PlayerChatEvent.cpp b/src-server/ll/api/event/player/PlayerChatEvent.cpp index 111aa90f82..fea6bf3ecc 100644 --- a/src-server/ll/api/event/player/PlayerChatEvent.cpp +++ b/src-server/ll/api/event/player/PlayerChatEvent.cpp @@ -30,7 +30,8 @@ LL_TYPE_INSTANCE_HOOK( NetworkIdentifier const& identifier, TextPacket const& packet ) { - if (auto player = _getServerPlayer(identifier, packet.mClientSubId); player) { + auto& handle = ll::memory::dAccess(this, -16); + if (auto player = handle._getServerPlayer(identifier, packet.mClientSubId); player) { auto event = PlayerChatEvent{*player, const_cast(packet).mMessage}; EventBus::getInstance().publish(event); if (event.isCancelled()) { diff --git a/src-server/ll/api/event/player/PlayerJoinEvent.cpp b/src-server/ll/api/event/player/PlayerJoinEvent.cpp index 123a5f6794..372e9c68aa 100644 --- a/src-server/ll/api/event/player/PlayerJoinEvent.cpp +++ b/src-server/ll/api/event/player/PlayerJoinEvent.cpp @@ -4,6 +4,7 @@ #include "mc/network/ServerNetworkHandler.h" #include "mc/network/packet/SetLocalPlayerAsInitializedPacket.h" +#include "mc/server/ServerPlayer.h" namespace ll::event::inline player { @@ -16,7 +17,8 @@ LL_TYPE_INSTANCE_HOOK( NetworkIdentifier const& identifier, SetLocalPlayerAsInitializedPacket const& packet ) { - if (auto player = _getServerPlayer(identifier, packet.mClientSubId); player) { + auto& handle = ll::memory::dAccess(this, -16); + if (auto player = handle._getServerPlayer(identifier, packet.mClientSubId); player) { auto event = PlayerJoinEvent{*player}; EventBus::getInstance().publish(event); if (event.isCancelled()) { diff --git a/src-server/ll/api/event/player/PlayerSneakAndSprintEvent.cpp b/src-server/ll/api/event/player/PlayerSneakAndSprintEvent.cpp index 24bb9f052c..30196791f8 100644 --- a/src-server/ll/api/event/player/PlayerSneakAndSprintEvent.cpp +++ b/src-server/ll/api/event/player/PlayerSneakAndSprintEvent.cpp @@ -17,19 +17,20 @@ LL_TYPE_INSTANCE_HOOK( NetworkIdentifier const& id, PlayerActionPacket const& packet ) { + auto& handle = ll::memory::dAccess(this, -16); switch (packet.mAction) { case PlayerActionType::StartSprinting: - if (auto player = this->_getServerPlayer(id, packet.mClientSubId); player) { + if (auto player = handle._getServerPlayer(id, packet.mClientSubId); player) { EventBus::getInstance().publish(PlayerSprintingEvent(*player)); break; } case PlayerActionType::StopSprinting: - if (auto player = this->_getServerPlayer(id, packet.mClientSubId); player) { + if (auto player = handle._getServerPlayer(id, packet.mClientSubId); player) { EventBus::getInstance().publish(PlayerSprintedEvent(*player)); break; } case PlayerActionType::StartSneaking: - if (auto player = this->_getServerPlayer(id, packet.mClientSubId); player) { + if (auto player = handle._getServerPlayer(id, packet.mClientSubId); player) { auto ev = PlayerSneakingEvent(*player); EventBus::getInstance().publish(ev); if (ev.isCancelled()) { diff --git a/src-server/ll/api/event/player/PlayerSwingEvent.cpp b/src-server/ll/api/event/player/PlayerSwingEvent.cpp index 96fbac5614..13f296c552 100644 --- a/src-server/ll/api/event/player/PlayerSwingEvent.cpp +++ b/src-server/ll/api/event/player/PlayerSwingEvent.cpp @@ -17,8 +17,9 @@ LL_TYPE_INSTANCE_HOOK( NetworkIdentifier const& id, AnimatePacket const& packet ) { + auto& handle = ll::memory::dAccess(this, -16); if (packet.mAction == AnimatePacket::Action::Swing) { - if (auto player = this->_getServerPlayer(id, packet.mClientSubId); player) { + if (auto player = handle._getServerPlayer(id, packet.mClientSubId); player) { EventBus::getInstance().publish(PlayerSwingEvent(*player)); } } diff --git a/src-server/ll/core/form/FormHandler.cpp b/src-server/ll/core/form/FormHandler.cpp index 77d5db461b..2d9e44da25 100644 --- a/src-server/ll/core/form/FormHandler.cpp +++ b/src-server/ll/core/form/FormHandler.cpp @@ -155,8 +155,8 @@ LL_TYPE_INSTANCE_HOOK( NetEventCallback& callback, std::shared_ptr& packet ) { - if (auto player = static_cast(callback)._getServerPlayer(source, SubClientId::PrimaryClient); - player) { + auto& handle = ll::memory::dAccess(&callback, -16); + if (auto player = handle._getServerPlayer(source, packet->mClientSubId); player) { auto& modalPacket = (ModalFormResponsePacket&)*packet; if (ll::form::handler::handleFormPacket( diff --git a/src/ll/api/event/player/PlayerJumpEvent.cpp b/src/ll/api/event/player/PlayerJumpEvent.cpp index 6da5affb66..b930f974fd 100644 --- a/src/ll/api/event/player/PlayerJumpEvent.cpp +++ b/src/ll/api/event/player/PlayerJumpEvent.cpp @@ -7,7 +7,7 @@ #include "mc/server/ServerPlayer.h" namespace ll::event::inline player { -LL_AUTO_TYPE_INSTANCE_HOOK( +LL_TYPE_INSTANCE_HOOK( PlayerJumpEventHook, HookPriority::Normal, ServerNetworkHandler, @@ -17,10 +17,9 @@ LL_AUTO_TYPE_INSTANCE_HOOK( ::PlayerAuthInputPacket const& packet ) { auto& handle = ll::memory::dAccess(this, -16); - if (ServerPlayer* player = handle._getServerPlayer(source, packet.mClientSubId)) { + if (ServerPlayer* player = handle._getServerPlayer(source, packet.mClientSubId); player) { if (packet.getInput(::PlayerAuthInputPacket::InputData::StartJumping)) { - std::cout << player->getRealName() << std::endl; - EventBus::getInstance().publish(PlayerJumpEvent(*(Player*)player)); + EventBus::getInstance().publish(PlayerJumpEvent(*player)); } } return origin(source, packet);