Botcraft 1.21.4
Loading...
Searching...
No Matches
PropertyMatcher.hpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
2#pragma once
6
7#include <string>
8#include <optional>
9
10namespace ProtocolCraft
11{
12 namespace Components
13 {
15 {
16 private: using THIS = PropertyMatcher;
17
19 DEFINE_CONDITION(IsRangedMatcher, !GetIsExactMatcher());
20
21 SERIALIZED_FIELD(Name, std::string);
25
27
30
31 protected:
32 bool GetIsExactMatcher() const
33 {
34 return IsExactMatcher_;
35 }
36
37 public:
38 auto& SetRangedMatcher(const std::optional<ProtocolCraft::Components::RangedMatcher>& RangedMatcher_)
39 {
40 RangedMatcher = RangedMatcher_;
41 IsExactMatcher_ = !RangedMatcher.has_value();
42 if (RangedMatcher.has_value())
43 {
44 ExactMatcher = std::nullopt;
45 }
46 return *this;
47 }
48
49 auto& SetExactMatcher(const std::optional<ProtocolCraft::Components::ExactMatcher>& ExactMatcher_)
50 {
51 ExactMatcher = ExactMatcher_;
52 IsExactMatcher_ = ExactMatcher.has_value();
53 if (ExactMatcher.has_value())
54 {
55 RangedMatcher = std::nullopt;
56 }
57 return *this;
58 }
59 };
60 }
61}
62#endif
auto & SetExactMatcher(const std::optional< ProtocolCraft::Components::ExactMatcher > &ExactMatcher_)
DEFINE_CONDITION(IsRangedMatcher, !GetIsExactMatcher())
SERIALIZED_FIELD_WITHOUT_GETTER_SETTER(IsExactMatcher_, bool)
SERIALIZED_FIELD_WITHOUT_GETTER_SETTER(RangedMatcher, Internal::Conditioned< ProtocolCraft::Components::RangedMatcher, &THIS::IsRangedMatcher >)
DEFINE_CONDITION(IsExactMatcher, GetIsExactMatcher())
auto & SetRangedMatcher(const std::optional< ProtocolCraft::Components::RangedMatcher > &RangedMatcher_)
SERIALIZED_FIELD_WITHOUT_GETTER_SETTER(ExactMatcher, Internal::Conditioned< ProtocolCraft::Components::ExactMatcher, &THIS::IsExactMatcher >)
A type wrapper to conditionally serialize a type.
Definition Templates.hpp:83