Merge remote-tracking branch 'origin/master' into Ranks
This commit is contained in:
@@ -41,6 +41,7 @@ Implements the 1.7.x protocol classes:
|
||||
#include "../BlockEntities/CommandBlockEntity.h"
|
||||
#include "../BlockEntities/MobHeadEntity.h"
|
||||
#include "../BlockEntities/FlowerPotEntity.h"
|
||||
#include "Bindings/PluginManager.h"
|
||||
|
||||
|
||||
|
||||
@@ -1720,21 +1721,41 @@ void cProtocol172::HandlePacketStatusPing(cByteBuffer & a_ByteBuffer)
|
||||
|
||||
void cProtocol172::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
||||
{
|
||||
// Send the response:
|
||||
AString Response = "{\"version\":{\"name\":\"1.7.2\", \"protocol\":4}, \"players\":{";
|
||||
cServer * Server = cRoot::Get()->GetServer();
|
||||
AppendPrintf(Response, "\"max\":%u, \"online\":%u, \"sample\":[]},",
|
||||
Server->GetMaxPlayers(),
|
||||
Server->GetNumPlayers()
|
||||
);
|
||||
AppendPrintf(Response, "\"description\":{\"text\":\"%s\"},",
|
||||
Server->GetDescription().c_str()
|
||||
);
|
||||
AppendPrintf(Response, "\"favicon\": \"data:image/png;base64,%s\"",
|
||||
Server->GetFaviconData().c_str()
|
||||
);
|
||||
Response.append("}");
|
||||
|
||||
AString ServerDescription = Server->GetDescription();
|
||||
int NumPlayers = Server->GetNumPlayers();
|
||||
int MaxPlayers = Server->GetMaxPlayers();
|
||||
AString Favicon = Server->GetFaviconData();
|
||||
cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon);
|
||||
|
||||
// Version:
|
||||
Json::Value Version;
|
||||
Version["name"] = "1.7.2";
|
||||
Version["protocol"] = 4;
|
||||
|
||||
// Players:
|
||||
Json::Value Players;
|
||||
Players["online"] = NumPlayers;
|
||||
Players["max"] = MaxPlayers;
|
||||
// TODO: Add "sample"
|
||||
|
||||
// Description:
|
||||
Json::Value Description;
|
||||
Description["text"] = ServerDescription.c_str();
|
||||
|
||||
// Create the response:
|
||||
Json::Value ResponseValue;
|
||||
ResponseValue["version"] = Version;
|
||||
ResponseValue["players"] = Players;
|
||||
ResponseValue["description"] = Description;
|
||||
if (!Favicon.empty())
|
||||
{
|
||||
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
|
||||
}
|
||||
|
||||
Json::StyledWriter Writer;
|
||||
AString Response = Writer.write(ResponseValue);
|
||||
|
||||
cPacketizer Pkt(*this, 0x00); // Response packet
|
||||
Pkt.WriteString(Response);
|
||||
}
|
||||
@@ -1803,7 +1824,11 @@ void cProtocol172::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffe
|
||||
void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
|
||||
{
|
||||
AString Username;
|
||||
a_ByteBuffer.ReadVarUTF8String(Username);
|
||||
if (!a_ByteBuffer.ReadVarUTF8String(Username))
|
||||
{
|
||||
m_Client->Kick("Bad username");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_Client->HandleHandshake(Username))
|
||||
{
|
||||
@@ -3070,20 +3095,41 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player)
|
||||
|
||||
void cProtocol176::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
||||
{
|
||||
// Send the response:
|
||||
AString Response = "{\"version\": {\"name\": \"1.7.6\", \"protocol\":5}, \"players\": {";
|
||||
AppendPrintf(Response, "\"max\": %u, \"online\": %u, \"sample\": []},",
|
||||
cRoot::Get()->GetServer()->GetMaxPlayers(),
|
||||
cRoot::Get()->GetServer()->GetNumPlayers()
|
||||
);
|
||||
AppendPrintf(Response, "\"description\": {\"text\": \"%s\"},",
|
||||
cRoot::Get()->GetServer()->GetDescription().c_str()
|
||||
);
|
||||
AppendPrintf(Response, "\"favicon\": \"data:image/png;base64,%s\"",
|
||||
cRoot::Get()->GetServer()->GetFaviconData().c_str()
|
||||
);
|
||||
Response.append("}");
|
||||
|
||||
cServer * Server = cRoot::Get()->GetServer();
|
||||
AString Motd = Server->GetDescription();
|
||||
int NumPlayers = Server->GetNumPlayers();
|
||||
int MaxPlayers = Server->GetMaxPlayers();
|
||||
AString Favicon = Server->GetFaviconData();
|
||||
cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, Motd, NumPlayers, MaxPlayers, Favicon);
|
||||
|
||||
// Version:
|
||||
Json::Value Version;
|
||||
Version["name"] = "1.7.6";
|
||||
Version["protocol"] = 5;
|
||||
|
||||
// Players:
|
||||
Json::Value Players;
|
||||
Players["online"] = NumPlayers;
|
||||
Players["max"] = MaxPlayers;
|
||||
// TODO: Add "sample"
|
||||
|
||||
// Description:
|
||||
Json::Value Description;
|
||||
Description["text"] = Motd.c_str();
|
||||
|
||||
// Create the response:
|
||||
Json::Value ResponseValue;
|
||||
ResponseValue["version"] = Version;
|
||||
ResponseValue["players"] = Players;
|
||||
ResponseValue["description"] = Description;
|
||||
if (!Favicon.empty())
|
||||
{
|
||||
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
|
||||
}
|
||||
|
||||
Json::StyledWriter Writer;
|
||||
AString Response = Writer.write(ResponseValue);
|
||||
|
||||
cPacketizer Pkt(*this, 0x00); // Response packet
|
||||
Pkt.WriteString(Response);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "../Server.h"
|
||||
#include "../World.h"
|
||||
#include "../ChatColor.h"
|
||||
#include "Bindings/PluginManager.h"
|
||||
|
||||
|
||||
|
||||
@@ -1013,6 +1014,13 @@ void cProtocolRecognizer::SendLengthlessServerPing(void)
|
||||
{
|
||||
AString Reply;
|
||||
cServer * Server = cRoot::Get()->GetServer();
|
||||
|
||||
AString ServerDescription = Server->GetDescription();
|
||||
int NumPlayers = Server->GetNumPlayers();
|
||||
int MaxPlayers = Server->GetMaxPlayers();
|
||||
AString Favicon = Server->GetFaviconData();
|
||||
cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon);
|
||||
|
||||
switch (cRoot::Get()->GetPrimaryServerVersion())
|
||||
{
|
||||
case PROTO_VERSION_1_2_5:
|
||||
@@ -1020,11 +1028,11 @@ void cProtocolRecognizer::SendLengthlessServerPing(void)
|
||||
{
|
||||
// http://wiki.vg/wiki/index.php?title=Protocol&oldid=3099#Server_List_Ping_.280xFE.29
|
||||
Printf(Reply, "%s%s%i%s%i",
|
||||
Server->GetDescription().c_str(),
|
||||
ServerDescription.c_str(),
|
||||
cChatColor::Delimiter,
|
||||
Server->GetNumPlayers(),
|
||||
NumPlayers,
|
||||
cChatColor::Delimiter,
|
||||
Server->GetMaxPlayers()
|
||||
MaxPlayers
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -1051,13 +1059,7 @@ void cProtocolRecognizer::SendLengthlessServerPing(void)
|
||||
m_Buffer.ReadByte(val); // 0x01 magic value
|
||||
ASSERT(val == 0x01);
|
||||
}
|
||||
|
||||
// http://wiki.vg/wiki/index.php?title=Server_List_Ping&oldid=3100
|
||||
AString NumPlayers;
|
||||
Printf(NumPlayers, "%d", Server->GetNumPlayers());
|
||||
AString MaxPlayers;
|
||||
Printf(MaxPlayers, "%d", Server->GetMaxPlayers());
|
||||
|
||||
|
||||
AString ProtocolVersionNum;
|
||||
Printf(ProtocolVersionNum, "%d", cRoot::Get()->GetPrimaryServerVersion());
|
||||
AString ProtocolVersionTxt(GetVersionTextFromInt(cRoot::Get()->GetPrimaryServerVersion()));
|
||||
@@ -1070,11 +1072,11 @@ void cProtocolRecognizer::SendLengthlessServerPing(void)
|
||||
Reply.push_back(0);
|
||||
Reply.append(ProtocolVersionTxt);
|
||||
Reply.push_back(0);
|
||||
Reply.append(Server->GetDescription());
|
||||
Reply.append(ServerDescription);
|
||||
Reply.push_back(0);
|
||||
Reply.append(NumPlayers);
|
||||
Reply.append(Printf("%d", NumPlayers));
|
||||
Reply.push_back(0);
|
||||
Reply.append(MaxPlayers);
|
||||
Reply.append(Printf("%d", MaxPlayers));
|
||||
break;
|
||||
}
|
||||
} // switch (m_PrimaryServerVersion)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
// Adjust these if a new protocol is added or an old one is removed:
|
||||
#define MCS_CLIENT_VERSIONS "1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5, 1.5.1, 1.5.2, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.7.2, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 1.7.9"
|
||||
#define MCS_CLIENT_VERSIONS "1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5, 1.5.1, 1.5.2, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.7.2, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 1.7.9, 1.7.10"
|
||||
#define MCS_PROTOCOL_VERSIONS "29, 39, 47, 49, 51, 60, 61, 73, 74, 77, 78, 4, 5"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user