コード例 #1
0
ファイル: Chat.cs プロジェクト: Kingwl/MineCase
        public virtual JObject ToJObject()
        {
            JObject jObject = new JObject();

            AddBoolValue(jObject, "bold", Bold);
            AddBoolValue(jObject, "itatic", Itatic);
            AddBoolValue(jObject, "underlined", Underlined);
            AddBoolValue(jObject, "shrikethrough", Strikethrough);
            AddBoolValue(jObject, "obfuscated", Obfuscated);
            AddStringValue(jObject, "insertion", Insertion);

            if (Color != null)
            {
                jObject.Add("color", _map[(int)Color]);
            }

            if (ClickEvent != null)
            {
                jObject.Add("clickEvent", ClickEvent.ToJObject());
            }

            if (HoverEvent != null)
            {
                jObject.Add("hoverEvent", HoverEvent.ToJObject());
            }

            if (Extra != null && Extra.Count != 0)
            {
                JArray jArray = new JArray();

                foreach (var comp in Extra)
                {
                    jArray.Add(comp.ToJObject());
                }

                jObject.Add("extra", jArray);
            }

            return(jObject);
        }