summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Pioch <lukas@zgow.de>2016-10-23 22:52:10 +0200
committerGitHub <noreply@github.com>2016-10-23 22:52:10 +0200
commit824f5dbbd6b88226b6899b7566fecb3af2cc6d58 (patch)
treee73bb368cc26cf3c6b5041bc27ae818ec50a25f9
parentStyleCheck: Add "else has to be on a separate line" (#3412) (diff)
parentAdded SendMessageRaw for sending json string. (diff)
downloadcuberite-824f5dbbd6b88226b6899b7566fecb3af2cc6d58.tar
cuberite-824f5dbbd6b88226b6899b7566fecb3af2cc6d58.tar.gz
cuberite-824f5dbbd6b88226b6899b7566fecb3af2cc6d58.tar.bz2
cuberite-824f5dbbd6b88226b6899b7566fecb3af2cc6d58.tar.lz
cuberite-824f5dbbd6b88226b6899b7566fecb3af2cc6d58.tar.xz
cuberite-824f5dbbd6b88226b6899b7566fecb3af2cc6d58.tar.zst
cuberite-824f5dbbd6b88226b6899b7566fecb3af2cc6d58.zip
-rw-r--r--Server/Plugins/APIDump/APIDesc.lua16
-rw-r--r--src/ClientHandle.cpp9
-rw-r--r--src/ClientHandle.h1
-rw-r--r--src/Entities/Player.h1
-rw-r--r--src/Protocol/Protocol.h1
-rw-r--r--src/Protocol/Protocol18x.cpp14
-rw-r--r--src/Protocol/Protocol18x.h1
-rw-r--r--src/Protocol/Protocol19x.cpp14
-rw-r--r--src/Protocol/Protocol19x.h1
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp10
-rw-r--r--src/Protocol/ProtocolRecognizer.h1
11 files changed, 69 insertions, 0 deletions
diff --git a/Server/Plugins/APIDump/APIDesc.lua b/Server/Plugins/APIDump/APIDesc.lua
index 15960f6d3..4d8499687 100644
--- a/Server/Plugins/APIDump/APIDesc.lua
+++ b/Server/Plugins/APIDump/APIDesc.lua
@@ -11698,6 +11698,22 @@ a_Player:OpenWindow(Window);
},
Notes = "Sends the specified message to the player.",
},
+ SendMessageRaw =
+ {
+ Params =
+ {
+ {
+ Name = "Json",
+ Type = "string",
+ },
+ {
+ Name = "eChatType",
+ Type = "number",
+ IsOptional = true,
+ }
+ },
+ Notes = "Sends the specified json string to the player. The optional value eChatType (default ctChatBox) can be ctChatBox, ctSystem or ctAboveActionBar. You can use {{cJson}} to build a json string.",
+ },
SendMessageFailure =
{
Params =
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 469095b19..fc41a4f7c 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -2271,6 +2271,15 @@ void cClientHandle::SendChat(const cCompositeChat & a_Message)
+void cClientHandle::SendChatRaw(const AString & a_MessageRaw, eChatType a_Type)
+{
+ m_Protocol->SendChatRaw(a_MessageRaw, a_Type);
+}
+
+
+
+
+
void cClientHandle::SendChatAboveActionBar(const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData)
{
cWorld * World = GetPlayer()->GetWorld();
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 4a4c9553d..cadce3c09 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -153,6 +153,7 @@ public: // tolua_export
void SendCameraSetTo (const cEntity & a_Entity);
void SendChat (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = "");
void SendChat (const cCompositeChat & a_Message);
+ void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type);
void SendChatAboveActionBar (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = "");
void SendChatAboveActionBar (const cCompositeChat & a_Message);
void SendChatSystem (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = "");
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 04cb5232b..cc83b1ca2 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -256,6 +256,7 @@ public:
void SendMessageFatal (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtFailure); }
void SendMessagePrivateMsg (const AString & a_Message, const AString & a_Sender) { m_ClientHandle->SendChat(a_Message, mtPrivateMessage, a_Sender); }
void SendMessage (const cCompositeChat & a_Message) { m_ClientHandle->SendChat(a_Message); }
+ void SendMessageRaw (const AString & a_MessageRaw, eChatType a_Type = eChatType::ctChatBox) { m_ClientHandle->SendChatRaw(a_MessageRaw, a_Type); }
void SendSystemMessage (const AString & a_Message) { m_ClientHandle->SendChatSystem(a_Message, mtCustom); }
void SendAboveActionBarMessage(const AString & a_Message) { m_ClientHandle->SendChatAboveActionBar(a_Message, mtCustom); }
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 3874307de..137a47acc 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -72,6 +72,7 @@ public:
virtual void SendCameraSetTo (const cEntity & a_Entity) = 0;
virtual void SendChat (const AString & a_Message, eChatType a_Type) = 0;
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) = 0;
+ virtual void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type) = 0;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) = 0;
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) = 0;
virtual void SendDestroyEntity (const cEntity & a_Entity) = 0;
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index d75ab3a5c..0679219a9 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -284,6 +284,20 @@ void cProtocol180::SendChat(const cCompositeChat & a_Message, eChatType a_Type,
+void cProtocol180::SendChatRaw(const AString & a_MessageRaw, eChatType a_Type)
+{
+ ASSERT(m_State == 3); // In game mode?
+
+ // Send the json string to the client:
+ cPacketizer Pkt(*this, 0x02);
+ Pkt.WriteString(a_MessageRaw);
+ Pkt.WriteBEInt8(a_Type);
+}
+
+
+
+
+
void cProtocol180::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
{
ASSERT(m_State == 3); // In game mode?
diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h
index 6fc2647ed..71bc95ef8 100644
--- a/src/Protocol/Protocol18x.h
+++ b/src/Protocol/Protocol18x.h
@@ -68,6 +68,7 @@ public:
virtual void SendCameraSetTo (const cEntity & a_Entity) override;
virtual void SendChat (const AString & a_Message, eChatType a_Type) override;
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override;
+ virtual void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
diff --git a/src/Protocol/Protocol19x.cpp b/src/Protocol/Protocol19x.cpp
index 6e26b2012..5f3b9ec27 100644
--- a/src/Protocol/Protocol19x.cpp
+++ b/src/Protocol/Protocol19x.cpp
@@ -293,6 +293,20 @@ void cProtocol190::SendChat(const cCompositeChat & a_Message, eChatType a_Type,
+void cProtocol190::SendChatRaw(const AString & a_MessageRaw, eChatType a_Type)
+{
+ ASSERT(m_State == 3); // In game mode?
+
+ // Send the json string to the client:
+ cPacketizer Pkt(*this, 0x0f); // Chat Message packet
+ Pkt.WriteString(a_MessageRaw);
+ Pkt.WriteBEInt8(a_Type);
+}
+
+
+
+
+
void cProtocol190::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
{
ASSERT(m_State == 3); // In game mode?
diff --git a/src/Protocol/Protocol19x.h b/src/Protocol/Protocol19x.h
index d46da2a0f..64cad081f 100644
--- a/src/Protocol/Protocol19x.h
+++ b/src/Protocol/Protocol19x.h
@@ -74,6 +74,7 @@ public:
virtual void SendCameraSetTo (const cEntity & a_Entity) override;
virtual void SendChat (const AString & a_Message, eChatType a_Type) override;
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override;
+ virtual void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index be97279a9..0c67f66f5 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -200,6 +200,16 @@ void cProtocolRecognizer::SendChat(const cCompositeChat & a_Message, eChatType a
+void cProtocolRecognizer::SendChatRaw(const AString & a_MessageRaw, eChatType a_Type)
+{
+ ASSERT(m_Protocol != nullptr);
+ m_Protocol->SendChatRaw(a_MessageRaw, a_Type);
+}
+
+
+
+
+
void cProtocolRecognizer::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
{
ASSERT(m_Protocol != nullptr);
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index 24e3e214e..560819705 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -59,6 +59,7 @@ public:
virtual void SendCameraSetTo (const cEntity & a_Entity) override;
virtual void SendChat (const AString & a_Message, eChatType a_Type) override;
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override;
+ virtual void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;