@Override public WrappedChatComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { if (json.isJsonPrimitive()) { return WrappedChatComponent.fromJson(json.getAsString()); } return null; }
/** * Retrieve a deep copy of the current chat component. * @return A copy of the current component. */ public WrappedChatComponent deepClone() { return fromJson(getJson()); }
/** * Converts an array of {@link BaseComponent}s into a ProtocolLib wrapper * @param components BaseComponent array * @return ProtocolLib wrapper */ public static WrappedChatComponent fromBaseComponent(BaseComponent... components) { return WrappedChatComponent.fromJson(ComponentSerializer.toString(components)); } }
@Override public WrappedChatComponent[] getSpecific(Object generic) { NbtBase<?> nbtBase = nbtConverter.getSpecific(generic); NbtCompound compound = (NbtCompound) nbtBase; WrappedChatComponent[] components = new WrappedChatComponent[lines]; for (int i = 0; i < lines; i++) { if (compound.containsKey("Text" + (i + 1))) { components[i] = WrappedChatComponent.fromJson(compound.getString("Text" + (i + 1))); } else { components[i] = WrappedChatComponent.fromText(""); } } return components; }
customNameWatchableObject.setValue(Optional.of(WrappedChatComponent.fromJson(customName).getHandle())); } else { customNameWatchableObject.setValue(customName);