Class DataComponentValueConverterRegistry


  • public final class DataComponentValueConverterRegistry
    extends java.lang.Object
    A registry for conversions between different data component value holder classes.

    Conversions are discovered by ServiceLoader lookup of implementations of the DataComponentValueConverterRegistry.Provider interface (on the classloader which loaded Adventure).

    Since:
    4.17.0
    • Method Detail

      • knownProviders

        public static java.util.Set<Key> knownProviders()
        Get the id's of all registered conversion providers.
        Returns:
        an unmodifiable set of the known provider ids
        Since:
        4.1.7.0
      • convert

        @NotNull
        public static <O extends DataComponentValue> O convert​(@NotNull
                                                               @NotNull java.lang.Class<O> target,
                                                               @NotNull
                                                               @NotNull Key key,
                                                               @NotNull
                                                               @NotNull DataComponentValue in)
        Try to convert the data component value in to the provided output type.
        Type Parameters:
        O - the output type
        Parameters:
        target - the target type
        key - the key this value is for
        in - the input value
        Returns:
        a value of target type
        Since:
        4.17.0