diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-11-23 18:16:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 18:16:25 +0100 |
commit | 7c7890c658616222c6aba6dde365f757f75005d6 (patch) | |
tree | e76a422bdabaa26a3ac8448042a21653f4a545ae /src/Protocol/Protocol_1_13.cpp | |
parent | Dump the api as well as checking it. (diff) | |
download | cuberite-7c7890c658616222c6aba6dde365f757f75005d6.tar cuberite-7c7890c658616222c6aba6dde365f757f75005d6.tar.gz cuberite-7c7890c658616222c6aba6dde365f757f75005d6.tar.bz2 cuberite-7c7890c658616222c6aba6dde365f757f75005d6.tar.lz cuberite-7c7890c658616222c6aba6dde365f757f75005d6.tar.xz cuberite-7c7890c658616222c6aba6dde365f757f75005d6.tar.zst cuberite-7c7890c658616222c6aba6dde365f757f75005d6.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Protocol/Protocol_1_13.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp index 5662fc45e..f6919388c 100644 --- a/src/Protocol/Protocol_1_13.cpp +++ b/src/Protocol/Protocol_1_13.cpp @@ -30,6 +30,7 @@ Implements the 1.13 protocol classes: #include "../World.h" #include "../JsonUtils.h" #include "../WorldStorage/FastNBT.h" +#include "WorldStorage/NamespaceSerializer.h" #include "../Bindings/PluginManager.h" @@ -658,24 +659,22 @@ bool cProtocol_1_13::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketTyp void cProtocol_1_13::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer) { - HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Channel); + HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, NamespacedChannel); + + const auto & [Namespace, Channel] = NamespaceSerializer::SplitNamespacedID(NamespacedChannel); // If the plugin channel is recognized vanilla, handle it directly: - if (Channel.substr(0, 15) == "minecraft:brand") + if (Namespace == NamespaceSerializer::Namespace::Minecraft) { - HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Brand); - m_Client->SetClientBrand(Brand); - - // Send back our brand, including the length: - m_Client->SendPluginMessage("minecraft:brand", "\x08""Cuberite"); + HandleVanillaPluginMessage(a_ByteBuffer, Channel); return; } ContiguousByteBuffer Data; // Read the plugin message and relay to clienthandle: - VERIFY(a_ByteBuffer.ReadSome(Data, a_ByteBuffer.GetReadableSpace())); // Always succeeds - m_Client->HandlePluginMessage(Channel, Data); + a_ByteBuffer.ReadSome(Data, a_ByteBuffer.GetReadableSpace()); + m_Client->HandlePluginMessage(NamespacedChannel, Data); } @@ -693,6 +692,21 @@ void cProtocol_1_13::HandlePacketSetBeaconEffect(cByteBuffer & a_ByteBuffer) +void cProtocol_1_13::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const std::string_view a_Channel) +{ + if (a_Channel == "brand") + { + HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Brand); + + m_Client->SetClientBrand(Brand); + m_Client->SendPluginMessage("brand", "\x08""Cuberite"); // Send back our brand, including the length. + } +} + + + + + bool cProtocol_1_13::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a_KeepRemainingBytes) const { HANDLE_PACKET_READ(a_ByteBuffer, ReadBEInt16, Int16, ItemID); |