parent
9af16c3f28
commit
ada54b79d7
@ -171,7 +171,13 @@ public:
|
|||||||
void HandleCreativeInventory(short a_SlotNum, const cItem & a_HeldItem);
|
void HandleCreativeInventory(short a_SlotNum, const cItem & a_HeldItem);
|
||||||
void HandleDisconnect (const AString & a_Reason);
|
void HandleDisconnect (const AString & a_Reason);
|
||||||
void HandleEntityAction (int a_EntityID, char a_ActionID);
|
void HandleEntityAction (int a_EntityID, char a_ActionID);
|
||||||
|
|
||||||
|
/** Called when the protocol handshake has been received (for protocol versions that support it;
|
||||||
|
otherwise the first instant when a username is received).
|
||||||
|
Returns true if the player is to be let in, false if they were disconnected
|
||||||
|
*/
|
||||||
bool HandleHandshake (const AString & a_Username);
|
bool HandleHandshake (const AString & a_Username);
|
||||||
|
|
||||||
void HandleKeepAlive (int a_KeepAliveID);
|
void HandleKeepAlive (int a_KeepAliveID);
|
||||||
void HandleLeftClick (int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status);
|
void HandleLeftClick (int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status);
|
||||||
void HandlePing (void);
|
void HandlePing (void);
|
||||||
|
@ -216,8 +216,23 @@ void cProtocol172::SendDestroyEntity(const cEntity & a_Entity)
|
|||||||
|
|
||||||
void cProtocol172::SendDisconnect(const AString & a_Reason)
|
void cProtocol172::SendDisconnect(const AString & a_Reason)
|
||||||
{
|
{
|
||||||
cPacketizer Pkt(*this, 0x40);
|
switch (m_State)
|
||||||
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Reason).c_str()));
|
{
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
// During login:
|
||||||
|
cPacketizer Pkt(*this, 0);
|
||||||
|
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Reason).c_str()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
// In-game:
|
||||||
|
cPacketizer Pkt(*this, 0x40);
|
||||||
|
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Reason).c_str()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1156,6 +1171,12 @@ void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
|
|||||||
|
|
||||||
// TODO: Protocol encryption should be set up here if not localhost / auth
|
// TODO: Protocol encryption should be set up here if not localhost / auth
|
||||||
|
|
||||||
|
if (!m_Client->HandleHandshake(Username))
|
||||||
|
{
|
||||||
|
// The client is not welcome here, they have been sent a Kick packet already
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Send login success:
|
// Send login success:
|
||||||
{
|
{
|
||||||
cPacketizer Pkt(*this, 0x02); // Login success packet
|
cPacketizer Pkt(*this, 0x02); // Login success packet
|
||||||
|
Loading…
Reference in New Issue
Block a user