summaryrefslogtreecommitdiffstats
path: root/src/Protocol/ProtocolRecognizer.cpp
diff options
context:
space:
mode:
authorSTRWarrior <STRWarrior@users.noreply.github.com>2014-08-20 22:57:48 +0200
committerSTRWarrior <STRWarrior@users.noreply.github.com>2014-08-20 22:57:48 +0200
commit3a113e3a75bb345d008e13bbecae5f78ed9d9aae (patch)
treed2d17b4c0091905cb55245305292ada6dcb11d71 /src/Protocol/ProtocolRecognizer.cpp
parentMerge pull request #1335 from mc-server/CodeFixes (diff)
parentRenamed a_Motd to a_ServerDescription. (diff)
downloadcuberite-3a113e3a75bb345d008e13bbecae5f78ed9d9aae.tar
cuberite-3a113e3a75bb345d008e13bbecae5f78ed9d9aae.tar.gz
cuberite-3a113e3a75bb345d008e13bbecae5f78ed9d9aae.tar.bz2
cuberite-3a113e3a75bb345d008e13bbecae5f78ed9d9aae.tar.lz
cuberite-3a113e3a75bb345d008e13bbecae5f78ed9d9aae.tar.xz
cuberite-3a113e3a75bb345d008e13bbecae5f78ed9d9aae.tar.zst
cuberite-3a113e3a75bb345d008e13bbecae5f78ed9d9aae.zip
Diffstat (limited to 'src/Protocol/ProtocolRecognizer.cpp')
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index 18694572a..c831da251 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -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)