Interface MetadataKey<V>

  • Type Parameters:
    V - Metadata value type.
    All Superinterfaces:
    Comparable<net.kyori.adventure.key.Key>, net.kyori.examination.Examinable, net.kyori.adventure.key.Key, net.kyori.adventure.key.Keyed, net.kyori.adventure.key.Namespaced

    @NonExtendable
    public interface MetadataKey<V>
    extends net.kyori.adventure.key.Key
    An identifying object used to store and retrieve metadata from MetadataHolders.

    Metadata key are similar to the Adventure Key objects, except metadata keys also consist of a value type.

    Key namespaces must match [a-z0-9_\-.]+

    Key values must match [a-z0-9_\-./]+

    • Method Detail

      • string

        @Contract(value="_ -> new",
                  pure=true)
        @NotNull
        static @NotNull MetadataKey<String> string​(@NotNull @KeyPattern
                                                   @NotNull String string)
        Returns a new string metadata key.

        Equivalent to calling of(Class, String) with String.class as the type.

        Parameters:
        string - Metadata key string.
        Returns:
        new metadata key.
        See Also:
        of(Class, String)
      • string

        @Contract(value="_, _ -> new",
                  pure=true)
        @NotNull
        static @NotNull MetadataKey<String> string​(@NotNull @Namespace
                                                   @NotNull String namespace,
                                                   @NotNull @Value
                                                   @NotNull String value)
        Returns a new string metadata key.

        Equivalent to calling of(Class, String, String) with String.class as the type.

        Parameters:
        namespace - Metadata key namespace.
        value - Metadata key value.
        Returns:
        new metadata key.
        See Also:
        of(Class, String)
      • bool

        @Contract(value="_ -> new",
                  pure=true)
        @NotNull
        static @NotNull MetadataKey<Boolean> bool​(@NotNull @KeyPattern
                                                  @NotNull String string)
        Returns a new boolean metadata key.

        Equivalent to calling of(Class, String) with Boolean.class as the type.

        Parameters:
        string - Metadata key string.
        Returns:
        new metadata key.
        See Also:
        of(Class, String)
      • bool

        @Contract(value="_, _ -> new",
                  pure=true)
        @NotNull
        static @NotNull MetadataKey<Boolean> bool​(@NotNull @Namespace
                                                  @NotNull String namespace,
                                                  @NotNull @Value
                                                  @NotNull String value)
        Returns a new boolean metadata key.

        Equivalent to calling of(Class, String, String) with Boolean.class as the type.

        Parameters:
        namespace - Metadata key namespace.
        value - Metadata key value.
        Returns:
        new metadata key.
        See Also:
        of(Class, String, String)
      • integer

        @Contract(value="_ -> new",
                  pure=true)
        @NotNull
        static @NotNull MetadataKey<Integer> integer​(@NotNull @KeyPattern
                                                     @NotNull String string)
        Returns a new boolean metadata key.

        Equivalent to calling of(Class, String) with Integer.class as the type.

        Parameters:
        string - Metadata key string.
        Returns:
        new metadata key.
        See Also:
        of(Class, String)
      • integer

        @Contract(value="_, _ -> new",
                  pure=true)
        @NotNull
        static @NotNull MetadataKey<Integer> integer​(@NotNull @Namespace
                                                     @NotNull String namespace,
                                                     @NotNull @Value
                                                     @NotNull String value)
        Returns a new boolean metadata key.

        Equivalent to calling of(Class, String, String) with Integer.class as the type.

        Parameters:
        namespace - Metadata key namespace.
        value - Metadata key value.
        Returns:
        new metadata key.
        See Also:
        of(Class, String, String)
      • uuid

        @Contract(value="_ -> new",
                  pure=true)
        @NotNull
        static @NotNull MetadataKey<UUID> uuid​(@NotNull @KeyPattern
                                               @NotNull String string)
        Returns a new UUID metadata key.

        Equivalent to calling of(Class, String) with UUID.class as the type.

        Parameters:
        string - Metadata key string.
        Returns:
        new metadata key.
        See Also:
        of(Class, String)
      • uuid

        @Contract(value="_, _ -> new",
                  pure=true)
        @NotNull
        static @NotNull MetadataKey<UUID> uuid​(@NotNull @Namespace
                                               @NotNull String namespace,
                                               @Value @NotNull
                                               @NotNull String value)
        Returns a new UUID metadata key.

        Equivalent to calling of(Class, String, String) with UUID.class as the type.

        Parameters:
        namespace - Metadata key namespace.
        value - Metadata key value.
        Returns:
        new metadata key.
        See Also:
        of(Class, String, String)
      • of

        @Contract(value="_, _ -> new",
                  pure=true)
        @NotNull
        static <V> @NotNull MetadataKey<V> of​(@NotNull
                                              @NotNull Class<V> type,
                                              @NotNull @KeyPattern
                                              @NotNull String string)
        Returns a new metadata key.

        string will be parsed as a key, using DEFAULT_SEPARATOR as a separator between the namespace and value.

        The key namespace is optional. If you do not provide one, then MINECRAFT_NAMESPACE will be used as the namespace, and the string will be used as the value.

        Type Parameters:
        V - Metadata value type.
        Parameters:
        type - Metadata key value type class.
        string - Metadata key string.
        Returns:
        new metadata key.
        Throws:
        IllegalArgumentException - if the namespace or valid contains an invalid character.
      • of

        @Contract(value="_, _, _ -> new",
                  pure=true)
        @NotNull
        static <V> @NotNull MetadataKey<V> of​(@NotNull
                                              @NotNull Class<V> type,
                                              @NotNull @Namespace
                                              @NotNull String namespace,
                                              @NotNull @Value
                                              @NotNull String value)
        Returns a new metadata key.
        Type Parameters:
        V - Metadata value type.
        Parameters:
        type - Metadata value type class.
        namespace - Metadata key namespace.
        value - Metadata key value.
        Returns:
        new metadata key.
        Throws:
        IllegalArgumentException - if the namespace or value contains an invalid character.
      • type

        @NotNull
        @NotNull Class<V> type()
        Returns the metadata value type.
        Returns:
        metadata value type.