Skip to content

Add simple commands docs - #363

Open
MagnusHJensen wants to merge 4 commits into
neoforged:mainfrom
MagnusHJensen:initial-command-docs
Open

Add simple commands docs#363
MagnusHJensen wants to merge 4 commits into
neoforged:mainfrom
MagnusHJensen:initial-command-docs

Conversation

@MagnusHJensen

@MagnusHJensen MagnusHJensen commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Hey 👋 First time contributor here.

I wanted to try and take a crack at adding some simple documentation for commands. Should resolve #299 if found satisfactory enough, my plan is to come with a follow-up PR for how to create a custom argument type.

Let me know if modifying the other category indicies is incorrect and should be reverted.

Please suggest as many changes as needed to the wording, it's my first time trying to contribute more than typos to public documentation, as I'm hoping to improve.


Preview URL: https://pr-363.neoforged-docs-previews.pages.dev

@IchHabeHunger54
IchHabeHunger54 requested a review from a team July 11, 2026 16:47
@IchHabeHunger54 IchHabeHunger54 added the addition Adding or rewriting information. label Jul 11, 2026

@IchHabeHunger54 IchHabeHunger54 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello and thanks for the contribution! This is a good PR, most things I noticed are typos or formatting issues.

Comment thread docs/commands/index.md Outdated
Comment thread docs/commands/index.md Outdated
Comment thread docs/commands/index.md Outdated
Comment thread docs/commands/index.md Outdated
Comment thread docs/commands/index.md Outdated
Comment thread docs/commands/index.md Outdated
@MagnusHJensen

Copy link
Copy Markdown
Contributor Author

@IchHabeHunger54 Hi, I just tweaked based on your comments and added the custom argument type as well. I did end up putting it into the top-level document page, which IMO I think is fine. Let me know if you think otherwise :D

@IchHabeHunger54 IchHabeHunger54 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, a few requests for changes and some info I noticed to be missing by looking at my own modded commands:

  • In the #executes lambda, please explain what the return value means. In many vanilla instances, this returns the amount of players affected. (See e.g. the /teleport command).
  • Permissions should be touched upon shortly. Something like .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) being mentioned somewhere would be good.
  • Commands currently have their own docs folder. Since they are a single article, please move them into the Misc section and undo the changing of the _category_.json files.

Comment thread docs/commands/index.md

## Custom Argument Types

A value that none of the existing types can parse is handled by implementing a custom argument type via. `ArgumentType<T>`, which reads the raw command text from a `StringReader` and returns a value of type `T`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A value that none of the existing types can parse is handled by implementing a custom argument type via. `ArgumentType<T>`, which reads the raw command text from a `StringReader` and returns a value of type `T`.
A value that none of the existing types can parse is handled by implementing a custom argument type via `ArgumentType<T>`, which reads the raw command text from a `StringReader` and returns a value of type `T`.

Comment thread docs/commands/index.md
A value that none of the existing types can parse is handled by implementing a custom argument type via. `ArgumentType<T>`, which reads the raw command text from a `StringReader` and returns a value of type `T`.

```java
public class SpellArgument implements ArgumentType<Spell> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention that Spell is a custom type for the sake of example, e.g. in a comment above the class.

@neoforged-pages-deployments
neoforged-pages-deployments Bot deployed to neoforged-docs-previews (Preview) July 27, 2026 09:59 Active
@neoforged-pages-deployments

Copy link
Copy Markdown

Deploying with Cloudflare Pages

Name Result
Last commit: 238c11e0dee05f89f86d3d38f9b5ca8c7fdbf3e1
Status: ✅ Deploy successful!
Preview URL: https://8e4584c9.neoforged-docs-previews.pages.dev
PR Preview URL: https://pr-363.neoforged-docs-previews.pages.dev

Comment on lines +1 to +4
{
"label": "Commands",
"position": 13
} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why this needs to be it's own section instead of something under misc.

Comment thread docs/commands/index.md
@Override
public Spell parse(StringReader reader) throws CommandSyntaxException {
String name = reader.readUnquotedString();
// Look up the spell, throwing ERROR_UNKNOWN_SPELL#createWithContext if there is none

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rephrase this to use the word 'validate' since that's functionally what it's supposed to do.

Comment thread docs/commands/index.md
Comment on lines +132 to +133
// Suggest the names of the available spells or none
return Suggestions.empty();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should elaborated on as the suggestions are obtained based on the sided context, meaning that if you plan to use data on the server, it may not show up if queried in a client context unless synced and referenced.

Comment thread docs/commands/index.md

An argument is used in two places. It is **declared** while building the tree, by supplying a name and an `ArgumentType`, and its parsed value is **accessed** inside the execution logic from the `CommandContext`, using that same name. The name is the contract between the two. The sections below cover each half in turn.

## Registering Commands

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there should be a minor note here for registering a command that's only available on the client. The process is exactly the same via RegisterClientCommandsEvent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition Adding or rewriting information.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add docs for commands

3 participants