endstone::NamespacedKey
Represents a string-based key which consists of two components - a namespace and a key.
Attributes:
Name | Description |
---|---|
MINECRAFT |
Functions:
Name | Description |
---|---|
getKey | |
getNamespace | |
toString |
Functions:
Name | Description |
---|---|
create | Create a key in the plugin’s namespace. |
fromString |
MINECRAFT
std::string_view endstone::NamespacedKey::MINECRAFT;
The namespace representing all inbuilt keys.
getKey
const std::string &getKey() noexcept const
getNamespace
const std::string &getNamespace() noexcept const
toString
std::string toString() noexcept const
create
static Result<NamespacedKey> create(const Plugin &plugin, std::string_view key)
Create a key in the plugin’s namespace.
Parameters:
plugin
the plugin to use for the namespacekey
the key to create
fromString
static Result<NamespacedKey> fromString(std::string_view input,
const Plugin *plugin = nullptr)
Parse a NamespacedKey from a string, with an optional default namespace.
Examples:
- fromString(“foo”, plugin) -> “plugin:foo”
- fromString(“foo:bar”, nullptr) -> “foo:bar”
- fromString(“:foo”, nullptr) -> “minecraft:foo”
- fromString(“foo”, nullptr) -> “minecraft:foo”
- fromString(“Foo”, plugin) -> std::nullopt
Parameters:
input
the string to parseplugin
optional default namespace; if nullptr, uses the minecraft namespace
Returns:
optional containing the parsed key, or std::nullopt if invalid
Last updated on