Skip to content

Commit 38d29d4

Browse files
added javadoc reference + deleted code comment
1 parent b5d9e42 commit 38d29d4

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

docs/paper/dev/api/commands-api/arguments.mdx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Paper's command system is still experimental and may change in the future.
1313

1414
:::
1515

16-
## Basic usage
16+
## Basic usage of arguments
1717

1818
You can add arguments to a command by doing the following:
1919
```java title="YourPluginClass.java"
@@ -50,18 +50,18 @@ sender will get a message containing the key of the enchantment they selected.
5050
- Custom types
5151
- Non alphanumerical sorting
5252

53-
## Types
53+
## Enchantment types
5454

55-
By default, you can use [the registry API](../registries.mdx) to get simple argument types like
56-
blocks, items, potions and many more. In the example above, we used the `Enchantment`
57-
argument type, but there are many others:
55+
By default, you can use [registries](../registries) to get simple argument types like
56+
blocks, items, potions and many more. In the example above, we used the Enchantment
57+
Argument type but there are many others:
5858

5959
### Predefined types (Registry)
6060

6161
| Registry key name | Return datatype class | Description |
6262
|---------------------|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
6363
| GAME_EVENT | GameEvent | Events in the game (eating, flying with an elytra etc.) |
64-
| STRUCTURE_TYPE | StructureType | [Structures](https://minecraft.wiki/w/Structure#Overworld) - Beware that, as of Paper 1.20.6-147, there is also a Registry named `STRUCTURE` that is not recognized by the client and makes it unable to connect. This has been reported to Paper developers and will be fixed in a future release. |
64+
| STRUCTURE_TYPE | StructureType | [Structures](https://minecraft.wiki/w/Structure#Overworld)
6565
| INSTRUMENT | CraftMusicInstrument | [Note block instrument](https://minecraft.wiki/w/Note_Block) |
6666
| ENCHANTMENT | Enchantment | [Enchantment type](https://minecraft.wiki/w/Enchanting#Summary_of_enchantments) |
6767
| MOB_EFFECT | PotionEffectType | [Potion effect](https://minecraft.wiki/w/Effect#List) |
@@ -87,16 +87,14 @@ argument type, but there are many others:
8787
| MAP_DECORATION_TYPE | MapCursor.Type | [Types of sprites displayed on a map](https://minecraft.wiki/w/Map#Map_icons) |
8888
| FLUID | Fluid | [Fluid types](https://minecraft.wiki/w/Fluid)
8989

90-
### Predefined types (in Brigadier itself)
91-
92-
Brigadier itself also specifies many argument types. For more information on them, see <Javadoc name={"io.papermc.paper.command.brigadier.argument.ArgumentTypes"}>ArgumentTypes</Javadoc>.
90+
Brigadier itself also specifies many argument types. For more information on them, see <Javadoc name={"io.papermc.paper.command.brigadier.argument.ArgumentTypes"}>LifecycleEventManager</Javadoc>
9391

9492
### Custom types
9593

9694
Custom arguments can be created by implementing the <Javadoc name={"io.papermc.paper.command.brigadier.argument.CustomArgumentType"}>CustomArgumentType</Javadoc>
9795
interface.
9896

99-
Now, let's say that we want to implement a command which lets you order ice cream. For that,
97+
Now, lets say that we want to implement a command which lets you order ice cream. For that,
10098
we add an enum that specifies all available values for our custom type.
10199

102100
```java
@@ -142,7 +140,7 @@ public class IceCreamTypeArgument implements CustomArgumentType.Converted<IceCre
142140
}
143141
```
144142

145-
That's a lot of code, so let's start from the top. We implemented the `CustomArgumentType.Converted`
143+
That's a lot of code, so let's start from the top. We implemented the <Javadoc name={"io.papermc.paper.command.brigadier.argument.CustomArgumentType$Converted"}>CustomArgumentType.Converted</Javadoc>
146144
interface. This interface takes two type arguments: our custom enum, T, and a type that is native to
147145
Minecraft, such as String, Integer, etc., called N. The native type exists so that the client can use
148146
the input data, as it doesn't know what our custom `IceCreamType` is.
@@ -160,7 +158,7 @@ In the last method, `listSuggestions()`, we return `CompletableFuture<Suggestion
160158
can suggest all available options. We can even add tooltips to the suggestions to explain them in greater
161159
detail.
162160

163-
As a last step, we need to register the command:
161+
As a last step, we need to register the Command:
164162

165163
```java
166164
public void onEnable() {
@@ -170,7 +168,7 @@ public void onEnable() {
170168
commands.register(Commands.literal("ordericecream")
171169
.then(
172170
Commands.argument("flavor", new IceCreamTypeArgument()).executes((commandContext -> {
173-
IceCreamType argumentResponse = commandContext.getArgument("flavor", IceCreamType.class); // Gets the raw argument
171+
IceCreamType argumentResponse = commandContext.getArgument("flavor", IceCreamType.class);
174172
commandContext.getSource().getSender().sendMessage(Component.text("You ordered: " + argumentResponse));
175173
return 1;
176174
}))
@@ -180,9 +178,9 @@ public void onEnable() {
180178
}
181179
```
182180

183-
Now that we have registered the command, we can execute it in-game:
181+
Now that we have registered the command, we can execute it ingame:
184182

185183
![command with suggestions](./assets/icecreamargument.gif)
186-
Look, we can even see our tooltip and if we execute the command, we get the message we specified:
184+
Look, we can even see our tooltip and if we execute the command, we get the message we specified
187185

188186
![executed command](./assets/command-executed.gif)

0 commit comments

Comments
 (0)