Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
Loading...
Searching...
No Matches
chatmessage.h
Go to the documentation of this file.
1
12#ifndef MINESERVER_CHATMESSAGE_H
13#define MINESERVER_CHATMESSAGE_H
14
15#include <string>
16#include <unordered_map>
17#include <rapidjson/rapidjson.h>
18#include <rapidjson/document.h>
19#include <plugins/luaheaders.h>
20
28{
29public:
34 bool bold{};
39 bool italic{};
44 bool underlined{};
54 bool obfuscated{};
64 std::string color{};
73 std::string insertion{};
74
81 std::string text{};
82
89 {
90 public:
129
139 std::string value;
140
147 ClickEvent(ActionType action, std::string value);
153 ClickEvent(std::uint32_t changePage);
158 ClickEvent();
163 ~ClickEvent() = default;
164
170 void load(const rapidjson::Value &document);
177 void save(rapidjson::Value &document, rapidjson::Document::AllocatorType &alloc) const;
178
185 static void loadLua(lua_State *state, const char *namespaceName);
186 };
187
193
194private:
195 ChatMessage *next = nullptr;
196
197public:
208 ChatMessage(const std::string &msg);
214 ChatMessage(const std::string &&msg);
219 ~ChatMessage();
220
228 void addExtra(ChatMessage *cm);
229
235 void load(const rapidjson::Value &document);
242 void save(rapidjson::Value &document, rapidjson::Document::AllocatorType &alloc) const;
243
252 friend bool operator==(const ChatMessage &lhs, const ChatMessage &rhs);
253
260 static void loadLua(lua_State *state, const char *namespaceName);
261};
262
263#ifndef DOXYGEN_IGNORE_THIS
264template <>
265struct luabridge::Stack<ChatMessage::ClickEvent::ActionType>
266 : luabridge::Enum<ChatMessage::ClickEvent::ActionType,
267 ChatMessage::ClickEvent::ActionType::NONE,
268 ChatMessage::ClickEvent::ActionType::OPEN_URL,
269 ChatMessage::ClickEvent::ActionType::RUN_COMMAND,
270 ChatMessage::ClickEvent::ActionType::SUGGEST_COMMAND,
271 ChatMessage::ClickEvent::ActionType::CHANGE_PAGE,
272 ChatMessage::ClickEvent::ActionType::COPY_TO_CLIPBOARD>
273{
274};
275#endif
276
277#endif // MINESERVER_CHATMESSAGE_H
Click Event.
Definition chatmessage.h:89
ActionType
Type of action to perform.
Definition chatmessage.h:96
@ SUGGEST_COMMAND
Suggest command to user.
Definition chatmessage.h:117
@ CHANGE_PAGE
Change page (book only)
Definition chatmessage.h:122
@ RUN_COMMAND
Run command.
Definition chatmessage.h:112
@ NONE
No action.
Definition chatmessage.h:102
@ OPEN_URL
Open URL.
Definition chatmessage.h:107
@ COPY_TO_CLIPBOARD
Copy text to clipboard.
Definition chatmessage.h:127
void save(rapidjson::Value &document, rapidjson::Document::AllocatorType &alloc) const
Save click event to JSON.
Definition chatmessage.cpp:222
std::string value
Value of action.
Definition chatmessage.h:139
static void loadLua(lua_State *state, const char *namespaceName)
Loads Click Event to lua.
Definition chatmessage.cpp:242
ClickEvent()
Construct a new Click Event object.
Definition chatmessage.cpp:178
ActionType action
Action to perform.
Definition chatmessage.h:134
void load(const rapidjson::Value &document)
Load click event from JSON.
Definition chatmessage.cpp:194
~ClickEvent()=default
Destroy the Click Event object.
Minecraft Chat Message implementation.
Definition chatmessage.h:28
ClickEvent clickEvent
Click event for message.
Definition chatmessage.h:192
ChatMessage()
Construct a new Chat Message object.
friend bool operator==(const ChatMessage &lhs, const ChatMessage &rhs)
Equality operator between two chat messages.
Definition chatmessage.cpp:135
bool italic
Italicness for text.
Definition chatmessage.h:39
std::string text
The text excluding extras.
Definition chatmessage.h:81
void addExtra(ChatMessage *cm)
Adds an extra.
Definition chatmessage.cpp:34
void load(const rapidjson::Value &document)
Loads data from a document.
Definition chatmessage.cpp:51
bool strikethrough
Strikethrough or not text.
Definition chatmessage.h:49
void save(rapidjson::Value &document, rapidjson::Document::AllocatorType &alloc) const
Saves data from a document.
Definition chatmessage.cpp:96
~ChatMessage()
Destroy the Chat Message object.
Definition chatmessage.cpp:26
std::string color
Color of text.
Definition chatmessage.h:64
bool obfuscated
Obfuscate or not text.
Definition chatmessage.h:54
std::string insertion
Text to insert.
Definition chatmessage.h:73
bool bold
Boldness for text.
Definition chatmessage.h:34
static void loadLua(lua_State *state, const char *namespaceName)
Loads the ChatMessage class to a Lua one.
Definition chatmessage.cpp:144
bool underlined
Underline or not text.
Definition chatmessage.h:44
constexpr std::string_view type_name()
Gets the name of the type paramater.
Definition event.h:56
Utility header file for lua things.