Ejemplo n.º 1
0
        ChatObject ParseWith(JArray with, ChatObject chatObj) {
            for (int x = 0; x < with.Count; x++) {
                switch (with[x].Type) {
                    case JTokenType.String: // -- Add a name
                        if (chatObj.translate == "chat.type.text")
                            chatObj.text += (string)((JValue)with[x]).Value;
                        else
                            chatObj.Names.Add((string)((JValue)with[x]).Value);
                            
                        break;
                    case JTokenType.Object:
                        var myObj = (JObject)with[x];
                        chatObj = ParseSecondaryElement(myObj, chatObj);
                        break;
                }
            }

            return chatObj;
        }
Ejemplo n.º 2
0
        ChatObject DoExtra(ChatObject chatObj, JObject myObj) {
            foreach (JProperty prop in myObj.Children()) {
                switch (prop.Name) {
                    case "color":
                        chatObj.text += Color_To_Code((string)prop.Value);
                        break;
                    case "text":
                        chatObj.text += (string)prop.Value;
                        break;
                }
            }

            return chatObj;
        }
Ejemplo n.º 3
0
        string ParseModifiers(ChatObject MainObj, string Text) {
            if (MainObj.italic)
                Text += "§o";

            if (MainObj.bold)
                Text += "§l";

            if (MainObj.strikethrough)
                Text += "§m";

            if (MainObj.obfs)
                Text += "§k";

            if (MainObj.color != null)
                Text += Color_To_Code(MainObj.color);

            return Text;
        }
Ejemplo n.º 4
0
        ChatObject ParseSecondaryElement(JObject jsonObj, ChatObject chatObj) {
            foreach (JProperty prop in jsonObj.Properties()) {
                switch (prop.Name) {
                    case "translate":
                        chatObj.translate = (string)((JValue)prop.Value);
                        break;
                    case "with":
                        chatObj.Names.Add((string)((JValue)((JArray)prop.Value)[0]).Value);
                        break;
                    case "text":
                        chatObj.Names.Add((string)((JValue)prop.Value));
                        break;
                    case "extra":
                        foreach (JValue b in (JArray)prop.Value) {
                            if (b.Type == JTokenType.String)
                                chatObj.text += (string)b.Value + " ";
                        }
                        break;
                }
            }

            return chatObj;
        }
Ejemplo n.º 5
0
        ChatObject ParseElement(JObject jsonObj) {
            var chat = new ChatObject();

            foreach (JProperty prop in jsonObj.Properties()) {
                switch (prop.Name) {
                    case "translate":
                        chat.translate = (string)prop.Value;
                        break;
                    case "italic":
                        chat.italic = (bool)prop.Value;
                        break;
                    case "color":
                        chat.color = (string)prop.Value;
                        break;
                    case "text":
                        chat.text = (string)prop.Value;
                        break;
                    case "with":
                        chat.with = (JArray)prop.Value;
                        break;
                    default:
                        chat.unknown = prop.Name;
                        break;
                }
            }

            return chat;
        }
Ejemplo n.º 6
0
        ChatObject ParseWith(IEnumerable<JToken> with, ChatObject chatObj)
        {
            foreach (JToken token in with)
            {
                switch (token.Type) {
                    case JTokenType.String: // -- Add a name
                        if (chatObj.Translate == "chat.type.text")
                            chatObj.Text += (string)((JValue)token).Value;
                        else
                            chatObj.Names.Add((string)((JValue)token).Value);
                            
                        break;
                    case JTokenType.Object:
                        var myObj = (JObject)token;
                        chatObj = ParseSecondaryElement(myObj, chatObj);
                        break;
                }
            }

            return chatObj;
        }
Ejemplo n.º 7
0
        string ParseModifiers(ChatObject mainObj, string text) {
            if (mainObj.Italic)
                text += "§o";

            if (mainObj.Bold)
                text += "§l";

            if (mainObj.Strikethrough)
                text += "§m";

            if (mainObj.Obfs)
                text += "§k";

            if (mainObj.Color != null)
                text += Color_To_Code(mainObj.Color);

            return text;
        }