LeviLamina
Loading...
Searching...
No Matches
CommandRegistry.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/network/packet/AvailableCommandsPacket.h"
5#include "mc/server/commands/BlockStateCommandParam.h"
6#include "mc/server/commands/CommandChainedSubcommand.h"
7#include "mc/server/commands/CommandCompareOperator.h"
8#include "mc/server/commands/CommandFilePath.h"
9#include "mc/server/commands/CommandIntegerRange.h"
10#include "mc/server/commands/CommandMessage.h"
11#include "mc/server/commands/CommandOperator.h"
12#include "mc/server/commands/CommandRawText.h"
13#include "mc/server/commands/CommandWildcardInt.h"
14#include "mc/server/commands/WildcardCommandSelector.h"
15
16// auto generated inclusion list
17#include "mc/deps/core/utility/typeid_t.h"
18#include "mc/platform/UUID.h"
19#include "mc/platform/brstd/associative_adapter.h"
20#include "mc/platform/brstd/copyable_function.h"
21#include "mc/server/commands/CommandFlag.h"
22#include "mc/server/commands/CommandLexer.h"
23#include "mc/server/commands/CommandPermissionLevel.h"
24#include "mc/server/commands/CommandSelector.h"
25#include "mc/server/commands/CommandStatus.h"
26#include "mc/server/commands/CommandTypeFlag.h"
27#include "mc/server/commands/CommandVersion.h"
28#include "mc/server/commands/SemanticConstraint.h"
29#include "mc/world/actor/selectors/InvertableFilter.h"
30
31// auto generated forward declare list
32// clang-format off
33class Actor;
35class BlockType;
36class Command;
37class CommandOrigin;
39class CommandRunStats;
42class Packet;
43class PlayerListEntry;
48namespace Json { class Value; }
49// clang-format on
50
51class CommandRegistry {
52public:
53 // CommandRegistry inner types declare
54 // clang-format off
55 struct RegistryState;
56 struct SoftEnum;
57 class Symbol;
58 struct ConstrainedValue;
59 struct Factorization;
60 struct LexicalToken;
62 struct Overload;
63 struct ParamSymbols;
64 struct ParseToken;
65 struct ChainedSubcommand;
66 struct Enum;
67 struct ParamParseRule;
68 struct ParseRule;
69 struct SemanticInfo;
70 struct Signature;
71 struct SymbolHasher;
72 struct SymbolPairHasher;
73 struct ParseTable;
74 class Parser;
75 // clang-format on
76
77 // CommandRegistry inner types define
78
79 using ParseFunction = bool (::CommandRegistry::*)(
80 void*,
82 ::CommandOrigin const&,
83 int,
84 ::std::string&,
85 ::std::vector<::std::string>&
86 ) const;
87
88 enum class HardNonTerminal : int {
89 Epsilon = 1048576,
90 Int = 1048577,
91 Float = 1048578,
92 Val = 1048579,
93 RVal = 1048580,
94 WildcardInt = 1048581,
95 Operator = 1048582,
96 CompareOperator = 1048583,
97 Selection = 1048584,
98 StandaloneSelection = 1048585,
99 WildcardSelection = 1048586,
100 NonIdSelector = 1048587,
101 ScoresArg = 1048588,
102 ScoresArgs = 1048589,
103 ScoreSelectParam = 1048590,
104 ScoreSelector = 1048591,
105 TagSelector = 1048592,
106 FilePath = 1048593,
107 FilePathVal = 1048594,
108 FilePathCont = 1048595,
109 IntegerRangeVal = 1048596,
110 IntegerRangePostVal = 1048597,
111 IntegerRange = 1048598,
112 FullIntegerRange = 1048599,
113 RationalRangeVal = 1048600,
114 RationalRangePostVal = 1048601,
115 RationalRange = 1048602,
116 FullRationalRange = 1048603,
117 SelArgs = 1048604,
118 Args = 1048605,
119 Arg = 1048606,
120 MArg = 1048607,
121 MValue = 1048608,
122 NameArg = 1048609,
123 TypeArg = 1048610,
124 FamilyArg = 1048611,
125 HasPermissionArg = 1048612,
126 HasPermissionArgs = 1048613,
127 HasPermissionSelector = 1048614,
128 HasPermissionElement = 1048615,
129 HasPermissionElements = 1048616,
130 TagArg = 1048617,
131 HasItemElement = 1048618,
132 HasItemElements = 1048619,
133 HasItemArg = 1048620,
134 HasItemArgs = 1048621,
135 HasItemSelector = 1048622,
136 EquipmentSlotEnum = 1048623,
137 PropertyValue = 1048624,
138 HasPropertyParamValue = 1048625,
139 HasPropertyParamEnumValue = 1048626,
140 HasPropertyArg = 1048627,
141 HasPropertyArgs = 1048628,
142 HasPropertyElement = 1048629,
143 HasPropertyElements = 1048630,
144 HasPropertySelector = 1048631,
145 Id = 1048632,
146 IdCont = 1048633,
147 CoordXInt = 1048634,
148 CoordYInt = 1048635,
149 CoordZInt = 1048636,
150 CoordXFloat = 1048637,
151 CoordYFloat = 1048638,
152 CoordZFloat = 1048639,
153 Position = 1048640,
154 PositionFloat = 1048641,
155 MessageExp = 1048642,
156 Message = 1048643,
157 MessageRoot = 1048644,
158 PostSelector = 1048645,
159 RawText = 1048646,
160 RawTextCont = 1048647,
161 JsonValue = 1048648,
162 JsonField = 1048649,
163 JsonObject = 1048650,
164 JsonObjectFields = 1048651,
165 JsonObjectCont = 1048652,
166 JsonArray = 1048653,
167 JsonArrayValues = 1048654,
168 JsonArrayCont = 1048655,
169 BlockState = 1048656,
170 BlockStateKey = 1048657,
171 BlockStateValue = 1048658,
172 BlockStateValues = 1048659,
173 BlockStateArray = 1048660,
174 BlockStateArrayCont = 1048661,
175 ClockTimeMarkerName = 1048662,
176 PoiTag = 1048663,
177 PoiType = 1048664,
178 Command = 1048665,
179 SlashCommand = 1048666,
180 CodeBuilderArg = 1048667,
181 CodeBuilderArgs = 1048668,
182 CodeBuilderSelectParam = 1048669,
183 CodeBuilderSelector = 1048670,
184 };
185
187 public:
188 // member variables
189 // NOLINTBEGIN
190 ::ll::TypedStorage<4, 4, uint> signatureCount;
191 ::ll::TypedStorage<4, 4, uint> enumValueCount;
192 ::ll::TypedStorage<4, 4, uint> postfixCount;
193 ::ll::TypedStorage<4, 4, uint> enumCount;
194 ::ll::TypedStorage<4, 4, uint> enumLookupCount;
195 ::ll::TypedStorage<4, 4, uint> typeLookupCount;
196 ::ll::TypedStorage<4, 4, uint> factorizationCount;
197 ::ll::TypedStorage<4, 4, uint> optionalCount;
198 ::ll::TypedStorage<4, 4, uint> ruleCount;
199 ::ll::TypedStorage<4, 4, uint> softEnumCount;
200 ::ll::TypedStorage<4, 4, uint> constraintCount;
201 ::ll::TypedStorage<4, 4, uint> chainedSubcommandCount;
202 ::ll::TypedStorage<4, 4, uint> chainedSubcommandValueCount;
203 ::ll::TypedStorage<8, 24, ::std::vector<uint>> enumValuesCount;
204 ::ll::TypedStorage<8, 24, ::std::vector<uint>> constrainedValueCount;
205 ::ll::TypedStorage<8, 24, ::std::vector<uint>> softEnumValuesCount;
206 // NOLINTEND
207
208 public:
209 // member functions
210 // NOLINTBEGIN
211 MCAPI ~RegistryState();
212 // NOLINTEND
213
214 public:
215 // destructor thunk
216 // NOLINTBEGIN
217 MCAPI void $dtor();
218 // NOLINTEND
219 };
220
221 struct SoftEnum {
222 public:
223 // member variables
224 // NOLINTBEGIN
225 ::std::string mName;
226 ::std::vector<::std::string> mValues;
227 // NOLINTEND
228
229 public:
230 // prevent constructor by default
231 SoftEnum();
232
233 public:
234 // member functions
235 // NOLINTBEGIN
236 MCAPI SoftEnum(::std::string const& name, ::std::vector<::std::string> values);
237 // NOLINTEND
238
239 public:
240 // constructor thunks
241 // NOLINTBEGIN
242 MCAPI void* $ctor(::std::string const& name, ::std::vector<::std::string> values);
243 // NOLINTEND
244 };
245
246 class Symbol {
247 public:
248 int mValue{-1}; // this+0x0
249
250 static int const NonTerminalBit = 0x100000;
251 static int const EnumBit = 0x200000;
252 static int const OptionalBit = 0x400000;
253 static int const FactorizationBit = 0x800000;
254 static int const PostfixBit = 0x1000000;
255 static int const EnumValueBit = 0x2000000;
256 static int const SoftEnumBit = 0x4000000;
257
258 Symbol() = default;
259
260 Symbol(int val) : mValue(val) {}
261
262 // not trivially copyable
263 Symbol(Symbol const& other) : mValue(other.mValue) {}
264
265 Symbol(HardNonTerminal data) : mValue(static_cast<int>(data)) {}
266
267 Symbol(CommandLexer::TokenType data) : mValue(static_cast<int>(data)) {}
268
269 Symbol& operator=(Symbol const& other) {
270 mValue = other.mValue;
271 return *this;
272 }
273
274 [[nodiscard]] inline bool operator==(Symbol const& other) const { return mValue == other.mValue; }
275
276 uint64 toIndex() const { return mValue & 0xffffffffe00fffffull; }
277 };
278
280 public:
281 // member variables
282 // NOLINTBEGIN
283 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> mValue;
284 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> mEnum;
285 ::ll::TypedStorage<8, 24, ::std::vector<uchar>> mConstraints;
286 // NOLINTEND
287 };
288
290 public:
291 // member variables
292 // NOLINTBEGIN
293 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> commandSymbol;
294 // NOLINTEND
295 };
296
297 struct LexicalToken {
298 public:
299 // member variables
300 // NOLINTBEGIN
301 char const* mText;
302 uint mLength;
304 ::CommandRegistry::Symbol mIdentifierInfo;
305 ::CommandRegistry const& mRegistry;
306 // NOLINTEND
307
308 public:
309 // prevent constructor by default
310 LexicalToken& operator=(LexicalToken const&);
311 LexicalToken(LexicalToken const&);
312 LexicalToken();
313
314 public:
315 // member functions
316 // NOLINTBEGIN
317 MCAPI ::CommandRegistry::LexicalToken& operator=(::CommandLexer::Token const& token);
318 // NOLINTEND
319 };
320
322 public:
323 // member variables
324 // NOLINTBEGIN
325 ::ll::TypedStorage<4, 4, int> parameterCount;
326 ::ll::TypedStorage<4, 4, int> followingRuleIndex;
327 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> paramSymbol;
328 // NOLINTEND
329 };
330
331 struct Overload {
332 public:
333 // Overload inner types define
334 using AllocFunction = ::brstd::copyable_function<::std::unique_ptr<::Command>() const>;
335
336 public:
337 // member variables
338 // NOLINTBEGIN
339 ::CommandVersion version;
340 AllocFunction alloc;
341 ::std::vector<::CommandParameterData> params;
342 int versionOffset;
343 bool isChaining;
344 ::std::vector<::CommandRegistry::Symbol> paramsSymbol;
345 // NOLINTEND
346 };
347
349 public:
350 // member variables
351 // NOLINTBEGIN
352 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> x;
353 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> y;
354 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> z;
355 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> dx;
356 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> dy;
357 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> dz;
358 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> r;
359 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> rm;
360 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> rx;
361 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> rxm;
362 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> ry;
363 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> rym;
364 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> l;
365 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> lm;
366 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> c;
367 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> m;
368 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> name;
369 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> type;
370 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> family;
371 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> score;
372 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> tag;
373 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> hasitem;
374 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> haspermission;
375 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> hasproperty;
376 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> codebuilder;
377 // NOLINTEND
378 };
379
380 struct ParseToken {
381 public:
382 // member variables
383 // NOLINTBEGIN
384 ::std::unique_ptr<::CommandRegistry::ParseToken> child;
385 ::std::unique_ptr<::CommandRegistry::ParseToken> next;
387 char const* text;
388 uint length;
390 // NOLINTEND
391
392 public:
393 // member functions
394 // NOLINTBEGIN
395 MCAPI ::std::string toString() const;
396
397 MCAPI ~ParseToken();
398 // NOLINTEND
399
400 public:
401 // destructor thunk
402 // NOLINTBEGIN
403 MCAPI void $dtor();
404 // NOLINTEND
405 };
406
408 public:
409 // member variables
410 // NOLINTBEGIN
411 ::std::string name;
413 ParseFunction parse;
414 ::std::vector<::std::pair<uint64, uint>> values;
415 // NOLINTEND
416 };
417
418 struct Enum {
419 public:
420 // member variables
421 // NOLINTBEGIN
422 ::std::string name;
424 ParseFunction parse;
425 ::std::vector<::std::pair<uint64, uint64>> values;
426 // NOLINTEND
427 };
428
430 public:
431 // member variables
432 // NOLINTBEGIN
433 ::ll::TypedStorage<
434 8,
435 8,
436 bool (CommandRegistry::*)(
437 void*,
439 ::CommandOrigin const&,
440 int,
441 ::std::string&,
442 ::std::vector<::std::string>&
443 ) const>
444 parse;
445 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> symbol;
446 // NOLINTEND
447 };
448
449 struct ParseRule {
450 public:
451 // member variables
452 // NOLINTBEGIN
453 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> nonTerminal;
454 ::ll::TypedStorage<
455 8,
456 64,
458 process;
459 ::ll::TypedStorage<8, 24, ::std::vector<::CommandRegistry::Symbol>> derivation;
460 ::ll::TypedStorage<4, 8, ::CommandVersion> versions;
461 // NOLINTEND
462
463 public:
464 // prevent constructor by default
465 ParseRule& operator=(ParseRule const&);
466 ParseRule(ParseRule const&);
467 ParseRule();
468
469 public:
470 // member functions
471 // NOLINTBEGIN
472 MCAPI ::CommandRegistry::ParseRule& operator=(::CommandRegistry::ParseRule&& rhs);
473 // NOLINTEND
474 };
475
477 public:
478 // member variables
479 // NOLINTBEGIN
480 ::ll::TypedStorage<1, 1, bool> mIsValid;
481 ::ll::TypedStorage<8, 24, ::std::vector<::CommandRegistry::Symbol>> mConstrainedParams;
482 ::ll::TypedStorage<8, 32, ::std::string> mSoftEnumText;
483 ::ll::TypedStorage<8, 32, ::std::string> mSoftEnumEscapeCharExceptions;
484 ::ll::TypedStorage<8, 16, ::std::set<::CommandRegistry::Symbol>> mAlreadyCompletedSymbols;
485 // NOLINTEND
486 };
487
488 struct Signature {
489 public:
490 // member variables
491 // NOLINTBEGIN
492 ::std::string name;
493 ::std::string description;
494 ::std::vector<::CommandRegistry::Overload> overloads;
495 ::std::vector<uint> chainedSubcommandIndexes;
496 ::CommandPermissionLevel permissionLevel;
497 ::CommandRegistry::Symbol commandSymbol;
498 ::CommandRegistry::Symbol commandAliasEnum;
499 ::CommandFlag flags;
500 int firstRule;
501 int firstFactorization;
502 int firstOptional;
503 bool runnable;
504 uint64 ruleCounter;
505 // NOLINTEND
506
507 public:
508 // member functions
509 // NOLINTBEGIN
510 MCAPI ~Signature();
511 // NOLINTEND
512
513 public:
514 // destructor thunk
515 // NOLINTBEGIN
516 MCAPI void $dtor();
517 // NOLINTEND
518 };
519
520 struct SymbolHasher {};
521
523
524 struct ParseTable {
525 public:
526 // member variables
527 // NOLINTBEGI
528 ::std::map<
530 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>>
531 first;
532
533 ::std::map<
535 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>>
536 follow;
537 ::entt::dense_map<
538 ::std::pair<::CommandRegistry::Symbol, ::CommandRegistry::Symbol>,
539 int,
541 ::std::equal_to<void>>
542 predict;
543 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>
544 nullableSymbols;
545 ::std::chrono::nanoseconds buildDuration;
546 // NOLINTEND
547 };
548
549 class Parser {
550 public:
551 // member variables
552 // NOLINTBEGIN
553 ::ll::TypedStorage<8, 8, ::CommandRegistry const&> mRegistry;
554 ::ll::TypedStorage<8, 8, ::CommandRegistry::ParseTable const*> mParseTable;
555 ::ll::TypedStorage<8, 40, ::std::deque<::std::pair<::CommandRegistry::Symbol, ::CommandRegistry::ParseToken*>>>
556 mStack;
557 ::ll::TypedStorage<8, 32, ::CommandRegistry::LexicalToken> mNext;
558 ::ll::TypedStorage<8, 32, ::std::string> mInput;
559 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::CommandRegistry::ParseToken>> mRoot;
560 ::ll::TypedStorage<8, 32, ::std::string> mError;
561 ::ll::TypedStorage<8, 24, ::std::vector<::std::string>> mErrorParams;
562 ::ll::TypedStorage<4, 4, int> mVersion;
563 ::ll::TypedStorage<1, 1, bool> mGenerateParams;
564 ::ll::TypedStorage<1, 1, bool> mBreakAtEnd;
565 // NOLINTEND
566
567 public:
568 // prevent constructor by default
569 Parser& operator=(Parser const&);
570 Parser(Parser const&);
571 Parser();
572
573 public:
574 // member functions
575 // NOLINTBEGIN
576 MCAPI Parser(::CommandRegistry const& registry, int version);
577
578 MCAPI bool _parse(::std::string const& in);
579
580 MCAPI ::std::unique_ptr<::CommandSelector<::Actor>>
581 createSelector(::std::string const& selectorString, ::CommandOrigin const& origin);
582
583 MCAPI ::std::vector<::std::string> getErrorParams() const;
584
585 MCAPI bool parseCommand(::std::string const& in);
586
587 MCAPI bool parseSelector(::std::string const& in);
588
589 MCAPI ~Parser();
590 // NOLINTEND
591
592 public:
593 // constructor thunks
594 // NOLINTBEGIN
595 MCAPI void* $ctor(::CommandRegistry const& registry, int version);
596 // NOLINTEND
597
598 public:
599 // destructor thunk
600 // NOLINTBEGIN
601 MCAPI void $dtor();
602 // NOLINTEND
603 };
604
605 using ChainedSubcommandConversionFunction = ::std::function<void(void*, uint64)>;
606
607 using ChainedSubcommandID = uint;
608
609 using ChainedSubcommandValueID = uint64;
610
611 using CommandOverrideFunctor =
612 ::std::function<void(::std::string const&, ::CommandFlag&, ::CommandPermissionLevel&)>;
613
614 using CommandVisitCallback = ::std::function<bool(::CommandRegistry::ParseToken const*, ::CommandOrigin const&)>;
615
616 using ConstrainedValueID = uint;
617
618 using ConstrainedValueLookupKey = ::std::pair<uint64, uint>;
619
620 using CustomStorageGetFn = void* (*)(::Command*, int);
621
622 using CustomStorageIsSetFn = bool* (*)(::Command*, int);
623
624 using EnumConversionFunction = ::std::function<void(void*, uint64)>;
625
626 using EnumID = uint;
627
628 using EnumValueID = uint64;
629
630 using HardTerminal = ::CommandLexer::TokenType;
631
632 using ParamVisitCallback = ::std::function<
634
635 using ParseMap = ::std::map<
637 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>>;
638
639 using ParseTableMap = ::std::map<uint, ::CommandRegistry::ParseTable>;
640
641 using PredictTable = ::entt::dense_map<
642 ::std::pair<::CommandRegistry::Symbol, ::CommandRegistry::Symbol>,
643 int,
645 ::std::equal_to<void>>;
646
647 using ProcessFunction =
649
650 using RuleIndex = int;
651
652 using ScoreboardScoreAccessor = ::std::function<int(bool&, ::std::string const&, ::Actor const&)>;
653
654 using SemanticConstraintID = uchar;
655
656 using SoftEnumID = uint;
657
659
660 using SymbolSet =
661 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>;
662
663 using SymbolVector = ::std::vector<::CommandRegistry::Symbol>;
664
665 using Terminal = ::CommandRegistry::Symbol;
666
667 using ValueTypeID = uint64;
668
669public:
670 // member variables
671 // NOLINTBEGIN
672 ::std::function<void(::Packet const&)> mNetworkUpdateCallback;
673 ScoreboardScoreAccessor mGetScoreForObjective;
674 bool mIsEduMode;
675 ::std::vector<::CommandRegistry::ParseRule> mRules;
676 ::std::map<uint, ::CommandRegistry::ParseTable> mParseTables;
677 ::std::vector<::CommandRegistry::OptionalParameterChain> mOptionals;
678 ::std::vector<::std::string> mEnumValues;
679 ::std::vector<::CommandRegistry::Enum> mEnums;
680 ::std::vector<::std::string> mChainedSubcommandValues;
681 ::std::vector<::CommandRegistry::ChainedSubcommand> mChainedSubcommands;
682 ::std::vector<::CommandRegistry::Factorization> mFactorizations;
683 ::std::vector<::std::string> mPostfixes;
684 ::std::map<::std::string, uint> mEnumLookup;
685 ::std::map<::std::string, uint64> mEnumValueLookup;
686 ::std::map<::std::string, uint> mChainedSubcommandLookup;
687 ::std::map<::std::string, uint64> mChainedSubcommandValueLookup;
688 ::std::vector<::CommandRegistry::Symbol> mCommandSymbols;
689 ::std::map<::std::string, ::CommandRegistry::Signature> mSignatures;
690 ::std::map<::Bedrock::typeid_t<::CommandRegistry>, int> mTypeLookup;
691 ::std::map<::std::string, ::std::string> mAliases;
692 ::std::vector<::SemanticConstraint> mSemanticConstraints;
693 ::std::map<::SemanticConstraint, uchar> mSemanticConstraintLookup;
694 ::std::vector<::CommandRegistry::ConstrainedValue> mConstrainedValues;
695 ::std::map<::std::pair<uint64, uint>, uint> mConstrainedValueLookup;
696 ::std::vector<::CommandRegistry::SoftEnum> mSoftEnums;
697 ::std::map<::std::string, uint> mSoftEnumLookup;
698 ::std::vector<::CommandRegistry::RegistryState> mStateStack;
700 ::std::unordered_set<int> mSkipOnEpsAutocompleteSymbols;
701 ::std::unordered_set<int> mAllowEmptySymbols;
702 CommandOverrideFunctor mCommandOverrideFunctor;
703 ::std::unique_ptr<::CommandRunStats> mCommandRunStats;
704 ::ll::TypedStorage<
705 8,
706 8,
707 ::std::string (*)(
708 ::std::string const&,
709 ::std::unordered_map<::mce::UUID, ::PlayerListEntry> const&,
711 )>
712 mAutoCompletePlayerMention;
713 // NOLINTEND
714
715 template <class T>
716 bool parse(
717 void* storage,
718 CommandRegistry::ParseToken const& token,
719 CommandOrigin const& origin,
720 int version,
721 std::string& error,
722 std::vector<std::string>& errorParams
723 ) const;
724
725 template <class E, class C>
726 bool parseEnum(
727 void* storage,
728 CommandRegistry::ParseToken const& token,
729 CommandOrigin const& origin,
730 int version,
731 std::string& error,
732 std::vector<std::string>& errorParams
733 ) const;
734
735 uint64 getEnumData(ParseToken const& token) const {
736 auto& values = mEnums[token.type.toIndex()].values;
737 return std::lower_bound(
738 values.begin(),
739 values.end(),
740 token.child->type.toIndex(),
741 [](auto& pair, auto& child) { return pair.first < child; }
742 )->second;
743 }
744
745 template <class T>
747 MCAPI static ParamParseRule const& instance();
748 };
749
750public:
751 // prevent constructor by default
752 CommandRegistry();
753
754public:
755 // member functions
756 // NOLINTBEGIN
757 MCAPI explicit CommandRegistry(::CommandRegistryArguments args);
758
759 MCAPI ::CommandRegistry::Symbol _addChainedSubcommandValuesInternal(
760 ::std::string const& name,
761 ::std::vector<::std::pair<::std::string, uint>> const& strings,
763 bool (CommandRegistry::*parse)(
764 void*,
766 ::CommandOrigin const&,
767 int,
768 ::std::string&,
769 ::std::vector<::std::string>&
770 ) const,
772 );
773
774#ifdef LL_PLAT_C
775 MCAPI ::CommandRegistry::Symbol _addChainedSubcommandValuesInternal(
776 ::std::string const& name,
777 ::std::vector<::std::pair<uint64, uint>> const& values,
779 bool (::CommandRegistry::*parse)(
780 void*,
782 ::CommandOrigin const&,
783 int,
784 ::std::string&,
785 ::std::vector<::std::string>&
786 ) const,
788 );
789#endif
790
791 MCAPI ::CommandRegistry::Symbol _addEnumValuesInternal(
792 ::std::string const& name,
793 ::std::vector<::std::pair<::std::string, uint64>> const& strings,
795 bool (CommandRegistry::*parse)(
796 void*,
798 ::CommandOrigin const&,
799 int,
800 ::std::string&,
801 ::std::vector<::std::string>&
802 ) const
803 );
804
805 MCAPI ::CommandRegistry::Symbol _addEnumValuesInternal(
806 ::std::string const& name,
807 ::std::vector<::std::pair<uint64, uint64>> const& values,
809 bool (::CommandRegistry::*parse)(
810 void*,
812 ::CommandOrigin const&,
813 int,
814 ::std::string&,
815 ::std::vector<::std::string>&
816 ) const
817 );
818
819 MCAPI ::std::unique_ptr<::CommandSelector<::Actor>> _createSelector(
821 ::CommandOrigin const& origin,
822 int version,
823 ::std::string& error,
824 ::std::vector<::std::string>& errorParams
825 ) const;
826
827#ifdef LL_PLAT_C
828 MCAPI ::CommandRegistry::Symbol _getConstrainedParamEnumSymbol(::CommandRegistry::Symbol symbol) const;
829#endif
830
831 MCAPI bool _matchesEnumConstraintsSet(
832 ::CommandRegistry::Symbol const& commandParamSymbol,
833 ::CommandOrigin const& origin,
834 ::CommandRegistry::Symbol const& value,
835 ::SemanticConstraint requiredConstraints
836 ) const;
837
838#ifdef LL_PLAT_C
839 MCAPI void addChainedSubcommandValuesToExisting(uint index, ::std::vector<::std::pair<uint64, uint>> const& values);
840#endif
841
842 MCAPI void addEnumValueConstraints(
843 ::std::string const& enumName,
844 ::std::vector<::std::string> const& values,
845 ::SemanticConstraint constraints
846 );
847
848 MCAPI int addEnumValues(::std::string const& name, ::std::vector<::std::string> const& values);
849
850 MCAPI void addEnumValuesToExisting(uint index, ::std::vector<::std::pair<uint64, uint64>> const& values);
851
852#ifdef LL_PLAT_C
853 MCAPI ::CommandRegistry::Symbol addPostfix(::std::string const& name);
854#endif
855
856 MCAPI void addRule(
858 ::std::vector<::CommandRegistry::Symbol> derivation,
860 process,
861 ::CommandVersion versions
862 );
863
864 MCAPI void addSemanticConstraint(::SemanticConstraint constraintType);
865
866 MCAPI int addSoftEnum(::std::string const& name, ::std::vector<::std::string> values);
867
868 MCAPI void addSoftEnumValues(::std::string const& enumName, ::std::vector<::std::string> values);
869
870 MCAPI ::CommandRegistry::Symbol addSoftTerminal(::std::string const& name);
871
872#ifdef LL_PLAT_C
873 MCAPI void autoComplete(
875 ::std::string const& cmdLine,
876 ::std::string const& partialMatch,
877 bool newWord,
878 ::CommandOrigin const& origin,
881 ) const;
882
883 MCAPI void autoCompleteCommand(
884 ::std::string const& partialMatch,
885 ::CommandOrigin const& origin,
887 ) const;
888#endif
889
890 MCAPI void buildFirstSet(::CommandRegistry::ParseTable& table, ::CommandRegistry::Symbol t, uint version) const;
891
892 MCAPI void buildFollowSet(
895 uint version,
896 ::std::set<::CommandRegistry::Symbol>& workingSet
897 ) const;
898
899 MCAPI ::CommandRegistry::Symbol buildRules(
901 ::std::vector<::gsl::not_null<::CommandRegistry::Overload*>> const& overloads,
902 uint64 firstParam
903 );
904
905 MCAPI bool
906 buildSelector(::ActorSelectorArgs const& args, ::CommandSelectorBase* output, ::std::string& error) const;
907
908#ifdef LL_PLAT_C
909 MCAPI bool canCommandBeUsed(
910 ::std::string const& commandLine,
911 ::CommandPermissionLevel const& permissionLevel,
912 bool cheatsEnabled,
913 bool isEditorWorld
914 ) const;
915#endif
916
917 MCAPI ::std::unique_ptr<::Command> createCommand(
919 ::CommandOrigin const& origin,
920 int version,
921 ::std::string& error,
922 ::std::vector<::std::string>& errorParams
923 ) const;
924
925 MCAPI ::std::string describe(::CommandRegistry::Symbol symbol) const;
926
927#ifdef LL_PLAT_C
928 MCAPI ::std::string describe(
929 ::CommandRegistry::Signature const& command,
930 ::std::string const& alias,
931 ::CommandRegistry::Overload const& overload,
932 uint highlight,
933 uint* start,
934 uint* length
935 ) const;
936#endif
937
938 MCAPI void finalizeChainedSubcommandOverloadRules(char const* command);
939
940 MCFOLD ::CommandRegistry::Signature const* findCommand(::std::string const& name) const;
941
942 MCFOLD ::CommandRegistry::Signature* findCommand(::std::string const& name);
943
944 MCAPI void fireCommandParseTableTelemetry(::IMinecraftEventing const& eventing, bool isServer) const;
945
946 MCAPI void forEachNonTerminal(::std::function<void(::CommandRegistry::Symbol)> func) const;
947
948 MCAPI ::Json::Value generateDocumentationMetadata(bool generateInternalMetadata) const;
949
950 MCAPI ::std::vector<::std::string> getAliases(::std::string const& command) const;
951
952 MCAPI ::std::vector<::std::string> getAlphabeticalLookup(::CommandOrigin const& origin) const;
953
954#ifdef LL_PLAT_C
955 MCAPI ::std::unique_ptr<::AutoCompleteInformation> getAutoCompleteOptions(
956 ::CommandOrigin const& origin,
957 ::std::string const& _cmdLine,
958 uint cursorPositionUnsafe
959 ) const;
960#endif
961
962 MCAPI ::std::string getCommandName(::std::string const& commandLine) const;
963
964 MCAPI ::CommandSyntaxInformation
965 getCommandOverloadSyntaxInformation(::CommandOrigin const& origin, ::std::string const& commandName) const;
966
967 MCAPI ::CommandStatus getCommandStatus(::std::string const& nameIn) const;
968
969 MCAPI ::InvertableFilter<::std::string> getInvertableFilter(::CommandRegistry::ParseToken const& token) const;
970
971#ifdef LL_PLAT_C
972 MCAPI ::CommandSyntaxInformation getOverloadSyntaxInformation(
973 ::CommandOrigin const& origin,
974 ::std::string const& cmdLine,
975 uint cursorPosition
976 ) const;
977#endif
978
979 MCAPI bool isCommandOfType(::std::string const& nameIn, ::CommandTypeFlag commandType) const;
980
981 MCAPI bool isValid(::CommandRegistry::Symbol symbol) const;
982
983#ifdef LL_PLAT_C
984 MCAPI void loadRemoteCommands(::AvailableCommandsPacket const& packet);
985#endif
986
987 MCAPI bool originCanRun(::CommandOrigin const& origin, ::CommandRegistry::Signature const& command) const;
988
989#ifdef LL_PLAT_C
990 MCAPI bool originCanRunOverloadWithParam(::CommandOrigin const& origin, ::CommandParameterData const& param) const;
991
992 MCAPI ::std::string parsePartialCommand(
994 ::std::string const& _cmdLine,
995 uint cursorPosition,
996 bool cutLastToken
997 ) const;
998#endif
999
1000 MCAPI bool parseSelector(
1001 ::ActorSelectorArgs& args,
1002 ::CommandRegistry::ParseToken const& token,
1003 ::CommandOrigin const& origin,
1004 int version,
1005 ::std::string& error,
1006 ::std::vector<::std::string>& errorParams
1007 ) const;
1008
1009 MCAPI bool parseSelector(
1010 ::CommandSelectorBase* output,
1011 ::CommandRegistry::ParseToken const& token,
1012 ::CommandOrigin const& origin,
1013 int version,
1014 ::std::string& error,
1015 ::std::vector<::std::string>& errorParams,
1016 bool wildcard
1017 ) const;
1018
1019#ifdef LL_PLAT_C
1020 MCAPI void popState();
1021
1022 MCAPI void pushState();
1023#endif
1024
1025 MCAPI void registerAlias(::std::string name, ::std::string alias);
1026
1027 MCAPI void registerCommand(
1028 ::std::string const& name,
1029 char const* description,
1030 ::CommandPermissionLevel requirement,
1031 ::CommandFlag f1,
1032 ::CommandFlag f2 = {}
1033 );
1034
1035#ifdef LL_PLAT_S
1036 MCAPI void registerCommandFactory(
1037 char const* command,
1038 ::brstd::copyable_function<::std::unique_ptr<::Command>() const> createCommand
1039 );
1040#endif
1041
1042 MCAPI void registerOverload(
1043 char const* command,
1044 ::CommandVersion version,
1045 ::std::function<::std::unique_ptr<::Command>()> allocFn,
1046 ::std::vector<::CommandParameterData> params
1047 );
1048
1049 MCAPI void registerOverloadInternal(::CommandRegistry::Signature& signature, ::CommandRegistry::Overload& overload);
1050
1051 MCAPI void removeSoftEnumValues(::std::string const& enumName, ::std::vector<::std::string> values);
1052
1053 MCAPI ::AvailableCommandsPacket serializeAvailableCommands() const;
1054
1055 MCAPI void setNetworkUpdateCallback(::std::function<void(::Packet const&)> callback);
1056
1057 MCAPI void setScoreCallback(::std::function<int(bool&, ::std::string const&, ::Actor const&)> callback);
1058
1059 MCAPI void setSoftEnumValues(::std::string const& enumName, ::std::vector<::std::string> values);
1060
1061 MCAPI void setupChainedSubcommandOverloadRules(::CommandRegistry::Signature& signature);
1062
1063#ifdef LL_PLAT_C
1064 MCAPI void setupOverloadRules(::CommandRegistry::Signature& signature);
1065#endif
1066
1067 MCAPI ::std::string symbolToString(::CommandRegistry::Symbol symbol) const;
1068
1069 MCAPI ~CommandRegistry();
1070 // NOLINTEND
1071
1072public:
1073 // static functions
1074 // NOLINTBEGIN
1075#ifdef LL_PLAT_C
1076 MCAPI static ::BlockType const* _getBlockFromCmdParameters(::std::string const& parameters);
1077#endif
1078
1079 MCAPI static ::std::string _removeStringQuotes(::std::string const& str);
1080
1081 MCFOLD static ::CommandRegistry::ParseToken*
1083
1084 MCAPI static ::CommandRegistry::ParseToken* collapseOn(
1087 ::CommandRegistry::Symbol boundSymbol
1088 );
1089
1090 MCAPI static ::CommandRegistry::ParseToken*
1092
1093 MCAPI static ::CommandRegistry::ParseToken* expandExcept(
1096 ::CommandRegistry::Symbol boundSymbol
1097 );
1098
1099 MCAPI static ::CommandRegistry::ParseToken* fold(
1102 ::CommandRegistry::Symbol boundSymbol
1103 );
1104
1105 MCAPI static ::CommandRegistry::ParseToken*
1107
1108 MCAPI static bool readFloat(
1109 float& value,
1110 ::CommandRegistry::ParseToken const& token,
1111 ::std::string& error,
1112 ::std::vector<::std::string>& errorParams
1113 );
1114
1115 MCAPI static bool readInt(
1116 int& value,
1117 ::CommandRegistry::ParseToken const& token,
1118 ::std::string& error,
1119 ::std::vector<::std::string>& errorParams
1120 );
1121
1122 MCAPI static bool readRelativeCoordinate(
1123 bool& relative,
1124 float& offset,
1125 ::CommandRegistry::ParseToken const& token,
1126 bool readIntegerAsCentered,
1127 ::std::string& error,
1128 ::std::vector<::std::string>& errorParams
1129 );
1130
1131 MCAPI static bool readString(
1132 ::std::string& value,
1133 ::CommandRegistry::ParseToken const& token,
1134 ::std::string& error,
1135 ::std::vector<::std::string>& errorParams
1136 );
1137 // NOLINTEND
1138
1139public:
1140 // static variables
1141 // NOLINTBEGIN
1142 MCAPI static char const*& CODE_STATUS_PROPERTY_NAME();
1143
1144 MCAPI static char const*& COMMAND_NAME_ENUM_NAME();
1145
1146 MCAPI static char const*& FUNCTION_NAME_SOFTENUM_NAME();
1147
1148 MCAPI static char const*& POI_TAG_SOFTENUM();
1149
1150 MCAPI static char const*& POI_TYPE_SOFTENUM();
1151
1152 MCAPI static char const*& TAG_VALUES_SOFTENUM_NAME();
1153
1154 MCAPI static char const*& UNLOCKABLE_RECIPES_SOFTENUM_NAME();
1155 // NOLINTEND
1156
1157public:
1158 // constructor thunks
1159 // NOLINTBEGIN
1160 MCAPI void* $ctor(::CommandRegistryArguments args);
1161 // NOLINTEND
1162
1163public:
1164 // destructor thunk
1165 // NOLINTBEGIN
1166 MCAPI void $dtor();
1167 // NOLINTEND
1168};
1169
1170// following are the functions required by CommandParameterData's ParseFunction
1171MCTAPI bool CommandRegistry::parse<std::string>(
1172 void*,
1174 CommandOrigin const&,
1175 int,
1176 std::string&,
1177 std::vector<std::string>&
1178) const;
1179
1180MCTAPI bool CommandRegistry::parse<int>(
1181 void*,
1183 CommandOrigin const&,
1184 int,
1185 std::string&,
1186 std::vector<std::string>&
1187) const;
1188
1189MCTAPI bool CommandRegistry::parse<float>(
1190 void*,
1192 CommandOrigin const&,
1193 int,
1194 std::string&,
1195 std::vector<std::string>&
1196) const;
1197
1198MCTAPI bool CommandRegistry::parse<Json::Value>(
1199 void*,
1201 CommandOrigin const&,
1202 int,
1203 std::string&,
1204 std::vector<std::string>&
1205) const;
1206
1207MCTAPI bool CommandRegistry::parse<CommandCompareOperator>(
1208 void*,
1210 CommandOrigin const&,
1211 int,
1212 std::string&,
1213 std::vector<std::string>&
1214) const;
1215
1216MCTAPI bool CommandRegistry::parse<CommandFilePath>(
1217 void*,
1219 CommandOrigin const&,
1220 int,
1221 std::string&,
1222 std::vector<std::string>&
1223) const;
1224
1225MCTAPI bool CommandRegistry::parse<CommandIntegerRange>(
1226 void*,
1228 CommandOrigin const&,
1229 int,
1230 std::string&,
1231 std::vector<std::string>&
1232) const;
1233
1234MCTAPI bool CommandRegistry::parse<CommandMessage>(
1235 void*,
1237 CommandOrigin const&,
1238 int,
1239 std::string&,
1240 std::vector<std::string>&
1241) const;
1242
1243MCTAPI bool CommandRegistry::parse<CommandOperator>(
1244 void*,
1246 CommandOrigin const&,
1247 int,
1248 std::string&,
1249 std::vector<std::string>&
1250) const;
1251
1252MCTAPI bool CommandRegistry::parse<CommandPosition>(
1253 void*,
1255 CommandOrigin const&,
1256 int,
1257 std::string&,
1258 std::vector<std::string>&
1259) const;
1260
1261MCTAPI bool CommandRegistry::parse<CommandPositionFloat>(
1262 void*,
1264 CommandOrigin const&,
1265 int,
1266 std::string&,
1267 std::vector<std::string>&
1268) const;
1269
1270MCTAPI bool CommandRegistry::parse<CommandRawText>(
1271 void*,
1273 CommandOrigin const&,
1274 int,
1275 std::string&,
1276 std::vector<std::string>&
1277) const;
1278
1279MCTAPI bool CommandRegistry::parse<CommandSelector<Actor>>(
1280 void*,
1282 CommandOrigin const&,
1283 int,
1284 std::string&,
1285 std::vector<std::string>&
1286) const;
1287
1288MCTAPI bool CommandRegistry::parse<CommandSelector<Player>>(
1289 void*,
1291 CommandOrigin const&,
1292 int,
1293 std::string&,
1294 std::vector<std::string>&
1295) const;
1296
1297MCTAPI bool CommandRegistry::parse<CommandWildcardInt>(
1298 void*,
1300 CommandOrigin const&,
1301 int,
1302 std::string&,
1303 std::vector<std::string>&
1304) const;
1305
1306MCTAPI bool CommandRegistry::parse<class RelativeFloat>(
1307 void*,
1309 CommandOrigin const&,
1310 int,
1311 std::string&,
1312 std::vector<std::string>&
1313) const;
1314
1315MCTAPI bool CommandRegistry::parse<WildcardCommandSelector<Actor>>(
1316 void*,
1318 CommandOrigin const&,
1319 int,
1320 std::string&,
1321 std::vector<std::string>&
1322) const;
1323
1324MCTAPI bool CommandRegistry::parse<std::unique_ptr<::Command>>(
1325 void*,
1327 CommandOrigin const&,
1328 int,
1329 std::string&,
1330 std::vector<std::string>&
1331) const;
1332
1333MCTAPI bool CommandRegistry::parse<std::vector<BlockStateCommandParam>>(
1334 void*,
1336 CommandOrigin const&,
1337 int,
1338 std::string&,
1339 std::vector<std::string>&
1340) const;
1341
1342MCTAPI bool CommandRegistry::parseEnum<CommandChainedSubcommand, void>(
1343 void*,
1345 CommandOrigin const&,
1346 int,
1347 std::string&,
1348 std::vector<std::string>&
1349) const;
1350
1351// clang-format off
1352template <>
1353MCAPI ::ll::type_id_ref Bedrock::typeid_storage_impl<class CommandRegistry, ::std::basic_string<char, ::std::char_traits<char>, ::std::allocator<char> >>();
1354template <>
1355MCAPI ::ll::type_id_ref Bedrock::typeid_storage_impl<class CommandRegistry, bool>();
1356template <>
1357MCAPI ::ll::type_id_ref Bedrock::typeid_storage_impl<class CommandRegistry, float>();
1358template <>
1359MCAPI ::ll::type_id_ref Bedrock::typeid_storage_impl<class CommandRegistry, int>();
1360// clang-format on
Definition Actor.h:113
Definition AvailableCommandsPacket.h:19
Definition typeid_t.h:36
Definition BlockState.h:14
Definition BlockType.h:79
Definition CommandOrigin.h:32
Definition CommandParameterData.h:18
Definition CommandRegistry.h:549
Definition CommandRegistry.h:246
Definition CommandRegistry.h:51
Definition CommandRunStats.h:8
Definition CommandSelectorBase.h:28
Definition CommandVersion.h:10
Definition Command.h:17
Definition IMinecraftEventing.h:147
Definition Value.h:16
Definition Packet.h:29
Definition PlayerListEntry.h:17
Definition copyable_function.h:8
Definition ActorSelectorArgs.h:21
Definition AutoCompleteInformation.h:10
Definition CommandFlag.h:43
Definition CommandLexer.h:50
Definition CommandRegistryArguments.h:14
Definition CommandRegistry.h:407
Definition CommandRegistry.h:279
Definition CommandRegistry.h:418
Definition CommandRegistry.h:289
Definition CommandRegistry.h:297
Definition CommandRegistry.h:321
Definition CommandRegistry.h:331
Definition CommandRegistry.h:429
Definition CommandRegistry.h:348
Definition CommandRegistry.h:746
Definition CommandRegistry.h:449
Definition CommandRegistry.h:524
Definition CommandRegistry.h:380
Definition CommandRegistry.h:186
Definition CommandRegistry.h:476
Definition CommandRegistry.h:488
Definition CommandRegistry.h:221
Definition CommandRegistry.h:520
Definition CommandRegistry.h:522
Definition CommandSyntaxInformation.h:10