Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request LiteLDev#59 from LiteLDev/dev
Browse files Browse the repository at this point in the history
Update Packet.cpp
  • Loading branch information
ShrBox authored Oct 2, 2021
2 parents 9245a01 + c9ddabb commit ee8c5b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions LiteLoader/api/Packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <mc/Player.h>

namespace packetapi {
LIAPI void sendMessage(ServerPlayer* sp, TextType tp, std::string text) {
LIAPI MyPkt<MinecraftPacketIds(0x09)> CreateTextPacket(TextType tp, std::string text) {
WBStream txtpkws;
txtpkws.data.reserve(8 + text.size());
txtpkws.apply((char)tp, (char)0);
Expand All @@ -28,6 +28,13 @@ LIAPI void sendMessage(ServerPlayer* sp, TextType tp, std::string text) {
}
txtpkws.apply("", "");
MyPkt<MinecraftPacketIds(0x09)> pk{txtpkws};
sp->sendNetworkPacket(pk);
return pk;
}

LIAPI MyPkt<MinecraftPacketIds(0x55), false> CreateTransferPacket(std::string address, int port) {
WBStream ws;
ws.apply(MCString(address), (unsigned short)port);
MyPkt<MinecraftPacketIds(0x55), false> pk(ws);
return pk;
}
} // namespace packetapi
2 changes: 1 addition & 1 deletion LiteLoader/api/WPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <api/packetApi.h>

LIAPI void WPlayer::sendText(string text, TextType tp) {
packetapi::sendMessage(v, tp, text);
v->sendNetworkPacket(packetapi::CreateTextPacket(tp, text));
}
static MSearcherEx<NetworkIdentifier> MS_NI;
static MSearcherEx<Certificate*> MS_PC;
Expand Down
3 changes: 2 additions & 1 deletion headers/api/packetApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
#include <mc/Player.h>

namespace packetapi {
LIAPI void sendMessage(ServerPlayer* sp, TextType tp, std::string text);
LIAPI MyPkt<MinecraftPacketIds(0x09)> CreateTextPacket(TextType tp, std::string text);
LIAPI MyPkt<MinecraftPacketIds(0x55), false> CreateTransferPacket(std::string address, int port);
}

0 comments on commit ee8c5b0

Please # to comment.