Skip to content

Commit

Permalink
Update Codec info
Browse files Browse the repository at this point in the history
  • Loading branch information
melontini committed May 10, 2024
1 parent 094d94e commit ca8fea7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/develop/Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ In general, you should prefer to implement Brigadier `/` commands, but there are

## Creating commands

Creating new commands is easy, you'll have to implement the `Command` interface, create a [Codec](https://forge.gemwire.uk/wiki/Codecs) to serialize/deserialize the command and register the codec with `CommandTypes.register()`.
Creating new commands is easy, you'll have to implement the `Command` interface, create a [MapCodec](https://forge.gemwire.uk/wiki/Codecs) to serialize/deserialize the command and register the codec with `CommandTypes.register()`.

Let's create a simple command which will print a string to standard output.

Expand All @@ -27,7 +27,7 @@ public record DummyCommand(String text) implements Command {
Now create a [Codec](https://forge.gemwire.uk/wiki/Codecs) for your command.

```java
public static final Codec<DummyCommand> CODEC = Codec.STRING.fieldOf("text").xmap(DummyCommand::new, DummyCommand::text).codec();
public static final MapCodec<DummyCommand> CODEC = Codec.STRING.fieldOf("text").xmap(DummyCommand::new, DummyCommand::text);
```

With that done, we'll have to register the command to get our `CommandType`.
Expand Down

0 comments on commit ca8fea7

Please sign in to comment.