summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol_1_9.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-07-18 19:57:23 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-07-18 20:23:10 +0200
commit5141d05ba676df9584831ffa9ff6e8ff8905887d (patch)
tree34a516e598fb0aeece8d728ad8f978d3d00fd0d0 /src/Protocol/Protocol_1_9.cpp
parent1.13 items support (diff)
downloadcuberite-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 '')
-rw-r--r--src/Protocol/Protocol_1_9.cpp188
1 files changed, 22 insertions, 166 deletions
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index e17832175..90e770134 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -581,6 +581,15 @@ UInt32 cProtocol_1_9_0::GetPacketID(cProtocol::ePacketType a_Packet)
+cProtocol::Version cProtocol_1_9_0::GetProtocolVersion()
+{
+ return Version::Version_1_9_0;
+}
+
+
+
+
+
bool cProtocol_1_9_0::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
{
switch (m_State)
@@ -673,51 +682,6 @@ bool cProtocol_1_9_0::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketTy
-void cProtocol_1_9_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.9";
- Version["protocol"] = 107;
-
- // 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());
- }
-
- auto Response = JsonUtils::WriteFastString(ResponseValue);
-
- cPacketizer Pkt(*this, pktStatusResponse);
- Pkt.WriteString(Response);
-}
-
-
-
-
-
void cProtocol_1_9_0::HandlePacketAnimation(cByteBuffer & a_ByteBuffer)
{
HANDLE_READ(a_ByteBuffer, ReadVarInt, Int32, Hand);
@@ -2251,45 +2215,9 @@ void cProtocol_1_9_1::SendLogin(const cPlayer & a_Player, const cWorld & a_World
-void cProtocol_1_9_1::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
+cProtocol::Version cProtocol_1_9_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.9.1";
- Version["protocol"] = 108;
-
- // 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());
- }
-
- AString Response = JsonUtils::WriteFastString(ResponseValue);
-
- cPacketizer Pkt(*this, pktStatusResponse);
- Pkt.WriteString(Response);
+ return Version::Version_1_9_1;
}
@@ -2308,45 +2236,9 @@ cProtocol_1_9_2::cProtocol_1_9_2(cClientHandle * a_Client, const AString & a_Ser
-void cProtocol_1_9_2::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
+cProtocol::Version cProtocol_1_9_2::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.9.2";
- Version["protocol"] = 109;
-
- // 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());
- }
-
- AString Response = JsonUtils::WriteFastString(ResponseValue);
-
- cPacketizer Pkt(*this, pktStatusResponse);
- Pkt.WriteString(Response);
+ return Version::Version_1_9_2;
}
@@ -2365,51 +2257,6 @@ cProtocol_1_9_4::cProtocol_1_9_4(cClientHandle * a_Client, const AString & a_Ser
-void cProtocol_1_9_4::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.9.4";
- Version["protocol"] = 110;
-
- // 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());
- }
-
- AString Response = JsonUtils::WriteFastString(ResponseValue);
-
- cPacketizer Pkt(*this, pktStatusResponse);
- Pkt.WriteString(Response);
-}
-
-
-
-
-
void cProtocol_1_9_4::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
{
ASSERT(m_State == 3); // In game mode?
@@ -2462,6 +2309,15 @@ void cProtocol_1_9_4::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, c
+cProtocol::Version cProtocol_1_9_4::GetProtocolVersion()
+{
+ return Version::Version_1_9_4;
+}
+
+
+
+
+
UInt32 cProtocol_1_9_4::GetPacketID(cProtocol::ePacketType a_Packet)
{
switch (a_Packet)