Package org.bukkit
Class NamespacedKey
java.lang.Object
org.bukkit.NamespacedKey
Represents a String based key which consists of two components - a namespace
 and a 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.
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionNamespacedKey(String namespace, String key) Deprecated.should never be used by plugins, for internal use only!!NamespacedKey(Plugin plugin, String key) Create a key in the plugin's namespace.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanstatic NamespacedKeyfromString(String key) Get a NamespacedKey from the supplied string.static NamespacedKeyfromString(String string, Plugin defaultNamespace) Get a NamespacedKey from the supplied string with a default namespace if a namespace is not defined.getKey()inthashCode()static NamespacedKeyGet a key in the Minecraft namespace.static NamespacedKeyDeprecated.should never be used by plugins, for internal use only!!toString()
- 
Field Details- 
MINECRAFTThe namespace representing all inbuilt keys.- See Also:
 
- 
BUKKITThe namespace representing all keys generated by Bukkit for backwards compatibility measures.- See Also:
 
 
- 
- 
Constructor Details- 
NamespacedKeyDeprecated.should never be used by plugins, for internal use only!!Create a key in a specific namespace.- Parameters:
- namespace- namespace
- key- key
 
- 
NamespacedKeyCreate 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 namespace
- key- the key to create
 
 
- 
- 
Method Details- 
getNamespace
- 
getKey
- 
hashCodepublic int hashCode()
- 
equals
- 
toString
- 
randomKeyDeprecated.should never be used by plugins, for internal use only!!Return a new random key in theBUKKITnamespace.- Returns:
- new key
 
- 
minecraftGet a key in the Minecraft namespace.- Parameters:
- key- the key to use
- Returns:
- new key in the Minecraft namespace
 
- 
fromString@Nullable public static 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. 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 NamespacedKey
- defaultNamespace- the default namespace to use if none was supplied. If null, the- minecraftnamespace (- minecraft(String)) will be used
- Returns:
- the created NamespacedKey. null if invalid key
- See Also:
 
- 
fromStringGet 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:
 
 
-