enum

inline fun <E : Enum<E>> PaperLiteralNode.enum(name: String, values: Iterable<E> = enumValues<E>().asList(), noinline block: PaperArgumentNode<E>.() -> Unit)

Adds an enum-backed "choice" argument to this command.

Each enum constant is mapped to a lowercase token by default (e.g. FOO_BAR ->foo_bar). The argument will only accept those tokens and will suggest them for tab-completion.

Implementation detail: This uses Paper's CustomArgumentType.Converted, delegating to a native StringArgumentType.word() on the client and converting the string to the enum on the server.

Consequences:

  • Client-side syntax validation only sees a generic string argument.

  • Invalid enum values are rejected on the server when the command is executed.

  • Suggestions are provided by the server in enum declaration order.

Documentation: Custom arguments

See also


inline fun <E : Enum<E>> PaperContext.enum(name: String): E

Returns the parsed enum value of an enum argument.

See also