Interface Key
-
- All Superinterfaces:
Comparable<Key>,net.kyori.examination.Examinable,Namespaced
public interface Key extends Comparable<Key>, net.kyori.examination.Examinable, Namespaced
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 Summary
Fields Modifier and Type Field Description static StringMINECRAFT_NAMESPACEThe namespace for Minecraft.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description @NotNull StringasString()Returns the string representation of this key.static @NotNull Comparator<? super Key>comparator()Gets the comparator.default intcompareTo(@NotNull Key that)default @NotNull Stream<? extends net.kyori.examination.ExaminableProperty>examinableProperties()static @NotNull Keykey(@NotNull String string)Creates a key.static @NotNull Keykey(@NotNull String string, char character)Creates a key.static @NotNull Keykey(@NotNull String namespace, @NotNull String value)Creates a key.static @NotNull Keykey(@NotNull Namespaced namespaced, @NotNull String value)Creates a key.@NotNull Stringnamespace()Gets the namespace.@NotNull Stringvalue()Gets the value.
-
-
-
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
@NotNull static @NotNull Key key(@NotNull @NotNull String string)
Creates a key.This will parse
stringas a key, using:as a separator between the namespace and the value.The namespace is optional. If you do not provide one (for example, if you provide just
playeror:playeras the string) thenMINECRAFT_NAMESPACEwill be used as a namespace andstringwill be used as the value, removing the colon if necessary.- Parameters:
string- the string- Returns:
- the key
- Throws:
InvalidKeyException- if the namespace or value contains an invalid character- Since:
- 4.0.0
-
key
@NotNull static @NotNull Key key(@NotNull @NotNull String string, char character)
Creates a key.This will parse
stringas a key, usingcharacteras a separator between the namespace and the value.The namespace is optional. If you do not provide one (for example, if you provide
playerorcharacter + "player"as the string) thenMINECRAFT_NAMESPACEwill be used as a namespace andstringwill be used as the value, removing the provided separator character if necessary.- Parameters:
string- the stringcharacter- the character that separates the namespace from the value- Returns:
- the key
- Throws:
InvalidKeyException- if the namespace or value contains an invalid character- Since:
- 4.0.0
-
key
@NotNull static @NotNull Key key(@NotNull @NotNull Namespaced namespaced, @NotNull @NotNull String value)
Creates a key.- Parameters:
namespaced- the namespace sourcevalue- the value- Returns:
- the key
- Throws:
InvalidKeyException- if the namespace or value contains an invalid character- Since:
- 4.4.0
-
key
@NotNull static @NotNull Key key(@NotNull @NotNull String namespace, @NotNull @NotNull String value)
Creates a key.- Parameters:
namespace- the namespacevalue- the value- Returns:
- the key
- Throws:
InvalidKeyException- if the namespace or value contains an invalid character- Since:
- 4.0.0
-
comparator
@NotNull static @NotNull Comparator<? super Key> comparator()
- Returns:
- a comparator for keys
- Since:
- 4.10.0
-
namespace
@NotNull @NotNull String namespace()
Gets the namespace.- Specified by:
namespacein interfaceNamespaced- Returns:
- the namespace
- Since:
- 4.0.0
-
value
@NotNull @NotNull String value()
Gets the value.- Returns:
- the value
- Since:
- 4.0.0
-
asString
@NotNull @NotNull String asString()
Returns the string representation of this key.- Returns:
- the string representation
- Since:
- 4.0.0
-
examinableProperties
@NotNull default @NotNull Stream<? extends net.kyori.examination.ExaminableProperty> examinableProperties()
- Specified by:
examinablePropertiesin interfacenet.kyori.examination.Examinable
-
compareTo
default int compareTo(@NotNull @NotNull Key that)- Specified by:
compareToin interfaceComparable<Key>
-
-