LeviLamina
Loading...
Searching...
No Matches
CommandOutput.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/server/commands/CommandOutputMessage.h"
5#include "mc/server/commands/CommandOutputParameter.h"
6
7// auto generated inclusion list
8#include "mc/server/commands/CommandOutputMessageType.h"
9#include "mc/server/commands/CommandOutputType.h"
10
11// auto generated forward declare list
12// clang-format off
13class Actor;
17// clang-format on
18
20public:
21 // member variables
22 // NOLINTBEGIN
23 CommandOutputType mType;
24 std::unique_ptr<CommandPropertyBag> mBag;
25 std::vector<CommandOutputMessage> mMessages;
26 int mSuccessCount;
27 bool mHasPlayerText;
28 // NOLINTEND
29
30 template <class First, class... Args>
31 requires(!std::is_same_v<std::remove_cvref_t<First>, std::vector<class CommandOutputParameter>>)
32 void success(fmt::format_string<First, Args...> fmt, First&& _args, Args&&... args) {
33 success(fmt::vformat(fmt.get(), fmt::make_format_args(_args, args...)));
34 }
35
36 template <class First, class... Args>
37 requires(!std::is_same_v<std::remove_cvref_t<First>, std::vector<class CommandOutputParameter>>)
38 void error(fmt::format_string<First, Args...> fmt, First&& _args, Args&&... args) {
39 error(fmt::vformat(fmt.get(), fmt::make_format_args(_args, args...)));
40 }
41
42 void error(std::string_view str) { mMessages.emplace_back(CommandOutputMessageType::Error, std::string{str}); }
43 void success(std::string_view str) {
44 mMessages.emplace_back(CommandOutputMessageType::Success, std::string{str});
45 mSuccessCount++;
46 }
47
48 void error(std::string_view msgId, std::vector<class CommandOutputParameter> const& params) {
49 std::vector<std::string> args;
50 args.reserve(params.size());
51 for (auto& param : params) {
52 args.emplace_back(param);
53 }
54 mMessages.emplace_back(CommandOutputMessageType::Error, std::string{msgId}, std::move(args));
55 }
56 void success(std::string_view msgId, std::vector<class CommandOutputParameter> const& params) {
57 std::vector<std::string> args;
58 args.reserve(params.size());
59 for (auto& param : params) {
60 args.emplace_back(param);
61 }
62 mMessages.emplace_back(CommandOutputMessageType::Success, std::string{msgId}, std::move(args));
63 mSuccessCount++;
64 }
65
66public:
67 // prevent constructor by default
68 CommandOutput& operator=(CommandOutput const&);
69
70public:
71 // member functions
72 // NOLINTBEGIN
73 MCAPI CommandOutput(::CommandOutput const& rhs);
74
75 MCAPI explicit CommandOutput(::CommandOutputType type);
76
77 MCAPI void addMessage(
78 ::std::string const& msgId,
79 ::std::vector<::CommandOutputParameter> const& params,
80 ::CommandOutputMessageType type
81 );
82
83 MCAPI void addToResultList(::std::string const& key, ::Actor const& element);
84
85 MCAPI void addToResultList(::std::string const& key, ::std::string const& element);
86
87 MCAPI void error(::std::string const& msgId, ::std::vector<::CommandOutputParameter> const& params);
88
89 MCAPI void load(
90 ::CommandOutputType type,
91 int successCount,
92 ::std::vector<::CommandOutputMessage>&& messages,
93 ::std::unique_ptr<::CommandPropertyBag>&& data
94 );
95
96 MCAPI void success(::std::string const& msgId, ::std::vector<::CommandOutputParameter> const& params);
97
98 MCAPI ~CommandOutput();
99 // NOLINTEND
100
101public:
102 // constructor thunks
103 // NOLINTBEGIN
104 MCAPI void* $ctor(::CommandOutput const& rhs);
105
106 MCAPI void* $ctor(::CommandOutputType type);
107 // NOLINTEND
108
109public:
110 // destructor thunk
111 // NOLINTBEGIN
112 MCAPI void $dtor();
113 // NOLINTEND
114};
Definition Actor.h:104
Definition CommandOutputMessage.h:8
Definition CommandOutputParameter.h:15
Definition CommandOutput.h:19
Definition CommandPropertyBag.h:14