diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-07-18 19:57:23 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-07-18 20:23:10 +0200 |
commit | 5141d05ba676df9584831ffa9ff6e8ff8905887d (patch) | |
tree | 34a516e598fb0aeece8d728ad8f978d3d00fd0d0 /src/Protocol/Protocol_1_11.cpp | |
parent | 1.13 items support (diff) | |
download | cuberite-5141d05ba676df9584831ffa9ff6e8ff8905887d.tar cuberite-5141d05ba676df9584831ffa9ff6e8ff8905887d.tar.gz cuberite-5141d05ba676df9584831ffa9ff6e8ff8905887d.tar.bz2 cuberite-5141d05ba676df9584831ffa9ff6e8ff8905887d.tar.lz cuberite-5141d05ba676df9584831ffa9ff6e8ff8905887d.tar.xz cuberite-5141d05ba676df9584831ffa9ff6e8ff8905887d.tar.zst cuberite-5141d05ba676df9584831ffa9ff6e8ff8905887d.zip |
Diffstat (limited to 'src/Protocol/Protocol_1_11.cpp')
-rw-r--r-- | src/Protocol/Protocol_1_11.cpp | 92 |
1 files changed, 11 insertions, 81 deletions
diff --git a/src/Protocol/Protocol_1_11.cpp b/src/Protocol/Protocol_1_11.cpp index 84151b4a9..20b26b31a 100644 --- a/src/Protocol/Protocol_1_11.cpp +++ b/src/Protocol/Protocol_1_11.cpp @@ -540,6 +540,15 @@ void cProtocol_1_11_0::SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int +cProtocol::Version cProtocol_1_11_0::GetProtocolVersion() +{ + return Version::Version_1_11_0; +} + + + + + UInt32 cProtocol_1_11_0::GetProtocolMobType(eMonsterType a_MobType) { switch (a_MobType) @@ -607,50 +616,6 @@ void cProtocol_1_11_0::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) -void cProtocol_1_11_0::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) -{ - cServer * Server = cRoot::Get()->GetServer(); - AString ServerDescription = Server->GetDescription(); - auto NumPlayers = static_cast<signed>(Server->GetNumPlayers()); - auto MaxPlayers = static_cast<signed>(Server->GetMaxPlayers()); - AString Favicon = Server->GetFaviconData(); - cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon); - - // Version: - Json::Value Version; - Version["name"] = "Cuberite 1.11"; - Version["protocol"] = cMultiVersionProtocol::PROTO_VERSION_1_11_0; - - // 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; - m_Client->ForgeAugmentServerListPing(ResponseValue); - if (!Favicon.empty()) - { - ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str()); - } - - // Serialize the response into a packet: - cPacketizer Pkt(*this, pktStatusResponse); - Pkt.WriteString(JsonUtils::WriteFastString(ResponseValue)); -} - - - - - void cProtocol_1_11_0::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) { using namespace Metadata_1_11; @@ -1229,42 +1194,7 @@ cProtocol_1_11_1::cProtocol_1_11_1(cClientHandle * a_Client, const AString & a_S -void cProtocol_1_11_1::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) +cProtocol::Version cProtocol_1_11_1::GetProtocolVersion() { - cServer * Server = cRoot::Get()->GetServer(); - AString ServerDescription = Server->GetDescription(); - auto NumPlayers = static_cast<signed>(Server->GetNumPlayers()); - auto MaxPlayers = static_cast<signed>(Server->GetMaxPlayers()); - AString Favicon = Server->GetFaviconData(); - cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon); - - // Version: - Json::Value Version; - Version["name"] = "Cuberite 1.11.1"; - Version["protocol"] = cMultiVersionProtocol::PROTO_VERSION_1_11_1; - - // 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; - m_Client->ForgeAugmentServerListPing(ResponseValue); - if (!Favicon.empty()) - { - ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str()); - } - - // Serialize the response into a packet: - cPacketizer Pkt(*this, pktStatusResponse); - Pkt.WriteString(JsonUtils::WriteFastString(ResponseValue)); + return Version::Version_1_11_1; } |