diff --git a/LiteLoader/api/Packet.cpp b/LiteLoader/api/Packet.cpp index c3fed7bc80..3b8dabe227 100644 --- a/LiteLoader/api/Packet.cpp +++ b/LiteLoader/api/Packet.cpp @@ -5,7 +5,7 @@ #include namespace packetapi { -LIAPI void sendMessage(ServerPlayer* sp, TextType tp, std::string text) { +LIAPI MyPkt CreateTextPacket(TextType tp, std::string text) { WBStream txtpkws; txtpkws.data.reserve(8 + text.size()); txtpkws.apply((char)tp, (char)0); @@ -28,6 +28,13 @@ LIAPI void sendMessage(ServerPlayer* sp, TextType tp, std::string text) { } txtpkws.apply("", ""); MyPkt pk{txtpkws}; - sp->sendNetworkPacket(pk); + return pk; +} + +LIAPI MyPkt CreateTransferPacket(std::string address, int port) { + WBStream ws; + ws.apply(MCString(address), (unsigned short)port); + MyPkt pk(ws); + return pk; } } // namespace packetapi \ No newline at end of file diff --git a/LiteLoader/api/WPlayer.cpp b/LiteLoader/api/WPlayer.cpp index c7ed17f02f..71d38544bc 100644 --- a/LiteLoader/api/WPlayer.cpp +++ b/LiteLoader/api/WPlayer.cpp @@ -10,7 +10,7 @@ #include LIAPI void WPlayer::sendText(string text, TextType tp) { - packetapi::sendMessage(v, tp, text); + v->sendNetworkPacket(packetapi::CreateTextPacket(tp, text)); } static MSearcherEx MS_NI; static MSearcherEx MS_PC; diff --git a/headers/api/packetApi.h b/headers/api/packetApi.h index cf5985e4fc..500cc66324 100644 --- a/headers/api/packetApi.h +++ b/headers/api/packetApi.h @@ -4,5 +4,6 @@ #include namespace packetapi { -LIAPI void sendMessage(ServerPlayer* sp, TextType tp, std::string text); +LIAPI MyPkt CreateTextPacket(TextType tp, std::string text); +LIAPI MyPkt CreateTransferPacket(std::string address, int port); } \ No newline at end of file