Skip to content

Commit 866f50c

Browse files
committed
Cleanup
1 parent 102b5e0 commit 866f50c

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ The time argument allows the user to define a time frame, similar to the Vanilla
102102

103103
If you choose to use this argument, it is advised to explain to the users what these suffixes mean, as real time (`s` suffix) is mixed with in-game time (`t` and `d` suffix).
104104

105-
The `ArgumentType.time()` method has one additional overload: `ArgumentType.time(int mintime)`. This allows to set the minimum required amount of ticks this argument has to resolve to.
105+
The `ArgumentTypes.time()` method has one additional overload: `ArgumentTypes.time(int mintime)`. This allows to set the minimum required amount of ticks this argument has to resolve to.
106106
By default this value is set to 0.
107107

108108
### Example usage

docs/paper/dev/api/command-api/arguments/registry.mdx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,17 @@ Here is the tab completion when using `ArgumentTypes.resource(RegistryKey.ITEM)`
117117
And here is the tab completion when using `ArgumentTypes.resourceKey(RegistryKey.ITEM)`:
118118
<FullWidthVideo src={ResourceKeyItem}/><br/>
119119

120-
The resource argument provides a much cleaner user experience, whilst the `resourceKey` argument has one very important usecase: You get the raw
120+
:::note
121+
122+
In the example given above, due to an unhandled null pointer exception, the command does not successfully run. The code for that command is directly trying to use the value retrieved
123+
by the registry access by doing `ItemType item = RegistryAccess.registryAccess().getRegistry(itemKey.registryKey()).get(itemKey.key())`. If you try to do any
124+
operation with the result, it might be null and error.
125+
126+
You should **always** check the result of a registry retrieval operation. An example for that is given below in the [direct code comparison](#direct-code-comparison).
127+
128+
:::
129+
130+
The resource argument provides a much cleaner user experience, whilst the `resourceKey` argument has one very important use case: You get the raw
121131
`TypedKey<T>` returned as an argument result. This object is particularly useful, as it provides all information required to be able to retrieve
122132
a value from a registry yourself.
123133

@@ -167,14 +177,14 @@ Commands.argument("item", ArgumentTypes.resourceKey(RegistryKey.ITEM))
167177
```
168178

169179
### Using a TypedKey
170-
First, in order to get the correct registry, you can run `RegistryAccess#getregistry(RegistryKey)`. In order to get a `RegistryAccess`, you can just use the static
171-
`RegistryAccess.registryAccess()` method. The `RegistryKey` is retrieved using `TypedKey#registryKey`.
172-
Now, in order to get the final value `T`, you can run `Registry#get(Key)`, where the key can be retrieved using `TypedKey#key`. This will return the backing instance
180+
First, in order to get the correct registry, you can run `RegistryAccess#getRegistry(RegistryKey)`. In order to get a `RegistryAccess`, you can just use the static
181+
`RegistryAccess.registryAccess()` method. The `RegistryKey` is retrieved using `TypedKey#registryKey()`.
182+
Now, in order to get the final value `T`, you can run `Registry#get(Key)`, where the key can be retrieved using `TypedKey#key()`. This will return the backing instance
173183
from that resource key or null, if no value has been found.
174184

175-
### Usecase over resource argument
176-
The main usecase for this argument type is the ability to store the key (the value returned to you by `TypedKey#key`). If you want to be able to store the exact user
177-
input and be able to retrieve the backed instance without much throuble, that is the way to do it.
185+
### Use case over resource argument
186+
The main use case for this argument type is the ability to store the key (the value returned to you by `TypedKey#key`). If you want to be able to store the exact user
187+
input and be able to retrieve the backed instance without much trouble, that is the way to do it.
178188

179189
## Registry key previews
180190

@@ -213,8 +223,6 @@ At the time of writing, the following RegistryKeys exist:
213223
| VILLAGER_TYPE | Villager.Type | [Villager Type](#villager-type) |
214224
| WOLF_VARIANT | Wolf.Variant | [Wolf Variant](#wolf-variant) |
215225

216-
Add: ENCHANTMENT, ENTITY_TYPE, MEMORY_MODULE_TYPE, PARTICLE_TYPE, POTION, TRIM_MATERIAL, TRIM_PATTERN
217-
218226
### Attribute
219227
<FullWidthVideo src={ResourceAttributes}/>
220228

docs/paper/dev/api/command-api/misc/comparison-bukkit-brigadier.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ After that, you can define your command like this:
6464
```java title="PluginClass.java"
6565
this.getServer().getCommandMap().register(
6666
this.getName().toLowerCase(),
67-
new BukkitPartyCommand("bukkitparty", "Have a party", "/party <player>", List.of())
67+
new BukkitPartyCommand("bukkitparty", "Have a party", "/bukkitparty <player>", List.of())
6868
);
6969
```
7070

0 commit comments

Comments
 (0)