# Custom Arguments

In order to create a custom argument, you have to:

* Create the `ArgumentType<T>`.
* Create the `Argument<T>` .
* Register it in an argument registry, such as the `PaperArgumentRegistry`.

Our `T` (in this case, a record `Person`):<br>

```java
public record Person(String name, int age, String favouriteFood) {
}
```

Paper-specific example of creating the `ArgumentType<T>`:

```java
public class PersonArgumentType implements CustomArgumentType.Converted<@NotNull Person, @NotNull String> {
    @Override
    public @NotNull Person convert(@NotNull String nativeType) throws CommandSyntaxException {
        final String[] parts = nativeType.split(":");
        return new Person(parts[0], Integer.parseInt(parts[1]), parts[2]);
    }

    @Override
    public ArgumentType<String> getNativeType() {
        return StringArgumentType.greedyString();
    }
}
```

Creating the `Argument<T>`:

```java
public class PersonArgument implements Argument<PersonArgumentType> {
    @Override
    public PersonArgumentType create(Object[] options) {
        return new PersonArgumentType();
    }
}
```

Finally, registering the argument in the `PaperArgumentRegistry`:

```java
final ArgumentRegistry argumentRegistry = funmandsManager.getArgumentRegistry();

argumentRegistry.register("person", new PersonArgument());
```

Now, to use it:

```java
this.addFormat("person:person", ctx -> {
final Person person = ctx.get("person");

ctx.getExecutor().sendMessage(Component.text(person.name()));
ctx.getExecutor().sendMessage(Component.text(person.age()));
ctx.getExecutor().sendMessage(Component.text(person.favouriteFood()));
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://slimecraft.gitbook.io/slimecraft-docs/deep-dive/arguments/custom-arguments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
