Package org.spongepowered.api
Interface ResourceKey
-
- All Superinterfaces:
java.lang.Comparable<Key>,net.kyori.examination.Examinable,Key,Keyed,Namespaced
public interface ResourceKey extends Key
An object representation of a location or pointer to resources. The key can be represented as aStringbyObject.toString(). The key is built with two parts:- The Namespace
- The Value
ResourceKey, including but not restricted toDataRegistrations,ConfigurationNodes,DataTranslators, andDataSerializables.Note that the methods
minecraft(String)andsponge(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
Nested Classes Modifier and Type Interface Description static interfaceResourceKey.BuilderA builder to createResourceKeys.static interfaceResourceKey.FactoryA factory to generateResourceKeys.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBRIGADIER_NAMESPACEThe brigadier namespace.static java.lang.StringMINECRAFT_NAMESPACEThe minecraft namespace.static java.lang.StringSPONGE_NAMESPACEThe sponge namespace.-
Fields inherited from interface net.kyori.adventure.key.Key
DEFAULT_SEPARATOR
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default java.lang.StringasString()static @NonNull ResourceKeybrigadier(java.lang.String value)Creates a resource key with a namespace ofbrigadier.static ResourceKey.Builderbuilder()Creates a newResourceKey.Builderfor creatingResourceKeys.default intcompareTo(Key o)default java.lang.Stringformatted()Gets this key as a formatted value.static @NonNull ResourceKeyminecraft(java.lang.String value)Creates a resource key with a namespace ofminecraft.static ResourceKeyof(java.lang.String namespace, java.lang.String value)Creates a resource key.static ResourceKeyof(org.spongepowered.plugin.PluginContainer plugin, java.lang.String value)Creates a resource key.static ResourceKeyresolve(java.lang.String formatted)Resolves a resource key from a string.static @NonNull ResourceKeysponge(java.lang.String value)Creates a resource key with a namespace ofsponge.-
Methods inherited from interface net.kyori.adventure.key.Key
examinableProperties, key, namespace, value
-
-
-
-
Field Detail
-
BRIGADIER_NAMESPACE
static final java.lang.String BRIGADIER_NAMESPACE
The brigadier namespace.- See Also:
- Constant Field Values
-
MINECRAFT_NAMESPACE
static final java.lang.String MINECRAFT_NAMESPACE
The minecraft namespace.- See Also:
- Constant Field Values
-
SPONGE_NAMESPACE
static final java.lang.String SPONGE_NAMESPACE
The sponge namespace.- See Also:
- Constant Field Values
-
-
Method Detail
-
brigadier
static @NonNull ResourceKey brigadier(java.lang.String value)
Creates a resource key with a namespace ofbrigadier.- Parameters:
value- The value- Returns:
- A new resource key
-
minecraft
static @NonNull ResourceKey minecraft(java.lang.String value)
Creates a resource key with a namespace ofminecraft.- Parameters:
value- The value- Returns:
- A new resource key
-
sponge
static @NonNull ResourceKey sponge(java.lang.String value)
Creates a resource key with a namespace ofsponge.- Parameters:
value- The value- Returns:
- A new resource key
-
builder
static ResourceKey.Builder builder()
Creates a newResourceKey.Builderfor creatingResourceKeys. The builder can be used for creating keys based onPluginContainers,Objects of plugins, andStringnamespaces.- Returns:
- The new builder instance
-
of
static ResourceKey of(java.lang.String namespace, java.lang.String value)
Creates a resource key.- Parameters:
namespace- The namespacevalue- The value- Returns:
- A new resource key
-
of
static ResourceKey of(org.spongepowered.plugin.PluginContainer plugin, java.lang.String value)
Creates a resource key.- Parameters:
plugin- The pluginvalue- The value- Returns:
- A new resource key
-
resolve
static ResourceKey resolve(java.lang.String formatted)
Resolves a resource key from a string.If no namespace is found in
formattedthenMINECRAFT_NAMESPACEwill be the namespace.- Parameters:
formatted- The formatted string to parse- Returns:
- A new resource key
-
formatted
default java.lang.String 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
-
-