Interface Key

  • All Superinterfaces:
    Comparable<Key>, net.kyori.examination.Examinable

    public interface Key
    extends Comparable<Key>, net.kyori.examination.Examinable
    An identifying object used to fetch and/or store unique objects.

    A key consists of:

    namespace
    in most cases this should be your plugin or organization name
    value
    what this key leads to, e.g "translations" or "entity.firework_rocket.blast"

    Valid characters for namespaces are [a-z0-9_.-].

    Valid characters for values are [a-z0-9/._-].

    Some examples of possible custom keys:

    • my_plugin:translations
    • my_plugin:weapon.amazing-weapon_damage-attribute
    • my_organization:music.song_1
    • my_organization:item.magic_button
    Since:
    4.0.0
    • Field Detail

      • MINECRAFT_NAMESPACE

        static final String MINECRAFT_NAMESPACE
        The namespace for Minecraft.
        Since:
        4.0.0
        See Also:
        Constant Field Values
    • Method Detail

      • key

        static @NonNull Key key​(@NonNull String string)
        Creates a key.
        Parameters:
        string - the string
        Returns:
        the key
        Throws:
        InvalidKeyException - if the namespace or value contains an invalid character
        Since:
        4.0.0
      • key

        static @NonNull Key key​(@NonNull String string,
                                char character)
        Creates a key.
        Parameters:
        string - the string
        character - the character
        Returns:
        the key
        Throws:
        InvalidKeyException - if the namespace or value contains an invalid character
        Since:
        4.0.0
      • key

        static @NonNull Key key​(@NonNull Namespaced namespaced,
                                @NonNull String value)
        Creates a key.
        Parameters:
        namespaced - the namespace source
        value - the value
        Returns:
        the key
        Throws:
        InvalidKeyException - if the namespace or value contains an invalid character
        Since:
        4.4.0
      • key

        static @NonNull Key key​(@NonNull String namespace,
                                @NonNull String value)
        Creates a key.
        Parameters:
        namespace - the namespace
        value - the value
        Returns:
        the key
        Throws:
        InvalidKeyException - if the namespace or value contains an invalid character
        Since:
        4.0.0
      • namespace

        @NonNull String namespace()
        Gets the namespace.
        Returns:
        the namespace
        Since:
        4.0.0
      • value

        @NonNull String value()
        Gets the value.
        Returns:
        the value
        Since:
        4.0.0
      • asString

        @NonNull String asString()
        Returns the string representation of this key.
        Returns:
        the string representation
        Since:
        4.0.0
      • examinableProperties

        default @NonNull Stream<? extends net.kyori.examination.ExaminableProperty> examinableProperties()
        Specified by:
        examinableProperties in interface net.kyori.examination.Examinable