--- a/net/minecraft/network/chat/Component.java
+++ b/net/minecraft/network/chat/Component.java
@@ -1,6 +1,7 @@
 package net.minecraft.network.chat;
 
 import com.google.common.collect.Lists;
+import io.papermc.paper.adventure.AdventureComponent; // Paper
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonArray;
@@ -20,8 +21,9 @@
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Optional;
 import javax.annotation.Nullable;
 import net.minecraft.Util;
@@ -39,8 +41,24 @@
 import net.minecraft.util.FormattedCharSequence;
 import net.minecraft.util.GsonHelper;
 import net.minecraft.util.LowerCaseEnumTypeAdapterFactory;
+// CraftBukkit start
+import com.google.common.collect.Streams;
+import java.util.stream.Stream;
+// CraftBukkit end
+
+public interface Component extends Message, FormattedText, Iterable<Component> { // CraftBukkit
+
+    // CraftBukkit start
+    default Stream<Component> stream() {
+        return Streams.concat(new Stream[]{Stream.of(this), this.getSiblings().stream().flatMap(Component::stream)});
+    }
+
+    @Override
+    default Iterator<Component> iterator() {
+        return this.stream().iterator();
+    }
+    // CraftBukkit end
 
-public interface Component extends Message, FormattedText {
     Style getStyle();
 
     ComponentContents getContents();
@@ -51,17 +69,19 @@
     }
 
     default String getString(int length) {
-        StringBuilder stringBuilder = new StringBuilder();
-        this.visit((string) -> {
-            int j = length - stringBuilder.length();
+        StringBuilder stringbuilder = new StringBuilder();
+
+        this.visit((s) -> {
+            int j = length - stringbuilder.length();
+
             if (j <= 0) {
-                return STOP_ITERATION;
+                return Component.STOP_ITERATION;
             } else {
-                stringBuilder.append(string.length() <= j ? string : string.substring(0, j));
+                stringbuilder.append(s.length() <= j ? s : s.substring(0, j));
                 return Optional.empty();
             }
         });
-        return stringBuilder.toString();
+        return stringbuilder.toString();
     }
 
     List<Component> getSiblings();
@@ -71,43 +91,59 @@
     }
 
     default MutableComponent copy() {
-        return new MutableComponent(this.getContents(), new ArrayList<>(this.getSiblings()), this.getStyle());
+        return new MutableComponent(this.getContents(), new ArrayList(this.getSiblings()), this.getStyle());
     }
 
     FormattedCharSequence getVisualOrderText();
 
     @Override
     default <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> styledVisitor, Style style) {
-        Style style2 = this.getStyle().applyTo(style);
-        Optional<T> optional = this.getContents().visit(styledVisitor, style2);
+        Style chatmodifier1 = this.getStyle().applyTo(style);
+        Optional<T> optional = this.getContents().visit(styledVisitor, chatmodifier1);
+
         if (optional.isPresent()) {
             return optional;
         } else {
-            for(Component component : this.getSiblings()) {
-                Optional<T> optional2 = component.visit(styledVisitor, style2);
-                if (optional2.isPresent()) {
-                    return optional2;
+            Iterator iterator = this.getSiblings().iterator();
+
+            Optional optional1;
+
+            do {
+                if (!iterator.hasNext()) {
+                    return Optional.empty();
                 }
-            }
 
-            return Optional.empty();
+                Component ichatbasecomponent = (Component) iterator.next();
+
+                optional1 = ichatbasecomponent.visit(styledVisitor, chatmodifier1);
+            } while (!optional1.isPresent());
+
+            return optional1;
         }
     }
 
     @Override
     default <T> Optional<T> visit(FormattedText.ContentConsumer<T> visitor) {
         Optional<T> optional = this.getContents().visit(visitor);
+
         if (optional.isPresent()) {
             return optional;
         } else {
-            for(Component component : this.getSiblings()) {
-                Optional<T> optional2 = component.visit(visitor);
-                if (optional2.isPresent()) {
-                    return optional2;
+            Iterator iterator = this.getSiblings().iterator();
+
+            Optional optional1;
+
+            do {
+                if (!iterator.hasNext()) {
+                    return Optional.empty();
                 }
-            }
 
-            return Optional.empty();
+                Component ichatbasecomponent = (Component) iterator.next();
+
+                optional1 = ichatbasecomponent.visit(visitor);
+            } while (!optional1.isPresent());
+
+            return optional1;
         }
     }
 
@@ -117,9 +153,10 @@
 
     default List<Component> toFlatList(Style style) {
         List<Component> list = Lists.newArrayList();
-        this.visit((styleOverride, text) -> {
-            if (!text.isEmpty()) {
-                list.add(literal(text).withStyle(styleOverride));
+
+        this.visit((chatmodifier1, s) -> {
+            if (!s.isEmpty()) {
+                list.add(Component.literal(s).withStyle(chatmodifier1));
             }
 
             return Optional.empty();
@@ -132,13 +169,14 @@
             return true;
         } else {
             List<Component> list = this.toFlatList();
-            List<Component> list2 = text.toFlatList(this.getStyle());
-            return Collections.indexOfSubList(list, list2) != -1;
+            List<Component> list1 = text.toFlatList(this.getStyle());
+
+            return Collections.indexOfSubList(list, list1) != -1;
         }
     }
 
     static Component nullToEmpty(@Nullable String string) {
-        return (Component)(string != null ? literal(string) : CommonComponents.EMPTY);
+        return (Component) (string != null ? Component.literal(string) : CommonComponents.EMPTY);
     }
 
     static MutableComponent literal(String string) {
@@ -174,136 +212,159 @@
     }
 
     public static class Serializer implements JsonDeserializer<MutableComponent>, JsonSerializer<Component> {
-        private static final Gson GSON = Util.make(() -> {
-            GsonBuilder gsonBuilder = new GsonBuilder();
-            gsonBuilder.disableHtmlEscaping();
-            gsonBuilder.registerTypeHierarchyAdapter(Component.class, new Component.Serializer());
-            gsonBuilder.registerTypeHierarchyAdapter(Style.class, new Style.Serializer());
-            gsonBuilder.registerTypeAdapterFactory(new LowerCaseEnumTypeAdapterFactory());
-            return gsonBuilder.create();
+
+        private static final Gson GSON = (Gson) Util.make(() -> {
+            GsonBuilder gsonbuilder = new GsonBuilder();
+
+            gsonbuilder.disableHtmlEscaping();
+            gsonbuilder.registerTypeAdapter(AdventureComponent.class, new AdventureComponent.Serializer()); // Paper
+            gsonbuilder.registerTypeHierarchyAdapter(Component.class, new Component.Serializer());
+            gsonbuilder.registerTypeHierarchyAdapter(Style.class, new Style.Serializer());
+            gsonbuilder.registerTypeAdapterFactory(new LowerCaseEnumTypeAdapterFactory());
+            return gsonbuilder.create();
         });
-        private static final Field JSON_READER_POS = Util.make(() -> {
+        private static final Field JSON_READER_POS = (Field) Util.make(() -> {
             try {
                 new JsonReader(new StringReader(""));
                 Field field = JsonReader.class.getDeclaredField("pos");
+
                 field.setAccessible(true);
                 return field;
-            } catch (NoSuchFieldException var1) {
-                throw new IllegalStateException("Couldn't get field 'pos' for JsonReader", var1);
+            } catch (NoSuchFieldException nosuchfieldexception) {
+                throw new IllegalStateException("Couldn't get field 'pos' for JsonReader", nosuchfieldexception);
             }
         });
-        private static final Field JSON_READER_LINESTART = Util.make(() -> {
+        private static final Field JSON_READER_LINESTART = (Field) Util.make(() -> {
             try {
                 new JsonReader(new StringReader(""));
                 Field field = JsonReader.class.getDeclaredField("lineStart");
+
                 field.setAccessible(true);
                 return field;
-            } catch (NoSuchFieldException var1) {
-                throw new IllegalStateException("Couldn't get field 'lineStart' for JsonReader", var1);
+            } catch (NoSuchFieldException nosuchfieldexception) {
+                throw new IllegalStateException("Couldn't get field 'lineStart' for JsonReader", nosuchfieldexception);
             }
         });
 
-        @Override
-        public MutableComponent deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
-            if (jsonElement.isJsonPrimitive()) {
-                return Component.literal(jsonElement.getAsString());
-            } else if (!jsonElement.isJsonObject()) {
-                if (jsonElement.isJsonArray()) {
-                    JsonArray jsonArray3 = jsonElement.getAsJsonArray();
-                    MutableComponent mutableComponent10 = null;
-
-                    for(JsonElement jsonElement2 : jsonArray3) {
-                        MutableComponent mutableComponent11 = this.deserialize(jsonElement2, jsonElement2.getClass(), jsonDeserializationContext);
-                        if (mutableComponent10 == null) {
-                            mutableComponent10 = mutableComponent11;
-                        } else {
-                            mutableComponent10.append(mutableComponent11);
-                        }
-                    }
+        public Serializer() {}
 
-                    return mutableComponent10;
-                } else {
-                    throw new JsonParseException("Don't know how to turn " + jsonElement + " into a Component");
-                }
+        public MutableComponent deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
+            if (jsonelement.isJsonPrimitive()) {
+                return Component.literal(jsonelement.getAsString());
             } else {
-                JsonObject jsonObject = jsonElement.getAsJsonObject();
-                MutableComponent mutableComponent;
-                if (jsonObject.has("text")) {
-                    String string = GsonHelper.getAsString(jsonObject, "text");
-                    mutableComponent = string.isEmpty() ? Component.empty() : Component.literal(string);
-                } else if (jsonObject.has("translate")) {
-                    String string2 = GsonHelper.getAsString(jsonObject, "translate");
-                    if (jsonObject.has("with")) {
-                        JsonArray jsonArray = GsonHelper.getAsJsonArray(jsonObject, "with");
-                        Object[] objects = new Object[jsonArray.size()];
+                MutableComponent ichatmutablecomponent;
 
-                        for(int i = 0; i < objects.length; ++i) {
-                            objects[i] = unwrapTextArgument(this.deserialize(jsonArray.get(i), type, jsonDeserializationContext));
+                if (!jsonelement.isJsonObject()) {
+                    if (jsonelement.isJsonArray()) {
+                        JsonArray jsonarray = jsonelement.getAsJsonArray();
+
+                        ichatmutablecomponent = null;
+                        Iterator iterator = jsonarray.iterator();
+
+                        while (iterator.hasNext()) {
+                            JsonElement jsonelement1 = (JsonElement) iterator.next();
+                            MutableComponent ichatmutablecomponent1 = this.deserialize(jsonelement1, jsonelement1.getClass(), jsondeserializationcontext);
+
+                            if (ichatmutablecomponent == null) {
+                                ichatmutablecomponent = ichatmutablecomponent1;
+                            } else {
+                                ichatmutablecomponent.append((Component) ichatmutablecomponent1);
+                            }
                         }
 
-                        mutableComponent = Component.translatable(string2, objects);
+                        return ichatmutablecomponent;
                     } else {
-                        mutableComponent = Component.translatable(string2);
-                    }
-                } else if (jsonObject.has("score")) {
-                    JsonObject jsonObject2 = GsonHelper.getAsJsonObject(jsonObject, "score");
-                    if (!jsonObject2.has("name") || !jsonObject2.has("objective")) {
-                        throw new JsonParseException("A score component needs a least a name and an objective");
+                        throw new JsonParseException("Don't know how to turn " + jsonelement + " into a Component");
                     }
-
-                    mutableComponent = Component.score(GsonHelper.getAsString(jsonObject2, "name"), GsonHelper.getAsString(jsonObject2, "objective"));
-                } else if (jsonObject.has("selector")) {
-                    Optional<Component> optional = this.parseSeparator(type, jsonDeserializationContext, jsonObject);
-                    mutableComponent = Component.selector(GsonHelper.getAsString(jsonObject, "selector"), optional);
-                } else if (jsonObject.has("keybind")) {
-                    mutableComponent = Component.keybind(GsonHelper.getAsString(jsonObject, "keybind"));
                 } else {
-                    if (!jsonObject.has("nbt")) {
-                        throw new JsonParseException("Don't know how to turn " + jsonElement + " into a Component");
-                    }
+                    JsonObject jsonobject = jsonelement.getAsJsonObject();
+                    String s;
 
-                    String string3 = GsonHelper.getAsString(jsonObject, "nbt");
-                    Optional<Component> optional2 = this.parseSeparator(type, jsonDeserializationContext, jsonObject);
-                    boolean bl = GsonHelper.getAsBoolean(jsonObject, "interpret", false);
-                    DataSource dataSource;
-                    if (jsonObject.has("block")) {
-                        dataSource = new BlockDataSource(GsonHelper.getAsString(jsonObject, "block"));
-                    } else if (jsonObject.has("entity")) {
-                        dataSource = new EntityDataSource(GsonHelper.getAsString(jsonObject, "entity"));
+                    if (jsonobject.has("text")) {
+                        s = GsonHelper.getAsString(jsonobject, "text");
+                        ichatmutablecomponent = s.isEmpty() ? Component.empty() : Component.literal(s);
+                    } else if (jsonobject.has("translate")) {
+                        s = GsonHelper.getAsString(jsonobject, "translate");
+                        if (jsonobject.has("with")) {
+                            JsonArray jsonarray1 = GsonHelper.getAsJsonArray(jsonobject, "with");
+                            Object[] aobject = new Object[jsonarray1.size()];
+
+                            for (int i = 0; i < aobject.length; ++i) {
+                                aobject[i] = Serializer.unwrapTextArgument(this.deserialize(jsonarray1.get(i), type, jsondeserializationcontext));
+                            }
+
+                            ichatmutablecomponent = Component.translatable(s, aobject);
+                        } else {
+                            ichatmutablecomponent = Component.translatable(s);
+                        }
+                    } else if (jsonobject.has("score")) {
+                        JsonObject jsonobject1 = GsonHelper.getAsJsonObject(jsonobject, "score");
+
+                        if (!jsonobject1.has("name") || !jsonobject1.has("objective")) {
+                            throw new JsonParseException("A score component needs a least a name and an objective");
+                        }
+
+                        ichatmutablecomponent = Component.score(GsonHelper.getAsString(jsonobject1, "name"), GsonHelper.getAsString(jsonobject1, "objective"));
+                    } else if (jsonobject.has("selector")) {
+                        Optional<Component> optional = this.parseSeparator(type, jsondeserializationcontext, jsonobject);
+
+                        ichatmutablecomponent = Component.selector(GsonHelper.getAsString(jsonobject, "selector"), optional);
+                    } else if (jsonobject.has("keybind")) {
+                        ichatmutablecomponent = Component.keybind(GsonHelper.getAsString(jsonobject, "keybind"));
                     } else {
-                        if (!jsonObject.has("storage")) {
-                            throw new JsonParseException("Don't know how to turn " + jsonElement + " into a Component");
+                        if (!jsonobject.has("nbt")) {
+                            throw new JsonParseException("Don't know how to turn " + jsonelement + " into a Component");
                         }
 
-                        dataSource = new StorageDataSource(new ResourceLocation(GsonHelper.getAsString(jsonObject, "storage")));
-                    }
+                        s = GsonHelper.getAsString(jsonobject, "nbt");
+                        Optional<Component> optional1 = this.parseSeparator(type, jsondeserializationcontext, jsonobject);
+                        boolean flag = GsonHelper.getAsBoolean(jsonobject, "interpret", false);
+                        Object object;
 
-                    mutableComponent = Component.nbt(string3, bl, optional2, dataSource);
-                }
+                        if (jsonobject.has("block")) {
+                            object = new BlockDataSource(GsonHelper.getAsString(jsonobject, "block"));
+                        } else if (jsonobject.has("entity")) {
+                            object = new EntityDataSource(GsonHelper.getAsString(jsonobject, "entity"));
+                        } else {
+                            if (!jsonobject.has("storage")) {
+                                throw new JsonParseException("Don't know how to turn " + jsonelement + " into a Component");
+                            }
 
-                if (jsonObject.has("extra")) {
-                    JsonArray jsonArray2 = GsonHelper.getAsJsonArray(jsonObject, "extra");
-                    if (jsonArray2.size() <= 0) {
-                        throw new JsonParseException("Unexpected empty array of components");
+                            object = new StorageDataSource(new ResourceLocation(GsonHelper.getAsString(jsonobject, "storage")));
+                        }
+
+                        ichatmutablecomponent = Component.nbt(s, flag, optional1, (DataSource) object);
                     }
 
-                    for(int j = 0; j < jsonArray2.size(); ++j) {
-                        mutableComponent.append(this.deserialize(jsonArray2.get(j), type, jsonDeserializationContext));
+                    if (jsonobject.has("extra")) {
+                        JsonArray jsonarray2 = GsonHelper.getAsJsonArray(jsonobject, "extra");
+
+                        if (jsonarray2.size() <= 0) {
+                            throw new JsonParseException("Unexpected empty array of components");
+                        }
+
+                        for (int j = 0; j < jsonarray2.size(); ++j) {
+                            ichatmutablecomponent.append((Component) this.deserialize(jsonarray2.get(j), type, jsondeserializationcontext));
+                        }
                     }
-                }
 
-                mutableComponent.setStyle(jsonDeserializationContext.deserialize(jsonElement, Style.class));
-                return mutableComponent;
+                    ichatmutablecomponent.setStyle((Style) jsondeserializationcontext.deserialize(jsonelement, Style.class));
+                    return ichatmutablecomponent;
+                }
             }
         }
 
         private static Object unwrapTextArgument(Object text) {
-            if (text instanceof Component component) {
-                if (component.getStyle().isEmpty() && component.getSiblings().isEmpty()) {
-                    ComponentContents componentContents = component.getContents();
-                    if (componentContents instanceof LiteralContents) {
-                        LiteralContents literalContents = (LiteralContents)componentContents;
-                        return literalContents.text();
+            if (text instanceof Component) {
+                Component ichatbasecomponent = (Component) text;
+
+                if (ichatbasecomponent.getStyle().isEmpty() && ichatbasecomponent.getSiblings().isEmpty()) {
+                    ComponentContents componentcontents = ichatbasecomponent.getContents();
+
+                    if (componentcontents instanceof LiteralContents) {
+                        LiteralContents literalcontents = (LiteralContents) componentcontents;
+
+                        return literalcontents.text();
                     }
                 }
             }
@@ -316,148 +377,173 @@
         }
 
         private void serializeStyle(Style style, JsonObject json, JsonSerializationContext context) {
-            JsonElement jsonElement = context.serialize(style);
-            if (jsonElement.isJsonObject()) {
-                JsonObject jsonObject = (JsonObject)jsonElement;
+            JsonElement jsonelement = context.serialize(style);
 
-                for(Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
-                    json.add(entry.getKey(), entry.getValue());
+            if (jsonelement.isJsonObject()) {
+                JsonObject jsonobject1 = (JsonObject) jsonelement;
+                Iterator iterator = jsonobject1.entrySet().iterator();
+
+                while (iterator.hasNext()) {
+                    Entry<String, JsonElement> entry = (Entry) iterator.next();
+
+                    json.add((String) entry.getKey(), (JsonElement) entry.getValue());
                 }
             }
 
         }
 
-        @Override
-        public JsonElement serialize(Component component, Type type, JsonSerializationContext jsonSerializationContext) {
-            JsonObject jsonObject = new JsonObject();
-            if (!component.getStyle().isEmpty()) {
-                this.serializeStyle(component.getStyle(), jsonObject, jsonSerializationContext);
+        public JsonElement serialize(Component ichatbasecomponent, Type type, JsonSerializationContext jsonserializationcontext) {
+            if (ichatbasecomponent instanceof AdventureComponent) return jsonserializationcontext.serialize(ichatbasecomponent); // Paper
+            JsonObject jsonobject = new JsonObject();
+
+            if (!ichatbasecomponent.getStyle().isEmpty()) {
+                this.serializeStyle(ichatbasecomponent.getStyle(), jsonobject, jsonserializationcontext);
             }
 
-            if (!component.getSiblings().isEmpty()) {
-                JsonArray jsonArray = new JsonArray();
+            if (!ichatbasecomponent.getSiblings().isEmpty()) {
+                JsonArray jsonarray = new JsonArray();
+                Iterator iterator = ichatbasecomponent.getSiblings().iterator();
 
-                for(Component component2 : component.getSiblings()) {
-                    jsonArray.add(this.serialize(component2, Component.class, jsonSerializationContext));
+                while (iterator.hasNext()) {
+                    Component ichatbasecomponent1 = (Component) iterator.next();
+
+                    jsonarray.add(this.serialize(ichatbasecomponent1, Component.class, jsonserializationcontext));
                 }
 
-                jsonObject.add("extra", jsonArray);
+                jsonobject.add("extra", jsonarray);
             }
 
-            ComponentContents componentContents = component.getContents();
-            if (componentContents == ComponentContents.EMPTY) {
-                jsonObject.addProperty("text", "");
-            } else if (componentContents instanceof LiteralContents) {
-                LiteralContents literalContents = (LiteralContents)componentContents;
-                jsonObject.addProperty("text", literalContents.text());
-            } else if (componentContents instanceof TranslatableContents) {
-                TranslatableContents translatableContents = (TranslatableContents)componentContents;
-                jsonObject.addProperty("translate", translatableContents.getKey());
-                if (translatableContents.getArgs().length > 0) {
-                    JsonArray jsonArray2 = new JsonArray();
+            ComponentContents componentcontents = ichatbasecomponent.getContents();
+
+            if (componentcontents == ComponentContents.EMPTY) {
+                jsonobject.addProperty("text", "");
+            } else if (componentcontents instanceof LiteralContents) {
+                LiteralContents literalcontents = (LiteralContents) componentcontents;
+
+                jsonobject.addProperty("text", literalcontents.text());
+            } else if (componentcontents instanceof TranslatableContents) {
+                TranslatableContents translatablecontents = (TranslatableContents) componentcontents;
+
+                jsonobject.addProperty("translate", translatablecontents.getKey());
+                if (translatablecontents.getArgs().length > 0) {
+                    JsonArray jsonarray1 = new JsonArray();
+                    Object[] aobject = translatablecontents.getArgs();
+                    int i = aobject.length;
+
+                    for (int j = 0; j < i; ++j) {
+                        Object object = aobject[j];
 
-                    for(Object object : translatableContents.getArgs()) {
                         if (object instanceof Component) {
-                            jsonArray2.add(this.serialize((Component)object, object.getClass(), jsonSerializationContext));
+                            jsonarray1.add(this.serialize((Component) object, object.getClass(), jsonserializationcontext));
                         } else {
-                            jsonArray2.add(new JsonPrimitive(String.valueOf(object)));
+                            jsonarray1.add(new JsonPrimitive(String.valueOf(object)));
                         }
                     }
 
-                    jsonObject.add("with", jsonArray2);
+                    jsonobject.add("with", jsonarray1);
                 }
-            } else if (componentContents instanceof ScoreContents) {
-                ScoreContents scoreContents = (ScoreContents)componentContents;
-                JsonObject jsonObject2 = new JsonObject();
-                jsonObject2.addProperty("name", scoreContents.getName());
-                jsonObject2.addProperty("objective", scoreContents.getObjective());
-                jsonObject.add("score", jsonObject2);
-            } else if (componentContents instanceof SelectorContents) {
-                SelectorContents selectorContents = (SelectorContents)componentContents;
-                jsonObject.addProperty("selector", selectorContents.getPattern());
-                this.serializeSeparator(jsonSerializationContext, jsonObject, selectorContents.getSeparator());
-            } else if (componentContents instanceof KeybindContents) {
-                KeybindContents keybindContents = (KeybindContents)componentContents;
-                jsonObject.addProperty("keybind", keybindContents.getName());
+            } else if (componentcontents instanceof ScoreContents) {
+                ScoreContents scorecontents = (ScoreContents) componentcontents;
+                JsonObject jsonobject1 = new JsonObject();
+
+                jsonobject1.addProperty("name", scorecontents.getName());
+                jsonobject1.addProperty("objective", scorecontents.getObjective());
+                jsonobject.add("score", jsonobject1);
+            } else if (componentcontents instanceof SelectorContents) {
+                SelectorContents selectorcontents = (SelectorContents) componentcontents;
+
+                jsonobject.addProperty("selector", selectorcontents.getPattern());
+                this.serializeSeparator(jsonserializationcontext, jsonobject, selectorcontents.getSeparator());
+            } else if (componentcontents instanceof KeybindContents) {
+                KeybindContents keybindcontents = (KeybindContents) componentcontents;
+
+                jsonobject.addProperty("keybind", keybindcontents.getName());
             } else {
-                if (!(componentContents instanceof NbtContents)) {
-                    throw new IllegalArgumentException("Don't know how to serialize " + componentContents + " as a Component");
+                if (!(componentcontents instanceof NbtContents)) {
+                    throw new IllegalArgumentException("Don't know how to serialize " + componentcontents + " as a Component");
                 }
 
-                NbtContents nbtContents = (NbtContents)componentContents;
-                jsonObject.addProperty("nbt", nbtContents.getNbtPath());
-                jsonObject.addProperty("interpret", nbtContents.isInterpreting());
-                this.serializeSeparator(jsonSerializationContext, jsonObject, nbtContents.getSeparator());
-                DataSource dataSource = nbtContents.getDataSource();
-                if (dataSource instanceof BlockDataSource) {
-                    BlockDataSource blockDataSource = (BlockDataSource)dataSource;
-                    jsonObject.addProperty("block", blockDataSource.posPattern());
-                } else if (dataSource instanceof EntityDataSource) {
-                    EntityDataSource entityDataSource = (EntityDataSource)dataSource;
-                    jsonObject.addProperty("entity", entityDataSource.selectorPattern());
+                NbtContents nbtcontents = (NbtContents) componentcontents;
+
+                jsonobject.addProperty("nbt", nbtcontents.getNbtPath());
+                jsonobject.addProperty("interpret", nbtcontents.isInterpreting());
+                this.serializeSeparator(jsonserializationcontext, jsonobject, nbtcontents.getSeparator());
+                DataSource datasource = nbtcontents.getDataSource();
+
+                if (datasource instanceof BlockDataSource) {
+                    BlockDataSource blockdatasource = (BlockDataSource) datasource;
+
+                    jsonobject.addProperty("block", blockdatasource.posPattern());
+                } else if (datasource instanceof EntityDataSource) {
+                    EntityDataSource entitydatasource = (EntityDataSource) datasource;
+
+                    jsonobject.addProperty("entity", entitydatasource.selectorPattern());
                 } else {
-                    if (!(dataSource instanceof StorageDataSource)) {
-                        throw new IllegalArgumentException("Don't know how to serialize " + componentContents + " as a Component");
+                    if (!(datasource instanceof StorageDataSource)) {
+                        throw new IllegalArgumentException("Don't know how to serialize " + componentcontents + " as a Component");
                     }
 
-                    StorageDataSource storageDataSource = (StorageDataSource)dataSource;
-                    jsonObject.addProperty("storage", storageDataSource.id().toString());
+                    StorageDataSource storagedatasource = (StorageDataSource) datasource;
+
+                    jsonobject.addProperty("storage", storagedatasource.id().toString());
                 }
             }
 
-            return jsonObject;
+            return jsonobject;
         }
 
         private void serializeSeparator(JsonSerializationContext context, JsonObject json, Optional<Component> separator) {
-            separator.ifPresent((separatorx) -> {
-                json.add("separator", this.serialize(separatorx, separatorx.getClass(), context));
+            separator.ifPresent((ichatbasecomponent) -> {
+                json.add("separator", this.serialize(ichatbasecomponent, ichatbasecomponent.getClass(), context));
             });
         }
 
         public static String toJson(Component text) {
-            return GSON.toJson(text);
+            return Component.Serializer.GSON.toJson(text);
         }
 
         public static String toStableJson(Component text) {
-            return GsonHelper.toStableString(toJsonTree(text));
+            return GsonHelper.toStableString(Serializer.toJsonTree(text));
         }
 
         public static JsonElement toJsonTree(Component text) {
-            return GSON.toJsonTree(text);
+            return Component.Serializer.GSON.toJsonTree(text);
         }
 
         @Nullable
         public static MutableComponent fromJson(String json) {
-            return GsonHelper.fromNullableJson(GSON, json, MutableComponent.class, false);
+            return (MutableComponent) GsonHelper.fromNullableJson(Component.Serializer.GSON, json, MutableComponent.class, false);
         }
 
         @Nullable
         public static MutableComponent fromJson(JsonElement json) {
-            return GSON.fromJson(json, MutableComponent.class);
+            return (MutableComponent) Component.Serializer.GSON.fromJson(json, MutableComponent.class);
         }
 
         @Nullable
         public static MutableComponent fromJsonLenient(String json) {
-            return GsonHelper.fromNullableJson(GSON, json, MutableComponent.class, true);
+            return (MutableComponent) GsonHelper.fromNullableJson(Component.Serializer.GSON, json, MutableComponent.class, true);
         }
 
         public static MutableComponent fromJson(com.mojang.brigadier.StringReader reader) {
             try {
-                JsonReader jsonReader = new JsonReader(new StringReader(reader.getRemaining()));
-                jsonReader.setLenient(false);
-                MutableComponent mutableComponent = GSON.getAdapter(MutableComponent.class).read(jsonReader);
-                reader.setCursor(reader.getCursor() + getPos(jsonReader));
-                return mutableComponent;
-            } catch (StackOverflowError | IOException var3) {
-                throw new JsonParseException(var3);
+                JsonReader jsonreader = new JsonReader(new StringReader(reader.getRemaining()));
+
+                jsonreader.setLenient(false);
+                MutableComponent ichatmutablecomponent = (MutableComponent) Component.Serializer.GSON.getAdapter(MutableComponent.class).read(jsonreader);
+
+                reader.setCursor(reader.getCursor() + Serializer.getPos(jsonreader));
+                return ichatmutablecomponent;
+            } catch (StackOverflowError | IOException ioexception) {
+                throw new JsonParseException(ioexception);
             }
         }
 
         private static int getPos(JsonReader reader) {
             try {
-                return JSON_READER_POS.getInt(reader) - JSON_READER_LINESTART.getInt(reader) + 1;
-            } catch (IllegalAccessException var2) {
-                throw new IllegalStateException("Couldn't read position of JsonReader", var2);
+                return Component.Serializer.JSON_READER_POS.getInt(reader) - Component.Serializer.JSON_READER_LINESTART.getInt(reader) + 1;
+            } catch (IllegalAccessException illegalaccessexception) {
+                throw new IllegalStateException("Couldn't read position of JsonReader", illegalaccessexception);
             }
         }
     }
