LeviLamina
Loading...
Searching...
No Matches
CommandFlag.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/server/commands/CommandAsyncFlag.h"
5#include "mc/server/commands/CommandCheatFlag.h"
6#include "mc/server/commands/CommandEditorFlag.h"
7#include "mc/server/commands/CommandExecuteFlag.h"
8#include "mc/server/commands/CommandSyncFlag.h"
9#include "mc/server/commands/CommandTypeFlag.h"
10#include "mc/server/commands/CommandUsageFlag.h"
11#include "mc/server/commands/CommandVisibilityFlag.h"
12
13
14enum class CommandFlagValue : ushort {
15 None = 0,
16 UsageTest = 1 << 0,
17 HiddenFromCommandBlockOrigin = 1 << 1,
18 HiddenFromPlayerOrigin = 1 << 2,
19 HiddenFromAutomationOrigin = 1 << 3,
20 SyncLocal = 1 << 4,
21 ExecuteDisallowed = 1 << 5,
22 TypeMessage = 1 << 6,
23 NotCheat = 1 << 7,
24 Async = 1 << 8,
25 NoEditor = 1 << 9,
26 Hidden = HiddenFromPlayerOrigin | HiddenFromCommandBlockOrigin,
27 Removed = Hidden | HiddenFromAutomationOrigin,
28};
29
30[[nodiscard]] constexpr CommandFlagValue operator|(const CommandFlagValue l, const CommandFlagValue r) noexcept {
31 return static_cast<CommandFlagValue>(
32 static_cast<std::underlying_type_t<CommandFlagValue>>(l)
33 | static_cast<std::underlying_type_t<CommandFlagValue>>(r)
34 );
35}
36[[nodiscard]] constexpr CommandFlagValue operator&(const CommandFlagValue l, const CommandFlagValue r) noexcept {
37 return static_cast<CommandFlagValue>(
38 static_cast<std::underlying_type_t<CommandFlagValue>>(l)
39 & static_cast<std::underlying_type_t<CommandFlagValue>>(r)
40 );
41}
42
44public:
45 CommandFlagValue value;
46
47 CommandFlag() = default;
48
49 CommandFlag(CommandFlagValue value) : value(value) {}
50
51 [[nodiscard]] constexpr bool operator==(CommandFlag const& rhs) const noexcept { return value == rhs.value; }
52 [[nodiscard]] constexpr bool operator!=(CommandFlag const& rhs) const noexcept { return value != rhs.value; }
53 CommandFlag& operator|=(CommandFlag const& rhs) {
54 value = rhs.value | value;
55 return *this;
56 }
57 CommandFlag& operator|=(CommandFlagValue rhs) {
58 value = rhs | value;
59 return *this;
60 }
61
62 CommandFlag& remove(CommandFlagValue rhs) {
63 value = (CommandFlagValue)((ushort)value & !(ushort)rhs);
64 return *this;
65 }
66};
Definition CommandFlag.h:43