Package org.spongepowered.api
Interface ResourceKey
- All Superinterfaces:
Comparable<Key>
,net.kyori.examination.Examinable
,Key
,Keyed
,Namespaced
An object representation of a location or pointer to resources.
The key can be represented as a
String
by Object.toString()
.
The key is built with two parts:
- The Namespace
- The Value
ResourceKey
, including but
not restricted to DataRegistration
s, ConfigurationNode
s,
DataTranslator
s, and DataSerializable
s.
Note that the methods minecraft(String)
and
sponge(String)
should only be used by the implementations for
creating new keys and usage by plugins may result in
a crash condition by the implementation.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A builder to createResourceKey
s.static interface
A factory to generateResourceKey
s. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The brigadier namespace.static final String
The minecraft namespace.static final String
The sponge namespace.Fields inherited from interface net.kyori.adventure.key.Key
DEFAULT_SEPARATOR
-
Method Summary
Modifier and TypeMethodDescriptiondefault String
asString()
static @NonNull ResourceKey
Creates a resource key with a namespace ofbrigadier
.static ResourceKey.Builder
builder()
Creates a newResourceKey.Builder
for creatingResourceKey
s.default int
default String
Gets this key as a formatted value.static @NonNull ResourceKey
Creates a resource key with a namespace ofminecraft
.static ResourceKey
Creates a resource key.static ResourceKey
Creates a resource key.static ResourceKey
Resolves a resource key from a string.static @NonNull ResourceKey
Creates a resource key with a namespace ofsponge
.Methods inherited from interface net.kyori.examination.Examinable
examinableName, examine
Methods inherited from interface net.kyori.adventure.key.Key
examinableProperties, key, namespace, value
-
Field Details
-
BRIGADIER_NAMESPACE
The brigadier namespace.- See Also:
-
MINECRAFT_NAMESPACE
The minecraft namespace.- See Also:
-
SPONGE_NAMESPACE
The sponge namespace.- See Also:
-
-
Method Details
-
brigadier
Creates a resource key with a namespace ofbrigadier
.- Parameters:
value
- The value- Returns:
- A new resource key
-
minecraft
Creates a resource key with a namespace ofminecraft
.- Parameters:
value
- The value- Returns:
- A new resource key
-
sponge
Creates a resource key with a namespace ofsponge
.- Parameters:
value
- The value- Returns:
- A new resource key
-
builder
Creates a newResourceKey.Builder
for creatingResourceKey
s. The builder can be used for creating keys based onPluginContainer
s,Object
s of plugins, andString
namespaces.- Returns:
- The new builder instance
-
of
Creates a resource key.- Parameters:
namespace
- The namespacevalue
- The value- Returns:
- A new resource key
-
of
Creates a resource key.- Parameters:
plugin
- The pluginvalue
- The value- Returns:
- A new resource key
-
resolve
Resolves a resource key from a string.- Parameters:
formatted
- The formatted string to parse- Returns:
- A new resource key
-
formatted
Gets this key as a formatted value.It is up to the implementation to determine the formatting. In vanilla Minecraft, keys are formatted as "namespace:value". For example, "minecraft:carrot".
- Returns:
- The key, formatted
-
asString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Key>
- Specified by:
compareTo
in interfaceKey
-