Skip to Content
⚠ Under Construction
ReferenceC++ APINamespacedKey

endstone::NamespacedKey

Represents a string-based key which consists of two components - a namespace and a key.

Attributes:

NameDescription
MINECRAFT

Functions:

Functions:

NameDescription
createCreate 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 namespace
  • key 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 parse
  • plugin optional default namespace; if nullptr, uses the minecraft namespace

Returns:

optional containing the parsed key, or std::nullopt if invalid

Last updated on