Botcraft 1.21.4
Loading...
Searching...
No Matches
ServerboundChatPacket.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4
5#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
6#if PROTOCOL_VERSION < 760 /* < 1.19.1 */
8#else
10#endif
11#endif
13
14namespace ProtocolCraft
15{
16 class ServerboundChatPacket : public BaseMessage<ServerboundChatPacket>
17 {
18 public:
19 static constexpr std::string_view packet_name = "Chat";
20
21#if PROTOCOL_VERSION < 759 /* < 1.19 */
22 SERIALIZED_FIELD(Message, std::string);
23#elif PROTOCOL_VERSION < 760 /* < 1.19.1 */
24 SERIALIZED_FIELD(Message, std::string);
25 SERIALIZED_FIELD(Timestamp, long long int);
27 SERIALIZED_FIELD(SignedPreview, bool);
28#elif PROTOCOL_VERSION < 761 /* < 1.19.3 */
29 SERIALIZED_FIELD(Message, std::string);
30 SERIALIZED_FIELD(Timestamp, long long int);
31 SERIALIZED_FIELD(Salt, long long int);
32 SERIALIZED_FIELD(Signature, std::vector<unsigned char>);
33 SERIALIZED_FIELD(SignedPreview, bool);
35#else
37 SERIALIZED_FIELD(Timestamp, long long int);
38 SERIALIZED_FIELD(Salt, long long int);
39 SERIALIZED_FIELD(Signature, std::optional<std::array<unsigned char, 256>>);
41#endif
43
44#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
45 public:
46 // Convenient set from a std::vector
47 auto& SetSignature(const std::vector<unsigned char>& signature)
48 {
49 std::array<unsigned char, 256> new_signature{};
50 std::copy_n(signature.begin(), 256, new_signature.begin());
51 return SetSignature(new_signature);
52 }
53#endif
54 };
55} //ProtocolCraft
#define SERIALIZED_FIELD(Name,...)
SERIALIZED_FIELD(Salt, long long int)
SERIALIZED_FIELD(LastSeenMessages, LastSeenMessagesUpdate)
SERIALIZED_FIELD(Message, std::string)
static constexpr std::string_view packet_name
SERIALIZED_FIELD(Timestamp, long long int)
auto & SetSignature(const std::vector< unsigned char > &signature)
SERIALIZED_FIELD(Signature, std::optional< std::array< unsigned char, 256 > >)