summaryrefslogtreecommitdiffstats
path: root/src/Chat.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Chat.hpp')
-rw-r--r--src/Chat.hpp90
1 files changed, 75 insertions, 15 deletions
diff --git a/src/Chat.hpp b/src/Chat.hpp
index 9ab5691..f9dde98 100644
--- a/src/Chat.hpp
+++ b/src/Chat.hpp
@@ -3,23 +3,83 @@
#include <vector>
#include <string>
-struct TextModifier {
- size_t offset;
- size_t length;
- enum {
- Italic,
- Bold,
- Underline,
- } type;
+
+struct ClickEvent {
+ enum ActionType {
+ NONE,
+ OPEN_URL,
+ OPEN_FILE,
+ RUN_COMMAND,
+ SUGGEST_COMMAND,
+ CHANGE_PAGE,
+ } action = NONE;
+ std::string value;
+};
+
+struct HoverEvent {
+ enum ActionType {
+ NONE,
+ SHOW_TEXT,
+ SHOW_ITEM,
+ SHOW_ENTITY,
+ SHOW_ACHIEVEMENT,
+ } action = NONE;
+ std::string value;
};
-struct Chat {
- std::vector<TextModifier> modifiers;
- std::string text;
+struct Component {
+ enum ComponentType {
+ DEFAULT,
+ STRING,
+ TRANSLATION,
+ KEYBIND,
+ SCORE,
+ SELECTOR,
+ UNKNOWN,
+ } type = DEFAULT;
+
+ bool isBold = false;
+ bool isItalic = false;
+ bool isUnderlined = false;
+ bool isStrikethrough = false;
+ bool isObfuscated = false;
+ std::string color;
+ std::string insertion;
+ ClickEvent clickEvent;
+ HoverEvent hoverEvent;
+ std::vector<Component> extra;
+
+ //string component
+ std::string text;
- Chat(const std::string &str);
+ //tranlation component
+ std::string translate;
+ std::vector<Component> with;
- Chat() = default;
+ //keybind component
+ std::string keybind;
+
+ //score component
+ struct {
+ std::string name;
+ std::string objective;
+ std::string value;
+ } score;
+
+ //selector component
+ std::string selector;
+};
- std::string ToJson() const;
-}; \ No newline at end of file
+class Chat {
+ Component component;
+
+public:
+
+ Chat() = default;
+
+ Chat(const std::string &json);
+
+ std::string ToPlainText() const;
+
+ std::string ToJson() const;
+};