summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol19x.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Protocol/Protocol19x.cpp')
-rw-r--r--src/Protocol/Protocol19x.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/Protocol/Protocol19x.cpp b/src/Protocol/Protocol19x.cpp
index c11e05565..a8c916e5b 100644
--- a/src/Protocol/Protocol19x.cpp
+++ b/src/Protocol/Protocol19x.cpp
@@ -22,6 +22,7 @@ Implements the 1.9.x protocol classes:
#include "Packetizer.h"
#include "../ClientHandle.h"
+#include "../ChannelManager.h"
#include "../Root.h"
#include "../Server.h"
#include "../World.h"
@@ -2552,10 +2553,24 @@ void cProtocol190::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer)
return;
}
- // Read the plugin message and relay to clienthandle:
+ // Read the rest of the message
+ cByteBuffer Buffer = a_ByteBuffer;
AString Data;
VERIFY(a_ByteBuffer.ReadString(Data, a_ByteBuffer.GetReadableSpace() - 1)); // Always succeeds
- m_Client->HandlePluginMessage(Channel, Data);
+
+ auto manager = cRoot::Get()->GetServer()->GetChannelManager();
+ // Register the client on the requested channels
+ if (Channel == "REGISTER")
+ {
+ manager->AddClientToChannels(*m_Client, Data);
+ }
+ else if (Channel == "UNREGISTER")
+ {
+ manager->RemoveClientFromChannels(*m_Client, Data);
+ }
+
+ // Call the channel message handler
+ manager->HandleChannelMessage(*m_Client, Channel, Buffer);
}
@@ -2843,10 +2858,7 @@ void cProtocol190::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const
}
LOG("Unhandled vanilla plugin channel: \"%s\".", a_Channel.c_str());
- // Read the payload and send it through to the clienthandle:
- AString Message;
- VERIFY(a_ByteBuffer.ReadString(Message, a_ByteBuffer.GetReadableSpace() - 1));
- m_Client->HandlePluginMessage(a_Channel, Message);
+ cRoot::Get()->GetServer()->GetChannelManager()->HandleChannelMessage(*m_Client, a_Channel, a_ByteBuffer);
}
@@ -4381,8 +4393,3 @@ void cProtocol194::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, cons
Writer.Finish();
Pkt.WriteBuf(Writer.GetResult().data(), Writer.GetResult().size());
}
-
-
-
-
-