Class NamespacedKey
- All Implemented Interfaces:
Namespaced,Comparable<net.kyori.adventure.key.Key>,net.kyori.adventure.key.Key,net.kyori.adventure.key.Keyed,net.kyori.adventure.key.Namespaced,net.kyori.examination.Examinable
Namespaces may only contain lowercase alphanumeric characters, periods, underscores, and hyphens.
Keys may only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe namespace representing all keys generated by Bukkit for backwards compatibility measures.static final StringThe namespace representing all inbuilt keys.Fields inherited from interface net.kyori.adventure.key.Key
DEFAULT_SEPARATOR, MINECRAFT_NAMESPACE -
Constructor Summary
ConstructorsConstructorDescriptionNamespacedKey(@NotNull String namespace, @NotNull String key) Create a key in a specific namespace.NamespacedKey(@NotNull Plugin plugin, @NotNull String key) Create a key in the plugin's namespace. -
Method Summary
Modifier and TypeMethodDescription@NotNull StringasString()booleanstatic @Nullable NamespacedKeyfromString(@NotNull String key) Get a NamespacedKey from the supplied string.static @Nullable NamespacedKeyfromString(@NotNull String string, @Nullable Plugin defaultNamespace) Get a NamespacedKey from the supplied string with a default namespace if a namespace is not defined.@NotNull StringgetKey()Gets the key corresponding to this resource@NotNull StringGets the namespace this resource is a part ofinthashCode()static @NotNull NamespacedKeyGet a key in the Minecraft namespace.@NotNull Stringstatic @NotNull NamespacedKeyDeprecated.should never be used by plugins, for internal use only!!toString()@NotNull Stringvalue()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.kyori.examination.Examinable
examinableName, examineMethods inherited from interface net.kyori.adventure.key.Key
asMinimalString, compareTo, examinableProperties, key
-
Field Details
-
MINECRAFT
The namespace representing all inbuilt keys.- See Also:
-
BUKKIT
The namespace representing all keys generated by Bukkit for backwards compatibility measures.- See Also:
-
-
Constructor Details
-
NamespacedKey
Create a key in a specific namespace.For most plugin related code, you should prefer using the
NamespacedKey(Plugin, String)constructor.- Parameters:
namespace- namespacekey- key- See Also:
-
NamespacedKey
Create a key in the plugin's namespace.Namespaces may only contain lowercase alphanumeric characters, periods, underscores, and hyphens.
Keys may only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.
- Parameters:
plugin- the plugin to use for the namespacekey- the key to create
-
-
Method Details
-
getNamespace
Description copied from interface:NamespacedGets the namespace this resource is a part ofThis is contractually obligated to only contain lowercase alphanumeric characters, periods, underscores, and hyphens.
- Specified by:
getNamespacein interfaceNamespaced- Returns:
- resource namespace
-
getKey
Description copied from interface:NamespacedGets the key corresponding to this resourceThis is contractually obligated to only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.
- Specified by:
getKeyin interfaceNamespaced- Returns:
- resource key
-
hashCode
public int hashCode() -
equals
-
toString
-
randomKey
Deprecated.should never be used by plugins, for internal use only!!Return a new random key in theBUKKITnamespace.- Returns:
- new key
-
minecraft
Get a key in the Minecraft namespace.- Parameters:
key- the key to use- Returns:
- new key in the Minecraft namespace
-
fromString
@Nullable public static @Nullable NamespacedKey fromString(@NotNull @NotNull String string, @Nullable @Nullable Plugin defaultNamespace) Get a NamespacedKey from the supplied string with a default namespace if a namespace is not defined. This is a utility method meant to fetch a NamespacedKey from user input. Please note that casing does matter and any instance of uppercase characters will be considered invalid. The input contract is as follows:fromString("foo", plugin) -> "plugin:foo" fromString("foo:bar", plugin) -> "foo:bar" fromString(":foo", null) -> "minecraft:foo" fromString("foo", null) -> "minecraft:foo" fromString("Foo", plugin) -> null fromString(":Foo", plugin) -> null fromString("foo:bar:bazz", plugin) -> null fromString("", plugin) -> null- Parameters:
string- the string to convert to a NamespacedKeydefaultNamespace- the default namespace to use if none was supplied. If null, theminecraftnamespace (minecraft(String)) will be used- Returns:
- the created NamespacedKey. null if invalid key
- See Also:
-
fromString
Get a NamespacedKey from the supplied string.The default namespace will be Minecraft's (i.e.
minecraft(String)).- Parameters:
key- the key to convert to a NamespacedKey- Returns:
- the created NamespacedKey. null if invalid
- See Also:
-
namespace
- Specified by:
namespacein interfacenet.kyori.adventure.key.Key- Specified by:
namespacein interfacenet.kyori.adventure.key.Namespaced
-
value
- Specified by:
valuein interfacenet.kyori.adventure.key.Key
-
asString
- Specified by:
asStringin interfacenet.kyori.adventure.key.Key
-