public final class NamespacedKey extends Object implements net.kyori.adventure.key.Key, Namespaced
Keys may only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.
| Modifier and Type | Field and Description |
|---|---|
static String |
BUKKIT
The namespace representing all keys generated by Bukkit for backwards
compatibility measures.
|
static String |
MINECRAFT
The namespace representing all inbuilt keys.
|
| Constructor and Description |
|---|
NamespacedKey(@NotNull Plugin plugin,
@NotNull String key)
Create a key in the plugin's namespace.
|
NamespacedKey(@NotNull String namespace,
@NotNull String key)
Deprecated.
should never be used by plugins, for internal use only!!
|
| Modifier and Type | Method and Description |
|---|---|
@NotNull String |
asString() |
boolean |
equals(Object obj) |
static @Nullable NamespacedKey |
fromString(@NotNull String key)
Get a NamespacedKey from the supplied string.
|
static @Nullable NamespacedKey |
fromString(@NotNull String string,
@Nullable Plugin defaultNamespace)
Get a NamespacedKey from the supplied string with a default namespace if
a namespace is not defined.
|
@NotNull String |
getKey()
Gets the key corresponding to this resource
|
@NotNull String |
getNamespace()
Gets the namespace this resource is a part of
|
int |
hashCode() |
static @NotNull NamespacedKey |
minecraft(@NotNull String key)
Get a key in the Minecraft namespace.
|
@NotNull String |
namespace() |
static @NotNull NamespacedKey |
randomKey()
Deprecated.
should never be used by plugins, for internal use only!!
|
String |
toString() |
@NotNull String |
value() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitpublic static final String MINECRAFT
public static final String BUKKIT
@Deprecated public NamespacedKey(@NotNull @NotNull String namespace, @NotNull @NotNull String key)
namespace - namespacekey - keypublic NamespacedKey(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String key)
Namespaces may only contain lowercase alphanumeric characters, periods, underscores, and hyphens.
Keys may only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.
plugin - the plugin to use for the namespacekey - the key to create@NotNull public @NotNull String getNamespace()
NamespacedThis is contractually obligated to only contain lowercase alphanumeric characters, periods, underscores, and hyphens.
getNamespace in interface Namespaced@NotNull public @NotNull String getKey()
NamespacedThis is contractually obligated to only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.
getKey in interface Namespaced@Deprecated @NotNull public static @NotNull NamespacedKey randomKey()
BUKKIT namespace.@NotNull public static @NotNull NamespacedKey minecraft(@NotNull @NotNull String key)
key - the key to use@Nullable public static @Nullable NamespacedKey fromString(@NotNull @NotNull String string, @Nullable @Nullable Plugin defaultNamespace)
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
string - the string to convert to a NamespacedKeydefaultNamespace - the default namespace to use if none was
supplied. If null, the minecraft namespace
(minecraft(String)) will be usedfromString(String)@Nullable public static @Nullable NamespacedKey fromString(@NotNull @NotNull String key)
minecraft(String)).key - the key to convert to a NamespacedKeyfromString(String, Plugin)@NotNull public @NotNull String namespace()
namespace in interface net.kyori.adventure.key.Key@NotNull public @NotNull String value()
value in interface net.kyori.adventure.key.KeyCopyright © 2021. All rights reserved.